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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
MerkleTree.fsti | MerkleTree.merkle_tree | val merkle_tree : Type0 | let merkle_tree = MTNL.merkle_tree | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 34,
"end_line": 30,
"start_col": 0,
"start_line": 30
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | Type0 | Prims.Tot | [
"total"
] | [] | [
"MerkleTree.Low.merkle_tree"
] | [] | false | false | false | true | true | let merkle_tree =
| MTNL.merkle_tree | false |
|
MerkleTree.fsti | MerkleTree.pt | val pt : _: _ -> _: _ -> _: _ -> Prims.logical | let pt = fun _ _ _ -> True | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 26,
"end_line": 37,
"start_col": 0,
"start_line": 37
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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.logical | Prims.Tot | [
"total"
] | [] | [
"Prims.l_True",
"Prims.logical"
] | [] | false | false | false | true | true | let pt =
| fun _ _ _ -> True | false |
|
MerkleTree.fsti | MerkleTree.hash | val hash : Type0 | let hash #hash_size = MTNLD.hash #hash_size | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 43,
"end_line": 24,
"start_col": 0,
"start_line": 24
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | Type0 | Prims.Tot | [
"total"
] | [] | [
"MerkleTree.Low.Datastructures.hash_size_t",
"MerkleTree.Low.Datastructures.hash"
] | [] | false | false | false | true | true | let hash #hash_size =
| MTNLD.hash #hash_size | false |
|
MerkleTree.fsti | MerkleTree.mt_p | val mt_p : Type0 | let mt_p = MTNL.mt_p | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 20,
"end_line": 31,
"start_col": 0,
"start_line": 31
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | Type0 | Prims.Tot | [
"total"
] | [] | [
"MerkleTree.Low.mt_p"
] | [] | false | false | false | true | true | let mt_p =
| MTNL.mt_p | false |
|
LowParse.Spec.ConstInt32.fst | LowParse.Spec.ConstInt32.parse_constint32le_unfold | val parse_constint32le_unfold (v: nat{0 <= v /\ v < 4294967296}) (input: bytes)
: Lemma
(parse (parse_constint32le v) input ==
(let res = parse parse_int32le input in
match res with
| Some (x, consumed) -> if U32.v x = v && consumed = 4 then Some (x, consumed) else None
| None -> None)) | val parse_constint32le_unfold (v: nat{0 <= v /\ v < 4294967296}) (input: bytes)
: Lemma
(parse (parse_constint32le v) input ==
(let res = parse parse_int32le input in
match res with
| Some (x, consumed) -> if U32.v x = v && consumed = 4 then Some (x, consumed) else None
| None -> None)) | let parse_constint32le_unfold
(v: nat { 0 <= v /\ v < 4294967296 } )
(input: bytes)
: Lemma
(parse (parse_constint32le v) input ==
(let res = parse parse_int32le input in
match res with
| Some (x, consumed) ->
if U32.v x = v && consumed = 4 then
Some (x, consumed)
else
None
| None -> None))
= let res = parse parse_int32le input in
match res with
| Some (x, consumed) ->
if U32.v x = v && consumed = 4 then
()
else
()
| None -> () | {
"file_name": "src/lowparse/LowParse.Spec.ConstInt32.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 16,
"end_line": 98,
"start_col": 0,
"start_line": 78
} | module LowParse.Spec.ConstInt32
(* LowParse specification module for parsing 32 bits = 4 bytes unsigned constants
Examples:
uint32 foo = 5
uint32_le foo = 7
*)
(* TODO: support big endian constants *)
include FStar.Endianness
include LowParse.Spec.Base
include LowParse.Spec.Combinators
include LowParse.Spec.Int32le
module U32 = FStar.UInt32
module U8 = FStar.UInt8
module Seq = FStar.Seq
module M = LowParse.Math
let constint32
(v: nat { 0 <= v /\ v < 4294967296 } )
: Tot Type
= (u: U32.t { U32.v u == v } )
inline_for_extraction
let parse_constint32le_kind
: parser_kind
= strong_parser_kind 4 4 None
let decode_constint32le
(v: nat {0 <= v /\ v < 4294967296 } )
(b: bytes { Seq.length b == 4 } )
: Tot (option (constint32 v))
= let v' = decode_int32le b in
if U32.v v' = v then
Some v'
else
None
let decode_constint32le_injective'
(v: nat { 0 <= v /\ v < 4294967296 } )
(b1: bytes { Seq.length b1 == 4 } )
(b2: bytes { Seq.length b2 == 4 } )
: Lemma
((Some? (decode_constint32le v b1) \/ Some? (decode_constint32le v b2))
/\ (decode_constint32le v b1 == decode_constint32le v b2)
==> Seq.equal b1 b2)
= let res1 = decode_constint32le v b1 in
let res2 = decode_constint32le v b2 in
match res1 with
| Some v1 ->
assert ( U32.v v1 == v );
(match res2 with
| Some v2 ->
assert ( U32.v v2 == v );
assert ( v1 == v2 );
decode_int32le_injective b1 b2
| None -> ())
| None -> ()
let decode_constint32le_injective
(v: nat { 0 <= v /\ v < 4294967296 } )
: Lemma
(make_constant_size_parser_precond 4 (constint32 v) (decode_constint32le v))
= Classical.forall_intro_2 (decode_constint32le_injective' v)
let parse_constint32le
(v: nat { 0 <= v /\ v < 4294967296 } )
: Tot (parser parse_constint32le_kind (constint32 v))
= decode_constint32le_injective v;
make_constant_size_parser 4 (constint32 v) (decode_constint32le v) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Int32le.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"LowParse.Spec.Base.fsti.checked",
"LowParse.Math.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Endianness.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.ConstInt32.fst"
} | [
{
"abbrev": true,
"full_module": "LowParse.Math",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Int32le",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Endianness",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 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 | v: Prims.nat{0 <= v /\ v < 4294967296} -> input: LowParse.Bytes.bytes
-> FStar.Pervasives.Lemma
(ensures
LowParse.Spec.Base.parse (LowParse.Spec.ConstInt32.parse_constint32le v) input ==
(let res = LowParse.Spec.Base.parse LowParse.Spec.Int32le.parse_int32le input in
(match res with
| FStar.Pervasives.Native.Some #_ (FStar.Pervasives.Native.Mktuple2 #_ #_ x consumed) ->
(match FStar.UInt32.v x = v && consumed = 4 with
| true -> FStar.Pervasives.Native.Some (x, consumed)
| _ -> FStar.Pervasives.Native.None)
<:
FStar.Pervasives.Native.option (LowParse.Spec.ConstInt32.constint32 v *
LowParse.Spec.Base.consumed_length input)
| FStar.Pervasives.Native.None #_ -> FStar.Pervasives.Native.None)
<:
FStar.Pervasives.Native.option (LowParse.Spec.ConstInt32.constint32 v *
LowParse.Spec.Base.consumed_length input))) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"LowParse.Bytes.bytes",
"FStar.UInt32.t",
"LowParse.Spec.Base.consumed_length",
"Prims.op_AmpAmp",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt32.n",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt32.v",
"Prims.bool",
"Prims.unit",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.Base.parse",
"LowParse.Spec.Int32le.parse_int32le",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"LowParse.Spec.ConstInt32.constint32",
"LowParse.Spec.ConstInt32.parse_constint32le",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.None",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let parse_constint32le_unfold (v: nat{0 <= v /\ v < 4294967296}) (input: bytes)
: Lemma
(parse (parse_constint32le v) input ==
(let res = parse parse_int32le input in
match res with
| Some (x, consumed) -> if U32.v x = v && consumed = 4 then Some (x, consumed) else None
| None -> None)) =
| let res = parse parse_int32le input in
match res with
| Some (x, consumed) -> if U32.v x = v && consumed = 4 then ()
| None -> () | false |
Hacl.Poly1305.Field32xN.Lemmas0.fst | Hacl.Poly1305.Field32xN.Lemmas0.mul_felem5_lemma_2 | val mul_felem5_lemma_2:
f1:tup64_5{tup64_fits5 f1 (3, 3, 3, 3, 3)}
-> r:tup64_5{tup64_fits5 r (2, 2, 2, 2, 2)} ->
Lemma
(let (f10, f11, f12, f13, f14) = f1 in
let (r0, r1, r2, r3, r4) = r in
(as_nat5 f1 * as_nat5 r) % prime ==
(v f10 * as_nat5 r +
v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) +
v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) +
v f13 * pow78 * as_nat5 r + v f14 * pow104 * as_nat5 r) % prime) | val mul_felem5_lemma_2:
f1:tup64_5{tup64_fits5 f1 (3, 3, 3, 3, 3)}
-> r:tup64_5{tup64_fits5 r (2, 2, 2, 2, 2)} ->
Lemma
(let (f10, f11, f12, f13, f14) = f1 in
let (r0, r1, r2, r3, r4) = r in
(as_nat5 f1 * as_nat5 r) % prime ==
(v f10 * as_nat5 r +
v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) +
v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) +
v f13 * pow78 * as_nat5 r + v f14 * pow104 * as_nat5 r) % prime) | let mul_felem5_lemma_2 f1 r =
let (f10, f11, f12, f13, f14) = f1 in
let (r0, r1, r2, r3, r4) = r in
let tmp =
v f10 * as_nat5 r + v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) +
v f13 * pow78 * as_nat5 r + v f14 * pow104 * as_nat5 r in
calc (==) {
(as_nat5 f1 * as_nat5 r) % prime;
(==) { mul_felem5_lemma_1 f1 r }
(tmp + v f12 * pow52 * as_nat5 r) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp (v f12 * pow52 * as_nat5 r) prime }
(tmp + (v f12 * pow52 * as_nat5 r) % prime) % prime;
(==) {
FStar.Math.Lemmas.paren_mul_right (v f12) pow52 (as_nat5 r);
FStar.Math.Lemmas.lemma_mod_mul_distr_r (v f12) (pow52 * as_nat5 r) prime }
(tmp + v f12 * (pow52 * as_nat5 r % prime) % prime) % prime;
(==) { lemma_fmul5_pow52 r }
(tmp + v f12 * (as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) % prime) % prime) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (v f12) (as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2)) prime }
(tmp + v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) % prime) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp (v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2)) prime }
(tmp + v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2)) % prime;
};
assert ((as_nat5 f1 * as_nat5 r) % prime == (tmp + v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2)) % prime) | {
"file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas0.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 117,
"end_line": 552,
"start_col": 0,
"start_line": 528
} | module Hacl.Poly1305.Field32xN.Lemmas0
open Lib.IntTypes
open Lib.IntVector
open Lib.Sequence
open FStar.Mul
open FStar.Calc
open Hacl.Spec.Poly1305.Vec
include Hacl.Spec.Poly1305.Field32xN
#reset-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0"
val lemma_prime: unit -> Lemma (pow2 130 % prime = 5)
let lemma_prime () =
assert_norm (pow2 130 % prime = 5 % prime);
assert_norm (5 < prime);
FStar.Math.Lemmas.modulo_lemma 5 prime
val lemma_mult_le: a:nat -> b:nat -> c:nat -> d:nat -> Lemma
(requires a <= b /\ c <= d)
(ensures a * c <= b * d)
let lemma_mult_le a b c d = ()
val lemma_mul5_distr_l: a:nat -> b:nat -> c:nat -> d:nat -> e:nat -> f:nat -> Lemma
(a * (b + c + d + e + f) == a * b + a * c + a * d + a * e + a * f)
let lemma_mul5_distr_l a b c d e f = ()
val lemma_mul5_distr_r: a:nat -> b:nat -> c:nat -> d:nat -> e:nat -> f:nat -> Lemma
((a + b + c + d + e) * f == a * f + b * f + c * f + d * f + e * f)
let lemma_mul5_distr_r a b c d e f = ()
val smul_mod_lemma:
#m1:scale32
-> #m2:scale32
-> a:nat{a <= m1 * max26}
-> b:nat{b <= m2 * max26} ->
Lemma (a * b % pow2 64 == a * b)
let smul_mod_lemma #m1 #m2 a b =
lemma_mult_le a (m1 * max26) b (m2 * max26);
assert (a * b <= m1 * m2 * max26 * max26);
FStar.Math.Lemmas.modulo_lemma (a * b) (pow2 64)
val smul_add_mod_lemma:
#m1:scale32
-> #m2:scale32
-> #m3:scale64{m3 + m1 * m2 <= 4096}
-> a:nat{a <= m1 * max26}
-> b:nat{b <= m2 * max26}
-> c:nat{c <= m3 * max26 * max26} ->
Lemma ((c + a * b % pow2 64) % pow2 64 == c + a * b)
let smul_add_mod_lemma #m1 #m2 #m3 a b c =
assert_norm ((m3 + m1 * m2) * max26 * max26 < pow2 64);
lemma_mult_le a (m1 * max26) b (m2 * max26);
assert (c + a * b <= m3 * max26 * max26 + m1 * m2 * max26 * max26);
FStar.Math.Lemmas.modulo_lemma (c + a * b) (pow2 64)
val add5_lemma1: ma:scale64 -> mb:scale64 -> a:uint64 -> b:uint64 -> Lemma
(requires v a <= ma * max26 /\ v b <= mb * max26 /\ ma + mb <= 64)
(ensures v (a +. b) == v a + v b /\ v (a +. b) <= (ma + mb) * max26)
let add5_lemma1 ma mb a b =
assert (v a + v b <= (ma + mb) * max26);
Math.Lemmas.lemma_mult_le_right max26 (ma + mb) 64;
assert (v a + v b <= 64 * max26);
assert_norm (64 * max26 < pow2 32);
Math.Lemmas.small_mod (v a + v b) (pow2 32)
#set-options "--ifuel 1"
val fadd5_eval_lemma_i:
#w:lanes
-> f1:felem5 w{felem_fits5 f1 (2,2,2,2,2)}
-> f2:felem5 w{felem_fits5 f2 (1,1,1,1,1)}
-> i:nat{i < w} ->
Lemma ((feval5 (fadd5 f1 f2)).[i] == pfadd (feval5 f1).[i] (feval5 f2).[i])
let fadd5_eval_lemma_i #w f1 f2 i =
let o = fadd5 f1 f2 in
let (f10, f11, f12, f13, f14) = as_tup64_i f1 i in
let (f20, f21, f22, f23, f24) = as_tup64_i f2 i in
let (o0, o1, o2, o3, o4) = as_tup64_i o i in
add5_lemma1 2 1 f10 f20;
add5_lemma1 2 1 f11 f21;
add5_lemma1 2 1 f12 f22;
add5_lemma1 2 1 f13 f23;
add5_lemma1 2 1 f14 f24;
assert (as_nat5 (o0, o1, o2, o3, o4) ==
as_nat5 (f10, f11, f12, f13, f14) + as_nat5 (f20, f21, f22, f23, f24));
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (f10, f11, f12, f13, f14)) (as_nat5 (f20, f21, f22, f23, f24)) prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
(as_nat5 (f10, f11, f12, f13, f14) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime
val smul_felem5_fits_lemma_i:
#w:lanes
-> #m1:scale32
-> #m2:scale32
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:uint64xN w{felem_fits1 f2 m2}
-> i:nat{i < w} ->
Lemma ((uint64xN_v (vec_mul_mod f2 u1)).[i] <= m1 * m2 * max26 * max26)
let smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 i =
let o = vec_mul_mod f2 u1 in
smul_mod_lemma #m1 #m2 (uint64xN_v u1).[i] (uint64xN_v f2).[i];
assert ((uint64xN_v o).[i] == (uint64xN_v u1).[i] * (uint64xN_v f2).[i]);
lemma_mult_le (uint64xN_v u1).[i] (m1 * max26) (uint64xN_v f2).[i] (m2 * max26)
val smul_felem5_eval_lemma_i:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2}
-> i:nat{i < w} ->
Lemma ((fas_nat5 (smul_felem5 #w u1 f2)).[i] == (uint64xN_v u1).[i] * (fas_nat5 f2).[i])
let smul_felem5_eval_lemma_i #w #m1 #m2 u1 f2 i =
let o = smul_felem5 #w u1 f2 in
let (m20, m21, m22, m23, m24) = m2 in
let vu1 = (uint64xN_v u1).[i] in
let (tf20, tf21, tf22, tf23, tf24) = as_tup64_i f2 i in
let (to0, to1, to2, to3, to4) = as_tup64_i o i in
smul_mod_lemma #m1 #m20 vu1 (v tf20);
smul_mod_lemma #m1 #m21 vu1 (v tf21);
smul_mod_lemma #m1 #m22 vu1 (v tf22);
smul_mod_lemma #m1 #m23 vu1 (v tf23);
smul_mod_lemma #m1 #m24 vu1 (v tf24);
assert ((fas_nat5 o).[i] == vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 +
vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104);
calc (==) {
vu1 * (fas_nat5 f2).[i];
(==) { }
vu1 * (v tf20 + v tf21 * pow26 + v tf22 * pow52 + v tf23 * pow78 + v tf24 * pow104);
(==) { lemma_mul5_distr_l vu1 (v tf20) (v tf21 * pow26) (v tf22 * pow52) (v tf23 * pow78) (v tf24 * pow104)}
vu1 * v tf20 + vu1 * (v tf21 * pow26) + vu1 * (v tf22 * pow52) + vu1 * (v tf23 * pow78) + vu1 * (v tf24 * pow104);
(==) {
FStar.Math.Lemmas.paren_mul_right vu1 (v tf21) pow26;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf22) pow52;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf23) pow78;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf24) pow104}
vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 + vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104;
};
assert (vu1 * (fas_nat5 f2).[i] == (fas_nat5 o).[i])
val smul_felem5_fits_lemma1:
#w:lanes
-> #m1:scale32
-> #m2:scale32
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:uint64xN w{felem_fits1 f2 m2} ->
Lemma (felem_wide_fits1 (vec_mul_mod f2 u1) (m1 * m2))
let smul_felem5_fits_lemma1 #w #m1 #m2 u1 f2 =
match w with
| 1 ->
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 0
| 2 ->
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 0;
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 1
| 4 ->
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 0;
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 1;
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 2;
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 3
val smul_felem5_fits_lemma:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2} ->
Lemma (felem_wide_fits5 (smul_felem5 #w u1 f2) (m1 *^ m2))
let smul_felem5_fits_lemma #w #m1 #m2 u1 f2 =
let (f20, f21, f22, f23, f24) = f2 in
let (m20, m21, m22, m23, m24) = m2 in
smul_felem5_fits_lemma1 #w #m1 #m20 u1 f20;
smul_felem5_fits_lemma1 #w #m1 #m21 u1 f21;
smul_felem5_fits_lemma1 #w #m1 #m22 u1 f22;
smul_felem5_fits_lemma1 #w #m1 #m23 u1 f23;
smul_felem5_fits_lemma1 #w #m1 #m24 u1 f24
val smul_felem5_eval_lemma:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2} ->
Lemma (fas_nat5 (smul_felem5 #w u1 f2) ==
map2 #nat #nat #nat (fun a b -> a * b) (uint64xN_v u1) (fas_nat5 f2))
let smul_felem5_eval_lemma #w #m1 #m2 u1 f2 =
FStar.Classical.forall_intro (smul_felem5_eval_lemma_i #w #m1 #m2 u1 f2);
eq_intro (fas_nat5 (smul_felem5 #w u1 f2))
(map2 #nat #nat #nat (fun a b -> a * b) (uint64xN_v u1) (fas_nat5 f2))
val smul_add_felem5_fits_lemma_i:
#w:lanes
-> #m1:scale32
-> #m2:scale32
-> #m3:scale64{m3 + m1 * m2 <= 4096}
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:uint64xN w{felem_fits1 f2 m2}
-> acc1:uint64xN w{felem_wide_fits1 acc1 m3}
-> i:nat{i < w} ->
Lemma ((uint64xN_v (vec_add_mod acc1 (vec_mul_mod f2 u1))).[i] <= (m3 + m1 * m2) * max26 * max26)
#push-options "--z3rlimit 200"
let smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 i =
let o = vec_add_mod acc1 (vec_mul_mod f2 u1) in
smul_add_mod_lemma #m1 #m2 #m3 (uint64xN_v u1).[i] (uint64xN_v f2).[i] (uint64xN_v acc1).[i];
assert ((uint64xN_v o).[i] == (uint64xN_v acc1).[i] + (uint64xN_v u1).[i] * (uint64xN_v f2).[i]);
lemma_mult_le (uint64xN_v u1).[i] (m1 * max26) (uint64xN_v f2).[i] (m2 * max26);
assert ((uint64xN_v o).[i] <= m3 * max26 * max26 + m1 * m2 * max26 * max26)
#pop-options
val smul_add_felem5_eval_lemma_i:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> #m3:scale64_5{m3 +* m1 *^ m2 <=* s64x5 4096}
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2}
-> acc1:felem_wide5 w{felem_wide_fits5 acc1 m3}
-> i:nat{i < w} ->
Lemma ((fas_nat5 (smul_add_felem5 #w u1 f2 acc1)).[i] ==
(fas_nat5 acc1).[i] + (uint64xN_v u1).[i] * (fas_nat5 f2).[i])
let smul_add_felem5_eval_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 i =
let o = smul_add_felem5 #w u1 f2 acc1 in
let (m20, m21, m22, m23, m24) = m2 in
let (m30, m31, m32, m33, m34) = m3 in
let vu1 = (uint64xN_v u1).[i] in
let (tf20, tf21, tf22, tf23, tf24) = as_tup64_i f2 i in
let (ta0, ta1, ta2, ta3, ta4) = as_tup64_i acc1 i in
let (to0, to1, to2, to3, to4) = as_tup64_i o i in
smul_add_mod_lemma #m1 #m20 #m30 vu1 (v tf20) (v ta0);
smul_add_mod_lemma #m1 #m21 #m31 vu1 (v tf21) (v ta1);
smul_add_mod_lemma #m1 #m22 #m32 vu1 (v tf22) (v ta2);
smul_add_mod_lemma #m1 #m23 #m33 vu1 (v tf23) (v ta3);
smul_add_mod_lemma #m1 #m24 #m34 vu1 (v tf24) (v ta4);
calc (==) {
(fas_nat5 o).[i];
(==) { }
v ta0 + vu1 * v tf20 + (v ta1 + vu1 * v tf21) * pow26 + (v ta2 + vu1 * v tf22) * pow52 +
(v ta3 + vu1 * v tf23) * pow78 + (v ta4 + vu1 * v tf24) * pow104;
(==) {
FStar.Math.Lemmas.distributivity_add_left (v ta1) (vu1 * v tf21) pow26;
FStar.Math.Lemmas.distributivity_add_left (v ta2) (vu1 * v tf22) pow52;
FStar.Math.Lemmas.distributivity_add_left (v ta3) (vu1 * v tf23) pow78;
FStar.Math.Lemmas.distributivity_add_left (v ta1) (vu1 * v tf24) pow104 }
v ta0 + v ta1 * pow26 + v ta2 * pow52 + v ta3 * pow78 + v ta4 * pow104 +
vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 + vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104;
(==) { }
(fas_nat5 acc1).[i] + vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 + vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104;
};
assert ((fas_nat5 o).[i] == (fas_nat5 acc1).[i] +
vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 + vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104);
calc (==) {
vu1 * (fas_nat5 f2).[i];
(==) { }
vu1 * (v tf20 + v tf21 * pow26 + v tf22 * pow52 + v tf23 * pow78 + v tf24 * pow104);
(==) { lemma_mul5_distr_l vu1 (v tf20) (v tf21 * pow26) (v tf22 * pow52) (v tf23 * pow78) (v tf24 * pow104)}
vu1 * v tf20 + vu1 * (v tf21 * pow26) + vu1 * (v tf22 * pow52) + vu1 * (v tf23 * pow78) + vu1 * (v tf24 * pow104);
(==) {
FStar.Math.Lemmas.paren_mul_right vu1 (v tf21) pow26;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf22) pow52;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf23) pow78;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf24) pow104}
vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 + vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104;
};
assert ((fas_nat5 o).[i] == (fas_nat5 acc1).[i] + vu1 * (fas_nat5 f2).[i])
val smul_add_felem5_fits_lemma1:
#w:lanes
-> #m1:scale32
-> #m2:scale32
-> #m3:scale64{m3 + m1 * m2 <= 4096}
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:uint64xN w{felem_fits1 f2 m2}
-> acc1:uint64xN w{felem_wide_fits1 acc1 m3} ->
Lemma (felem_wide_fits1 (vec_add_mod acc1 (vec_mul_mod f2 u1)) (m3 + m1 * m2))
let smul_add_felem5_fits_lemma1 #w #m1 #m2 #m3 u1 f2 acc1 =
match w with
| 1 ->
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 0
| 2 ->
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 0;
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 1
| 4 ->
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 0;
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 1;
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 2;
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 3
val smul_add_felem5_fits_lemma:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> #m3:scale64_5{m3 +* m1 *^ m2 <=* s64x5 4096}
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2}
-> acc1:felem_wide5 w{felem_wide_fits5 acc1 m3} ->
Lemma (felem_wide_fits5 (smul_add_felem5 #w u1 f2 acc1) (m3 +* m1 *^ m2))
let smul_add_felem5_fits_lemma #w #m1 #m2 #m3 u1 f2 acc1 =
let (f20, f21, f22, f23, f24) = f2 in
let (m20, m21, m22, m23, m24) = m2 in
let (a0, a1, a2, a3, a4) = acc1 in
let (m30, m31, m32, m33, m34) = m3 in
smul_add_felem5_fits_lemma1 #w #m1 #m20 #m30 u1 f20 a0;
smul_add_felem5_fits_lemma1 #w #m1 #m21 #m31 u1 f21 a1;
smul_add_felem5_fits_lemma1 #w #m1 #m22 #m32 u1 f22 a2;
smul_add_felem5_fits_lemma1 #w #m1 #m23 #m33 u1 f23 a3;
smul_add_felem5_fits_lemma1 #w #m1 #m24 #m34 u1 f24 a4
val smul_add_felem5_eval_lemma:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> #m3:scale64_5{m3 +* m1 *^ m2 <=* s64x5 4096}
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2}
-> acc1:felem_wide5 w{felem_wide_fits5 acc1 m3} ->
Lemma (fas_nat5 (smul_add_felem5 #w u1 f2 acc1) ==
map2 #nat #nat #nat (fun a b -> a + b) (fas_nat5 acc1)
(map2 #nat #nat #nat (fun a b -> a * b) (uint64xN_v u1) (fas_nat5 f2)))
let smul_add_felem5_eval_lemma #w #m1 #m2 #m3 u1 f2 acc1 =
let tmp =
map2 #nat #nat #nat (fun a b -> a + b) (fas_nat5 acc1)
(map2 #nat #nat #nat (fun a b -> a * b) (uint64xN_v u1) (fas_nat5 f2)) in
FStar.Classical.forall_intro (smul_add_felem5_eval_lemma_i #w #m1 #m2 #m3 u1 f2 acc1);
eq_intro (fas_nat5 (smul_add_felem5 #w u1 f2 acc1)) tmp
val lemma_fmul5_pow26: r:tup64_5 -> Lemma
(requires (let (r0, r1, r2, r3, r4) = r in v r4 * 5 <= 10 * pow26))
(ensures (let (r0, r1, r2, r3, r4) = r in
(pow26 * as_nat5 r) % prime == as_nat5 (r4 *! u64 5, r0, r1, r2, r3) % prime))
let lemma_fmul5_pow26 r =
let (r0, r1, r2, r3, r4) = r in
calc (==) {
(pow26 * as_nat5 r) % prime;
(==) { }
(pow26 * (v r0 + v r1 * pow26 + v r2 * pow52 + v r3 * pow78 + v r4 * pow104)) % prime;
(==) { lemma_mul5_distr_l pow26 (v r0) (v r1 * pow26) (v r2 * pow52) (v r3 * pow78) (v r4 * pow104) }
(v r0 * pow26 + pow26 * v r1 * pow26 + pow26 * v r2 * pow52 + pow26 * v r3 * pow78 + pow26 * v r4 * pow104) % prime;
(==) { }
(v r0 * pow26 + v r1 * pow26 * pow26 + v r2 * pow26 * pow52 + v r3 * pow26 * pow78 + v r4 * pow26 * pow104) % prime;
(==) {
assert_norm (pow26 * pow26 = pow52);
assert_norm (pow26 * pow52 = pow78);
assert_norm (pow26 * pow78 = pow104);
assert_norm (pow26 * pow104 = pow2 130) }
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + v r4 * pow2 130) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104) (v r4 * pow2 130) prime }
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + (v r4 * pow2 130) % prime) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (v r4) (pow2 130) prime }
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + (v r4 * (pow2 130 % prime)) % prime) % prime;
(==) { lemma_prime () }
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + (v r4 * 5) % prime) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104) (v r4 * 5) prime }
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + v r4 * 5) % prime;
};
assert ((pow26 * as_nat5 r) % prime ==
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + v r4 * 5) % prime)
val lemma_fmul5_pow52: r:tup64_5 -> Lemma
(requires (let (r0, r1, r2, r3, r4) = r in
v r4 * 5 <= 10 * pow26 /\ v r3 * 5 <= 10 * pow26))
(ensures (let (r0, r1, r2, r3, r4) = r in
(pow52 * as_nat5 r) % prime == as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) % prime))
let lemma_fmul5_pow52 r =
let (r0, r1, r2, r3, r4) = r in
calc (==) {
(pow52 * as_nat5 r) % prime;
(==) { assert_norm (pow52 == pow26 * pow26) }
(pow26 * pow26 * as_nat5 r) % prime;
(==) {
FStar.Math.Lemmas.paren_mul_right pow26 pow26 (as_nat5 r);
FStar.Math.Lemmas.lemma_mod_mul_distr_r pow26 (pow26 * as_nat5 r) prime }
(pow26 * (pow26 * as_nat5 r % prime)) % prime;
(==) { lemma_fmul5_pow26 r }
(pow26 * (as_nat5 (r4 *! u64 5, r0, r1, r2, r3) % prime)) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r pow26 (as_nat5 (r4 *! u64 5, r0, r1, r2, r3)) prime }
(pow26 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3)) % prime;
(==) { lemma_fmul5_pow26 (r4 *! u64 5, r0, r1, r2, r3) }
as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) % prime;
};
assert ((pow52 * as_nat5 r) % prime == as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) % prime)
val lemma_fmul5_pow78: r:tup64_5 -> Lemma
(requires (let (r0, r1, r2, r3, r4) = r in
v r4 * 5 <= 10 * pow26 /\ v r3 * 5 <= 10 * pow26 /\ v r2 * 5 <= 10 * pow26))
(ensures (let (r0, r1, r2, r3, r4) = r in
(pow78 * as_nat5 r) % prime == as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) % prime))
let lemma_fmul5_pow78 r =
let (r0, r1, r2, r3, r4) = r in
calc (==) {
(pow78 * as_nat5 r) % prime;
(==) { assert_norm (pow78 == pow26 * pow52) }
(pow26 * pow52 * as_nat5 r) % prime;
(==) {
FStar.Math.Lemmas.paren_mul_right pow26 pow52 (as_nat5 r);
FStar.Math.Lemmas.lemma_mod_mul_distr_r pow26 (pow52 * as_nat5 r) prime }
(pow26 * (pow52 * as_nat5 r % prime)) % prime;
(==) { lemma_fmul5_pow52 r }
(pow26 * (as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) % prime)) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r pow26 (as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2)) prime }
(pow26 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2)) % prime;
(==) { lemma_fmul5_pow26 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) }
as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) % prime;
};
assert ((pow78 * as_nat5 r) % prime == as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) % prime)
val lemma_fmul5_pow104: r:tup64_5 -> Lemma
(requires (let (r0, r1, r2, r3, r4) = r in
v r4 * 5 <= 10 * pow26 /\ v r3 * 5 <= 10 * pow26 /\
v r2 * 5 <= 10 * pow26 /\ v r1 * 5 <= 10 * pow26))
(ensures (let (r0, r1, r2, r3, r4) = r in
(pow104 * as_nat5 r) % prime == as_nat5 (r1 *! u64 5, r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0) % prime))
let lemma_fmul5_pow104 r =
let (r0, r1, r2, r3, r4) = r in
calc (==) {
(pow104 * as_nat5 r) % prime;
(==) { assert_norm (pow104 == pow26 * pow78) }
(pow26 * pow78 * as_nat5 r) % prime;
(==) {
FStar.Math.Lemmas.paren_mul_right pow26 pow78 (as_nat5 r);
FStar.Math.Lemmas.lemma_mod_mul_distr_r pow26 (pow78 * as_nat5 r) prime }
(pow26 * (pow78 * as_nat5 r % prime)) % prime;
(==) { lemma_fmul5_pow78 r }
(pow26 * (as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) % prime)) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r pow26 (as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1)) prime }
(pow26 * as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1)) % prime;
(==) { lemma_fmul5_pow26 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) }
as_nat5 (r1 *! u64 5, r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0) % prime;
};
assert ((pow104 * as_nat5 r) % prime == as_nat5 (r1 *! u64 5, r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0) % prime)
val mul_felem5_lemma_1:
f1:tup64_5{tup64_fits5 f1 (3, 3, 3, 3, 3)}
-> r:tup64_5{tup64_fits5 r (2, 2, 2, 2, 2)} ->
Lemma
(let (f10, f11, f12, f13, f14) = f1 in
let (r0, r1, r2, r3, r4) = r in
(as_nat5 f1 * as_nat5 r) % prime ==
(v f10 * as_nat5 r +
v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) +
v f12 * pow52 * as_nat5 r + v f13 * pow78 * as_nat5 r + v f14 * pow104 * as_nat5 r) % prime)
let mul_felem5_lemma_1 f1 r =
let (f10, f11, f12, f13, f14) = f1 in
let (r0, r1, r2, r3, r4) = r in
let tmp = v f10 * as_nat5 r + v f12 * pow52 * as_nat5 r + v f13 * pow78 * as_nat5 r + v f14 * pow104 * as_nat5 r in
calc (==) {
(as_nat5 f1 * as_nat5 r) % prime;
(==) { }
(v f10 + v f11 * pow26 + v f12 * pow52 + v f13 * pow78 + v f14 * pow104) * as_nat5 r % prime;
(==) { lemma_mul5_distr_r (v f10) (v f11 * pow26) (v f12 * pow52) (v f13 * pow78) (v f14 * pow104) (as_nat5 r) }
(v f10 * as_nat5 r + v f11 * pow26 * as_nat5 r + v f12 * pow52 * as_nat5 r + v f13 * pow78 * as_nat5 r + v f14 * pow104 * as_nat5 r) % prime;
(==) {
FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp (v f11 * pow26 * as_nat5 r) prime }
(tmp + (v f11 * pow26 * as_nat5 r) % prime) % prime;
(==) {
FStar.Math.Lemmas.paren_mul_right (v f11) pow26 (as_nat5 r);
FStar.Math.Lemmas.lemma_mod_mul_distr_r (v f11) (pow26 * as_nat5 r) prime }
(tmp + v f11 * (pow26 * as_nat5 r % prime) % prime) % prime;
(==) { lemma_fmul5_pow26 r }
(tmp + v f11 * (as_nat5 (r4 *! u64 5, r0, r1, r2, r3) % prime) % prime) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (v f11) (as_nat5 (r4 *! u64 5, r0, r1, r2, r3)) prime }
(tmp + v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) % prime) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp (v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3)) prime }
(tmp + v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3)) % prime;
};
assert ((as_nat5 f1 * as_nat5 r) % prime == (tmp + v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3)) % prime)
val mul_felem5_lemma_2:
f1:tup64_5{tup64_fits5 f1 (3, 3, 3, 3, 3)}
-> r:tup64_5{tup64_fits5 r (2, 2, 2, 2, 2)} ->
Lemma
(let (f10, f11, f12, f13, f14) = f1 in
let (r0, r1, r2, r3, r4) = r in
(as_nat5 f1 * as_nat5 r) % prime ==
(v f10 * as_nat5 r +
v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) +
v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) +
v f13 * pow78 * as_nat5 r + v f14 * pow104 * as_nat5 r) % prime) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Poly1305.Vec.fst.checked",
"Hacl.Spec.Poly1305.Field32xN.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Poly1305.Field32xN.Lemmas0.fst"
} | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Poly1305.Field32xN",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Poly1305.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Poly1305.Field32xN",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Poly1305.Field32xN",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
f1:
Hacl.Spec.Poly1305.Field32xN.tup64_5
{Hacl.Spec.Poly1305.Field32xN.tup64_fits5 f1 (3, 3, 3, 3, 3)} ->
r:
Hacl.Spec.Poly1305.Field32xN.tup64_5
{Hacl.Spec.Poly1305.Field32xN.tup64_fits5 r (2, 2, 2, 2, 2)}
-> FStar.Pervasives.Lemma
(ensures
(let _ = f1 in
(let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ f10 f11 f12 f13 f14 = _ in
let _ = r in
(let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ r0 r1 r2 r3 r4 = _ in
Hacl.Spec.Poly1305.Field32xN.as_nat5 f1 * Hacl.Spec.Poly1305.Field32xN.as_nat5 r %
Hacl.Spec.Poly1305.Vec.prime ==
(Lib.IntTypes.v f10 * Hacl.Spec.Poly1305.Field32xN.as_nat5 r +
Lib.IntTypes.v f11 *
Hacl.Spec.Poly1305.Field32xN.as_nat5 (r4 *! Lib.IntTypes.u64 5, r0, r1, r2, r3) +
Lib.IntTypes.v f12 *
Hacl.Spec.Poly1305.Field32xN.as_nat5 (r3 *! Lib.IntTypes.u64 5,
r4 *! Lib.IntTypes.u64 5,
r0,
r1,
r2) +
(Lib.IntTypes.v f13 * Hacl.Spec.Poly1305.Field32xN.pow78) *
Hacl.Spec.Poly1305.Field32xN.as_nat5 r +
(Lib.IntTypes.v f14 * Hacl.Spec.Poly1305.Field32xN.pow104) *
Hacl.Spec.Poly1305.Field32xN.as_nat5 r) %
Hacl.Spec.Poly1305.Vec.prime)
<:
Type0)
<:
Type0)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Hacl.Spec.Poly1305.Field32xN.tup64_5",
"Hacl.Spec.Poly1305.Field32xN.tup64_fits5",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Lib.IntTypes.uint64",
"Prims._assert",
"Prims.eq2",
"Prims.int",
"Prims.op_Modulus",
"FStar.Mul.op_Star",
"Hacl.Spec.Poly1305.Field32xN.as_nat5",
"Hacl.Spec.Poly1305.Vec.prime",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.u64",
"Prims.unit",
"FStar.Calc.calc_finish",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"FStar.Calc.calc_step",
"Hacl.Spec.Poly1305.Field32xN.pow52",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Hacl.Poly1305.Field32xN.Lemmas0.mul_felem5_lemma_1",
"Prims.squash",
"FStar.Math.Lemmas.lemma_mod_plus_distr_r",
"FStar.Math.Lemmas.lemma_mod_mul_distr_r",
"FStar.Math.Lemmas.paren_mul_right",
"Hacl.Poly1305.Field32xN.Lemmas0.lemma_fmul5_pow52",
"Hacl.Spec.Poly1305.Field32xN.pow78",
"Hacl.Spec.Poly1305.Field32xN.pow104"
] | [] | false | false | true | false | false | let mul_felem5_lemma_2 f1 r =
| let f10, f11, f12, f13, f14 = f1 in
let r0, r1, r2, r3, r4 = r in
let tmp =
v f10 * as_nat5 r + v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) + (v f13 * pow78) * as_nat5 r +
(v f14 * pow104) * as_nat5 r
in
calc ( == ) {
(as_nat5 f1 * as_nat5 r) % prime;
( == ) { mul_felem5_lemma_1 f1 r }
(tmp + (v f12 * pow52) * as_nat5 r) % prime;
( == ) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp ((v f12 * pow52) * as_nat5 r) prime }
(tmp + ((v f12 * pow52) * as_nat5 r) % prime) % prime;
( == ) { (FStar.Math.Lemmas.paren_mul_right (v f12) pow52 (as_nat5 r);
FStar.Math.Lemmas.lemma_mod_mul_distr_r (v f12) (pow52 * as_nat5 r) prime) }
(tmp + v f12 * (pow52 * as_nat5 r % prime) % prime) % prime;
( == ) { lemma_fmul5_pow52 r }
(tmp + v f12 * (as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) % prime) % prime) % prime;
( == ) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (v f12)
(as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2))
prime }
(tmp + v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) % prime) % prime;
( == ) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp
(v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2))
prime }
(tmp + v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2)) % prime;
};
assert ((as_nat5 f1 * as_nat5 r) % prime ==
(tmp + v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2)) % prime) | false |
Vale.Wrapper.X64.GCTR.fsti | Vale.Wrapper.X64.GCTR.gctr_bytes_st | val gctr_bytes_st : a:
Vale.AES.AES_common_s.algorithm
{a = Vale.AES.AES_common_s.AES_128 \/ a = Vale.AES.AES_common_s.AES_256}
-> Type0 | let gctr_bytes_st (a: algorithm { a = AES_128 \/ a = AES_256 }) =
key:Ghost.erased (Seq.seq nat32) ->
in_b:uint8_p ->
num_bytes:uint64 ->
out_b:uint8_p ->
keys_b:uint8_p ->
ctr_b:uint8_p ->
Stack unit
(requires fun h0 ->
B.disjoint in_b out_b /\
B.disjoint keys_b out_b /\
B.disjoint in_b keys_b /\
B.disjoint ctr_b in_b /\
B.disjoint ctr_b out_b /\
B.disjoint ctr_b keys_b /\
B.live h0 keys_b /\ B.live h0 in_b /\
B.live h0 out_b /\ B.live h0 ctr_b /\
B.length in_b = UInt64.v num_bytes /\
B.length out_b = B.length in_b /\
B.length ctr_b = 16 /\
B.length keys_b = Vale.Wrapper.X64.AES.key_offset a /\
4096 * (UInt64.v num_bytes) < pow2_32 /\
aesni_enabled /\ avx_enabled /\ sse_enabled /\
is_aes_key_LE a (Ghost.reveal key) /\
(Seq.equal (B.as_seq h0 keys_b)
(seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (key_to_round_keys_LE a (Ghost.reveal key)))))
)
(ensures fun h0 r h1 ->
B.modifies (B.loc_buffer out_b) h0 h1 /\
(let ctr = seq_uint8_to_seq_nat8 (B.as_seq h0 ctr_b) in
let plain = seq_uint8_to_seq_nat8 (B.as_seq h0 in_b) in
let cipher = seq_uint8_to_seq_nat8 (B.as_seq h1 out_b) in
Seq.equal
(gctr_encrypt_LE (le_bytes_to_quad32 ctr) (make_gctr_plain_LE plain) a (Ghost.reveal key))
cipher
)
) | {
"file_name": "vale/code/arch/x64/interop/Vale.Wrapper.X64.GCTR.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 4,
"end_line": 64,
"start_col": 0,
"start_line": 23
} | module Vale.Wrapper.X64.GCTR
open Vale.X64.CPU_Features_s
open FStar.HyperStack.ST
module B = LowStar.Buffer
module HS = FStar.HyperStack
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.AES.AES_s
open Vale.AES.GCTR
open Vale.AES.GCTR_s
open Vale.Interop.Base
open Vale.Def.Types_s
unfold
let uint8_p = B.buffer UInt8.t
let uint64 = UInt64.t | {
"checked_file": "/",
"dependencies": [
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Wrapper.X64.AES.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AES.GCTR_s.fst.checked",
"Vale.AES.GCTR.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.Seq.fst.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": "Vale.Wrapper.X64.GCTR.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a:
Vale.AES.AES_common_s.algorithm
{a = Vale.AES.AES_common_s.AES_128 \/ a = Vale.AES.AES_common_s.AES_256}
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.AES.AES_common_s.algorithm",
"Prims.l_or",
"Prims.b2t",
"Prims.op_Equality",
"Vale.AES.AES_common_s.AES_128",
"Vale.AES.AES_common_s.AES_256",
"FStar.Ghost.erased",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat32",
"Vale.Wrapper.X64.GCTR.uint8_p",
"Vale.Wrapper.X64.GCTR.uint64",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"LowStar.Monotonic.Buffer.disjoint",
"FStar.UInt8.t",
"LowStar.Buffer.trivial_preorder",
"LowStar.Monotonic.Buffer.live",
"Prims.int",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt.size",
"FStar.UInt64.n",
"LowStar.Monotonic.Buffer.length",
"FStar.UInt64.v",
"Prims.nat",
"Vale.Wrapper.X64.AES.key_offset",
"Prims.op_LessThan",
"FStar.Mul.op_Star",
"Vale.Def.Words_s.pow2_32",
"Vale.X64.CPU_Features_s.aesni_enabled",
"Vale.X64.CPU_Features_s.avx_enabled",
"Vale.X64.CPU_Features_s.sse_enabled",
"Vale.AES.AES_s.is_aes_key_LE",
"FStar.Ghost.reveal",
"FStar.Seq.Base.equal",
"LowStar.Monotonic.Buffer.as_seq",
"Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8",
"Vale.Def.Types_s.le_seq_quad32_to_bytes",
"Vale.AES.AES_s.key_to_round_keys_LE",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_buffer",
"Vale.Def.Types_s.nat8",
"Vale.AES.GCTR_s.gctr_encrypt_LE",
"Vale.Def.Types_s.le_bytes_to_quad32",
"Vale.AES.GCTR.make_gctr_plain_LE",
"Vale.Def.Words_s.nat8",
"Vale.Def.Words.Seq_s.seq_uint8_to_seq_nat8"
] | [] | false | false | false | false | true | let gctr_bytes_st (a: algorithm{a = AES_128 \/ a = AES_256}) =
|
key: Ghost.erased (Seq.seq nat32) ->
in_b: uint8_p ->
num_bytes: uint64 ->
out_b: uint8_p ->
keys_b: uint8_p ->
ctr_b: uint8_p
-> Stack unit
(requires
fun h0 ->
B.disjoint in_b out_b /\ B.disjoint keys_b out_b /\ B.disjoint in_b keys_b /\
B.disjoint ctr_b in_b /\ B.disjoint ctr_b out_b /\ B.disjoint ctr_b keys_b /\
B.live h0 keys_b /\ B.live h0 in_b /\ B.live h0 out_b /\ B.live h0 ctr_b /\
B.length in_b = UInt64.v num_bytes /\ B.length out_b = B.length in_b /\
B.length ctr_b = 16 /\ B.length keys_b = Vale.Wrapper.X64.AES.key_offset a /\
4096 * (UInt64.v num_bytes) < pow2_32 /\ aesni_enabled /\ avx_enabled /\ sse_enabled /\
is_aes_key_LE a (Ghost.reveal key) /\
(Seq.equal (B.as_seq h0 keys_b)
(seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (key_to_round_keys_LE a
(Ghost.reveal key))))))
(ensures
fun h0 r h1 ->
B.modifies (B.loc_buffer out_b) h0 h1 /\
(let ctr = seq_uint8_to_seq_nat8 (B.as_seq h0 ctr_b) in
let plain = seq_uint8_to_seq_nat8 (B.as_seq h0 in_b) in
let cipher = seq_uint8_to_seq_nat8 (B.as_seq h1 out_b) in
Seq.equal (gctr_encrypt_LE (le_bytes_to_quad32 ctr)
(make_gctr_plain_LE plain)
a
(Ghost.reveal key))
cipher)) | false |
|
Hacl.Poly1305.Field32xN.Lemmas0.fst | Hacl.Poly1305.Field32xN.Lemmas0.mul_felem5_lemma_1 | val mul_felem5_lemma_1:
f1:tup64_5{tup64_fits5 f1 (3, 3, 3, 3, 3)}
-> r:tup64_5{tup64_fits5 r (2, 2, 2, 2, 2)} ->
Lemma
(let (f10, f11, f12, f13, f14) = f1 in
let (r0, r1, r2, r3, r4) = r in
(as_nat5 f1 * as_nat5 r) % prime ==
(v f10 * as_nat5 r +
v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) +
v f12 * pow52 * as_nat5 r + v f13 * pow78 * as_nat5 r + v f14 * pow104 * as_nat5 r) % prime) | val mul_felem5_lemma_1:
f1:tup64_5{tup64_fits5 f1 (3, 3, 3, 3, 3)}
-> r:tup64_5{tup64_fits5 r (2, 2, 2, 2, 2)} ->
Lemma
(let (f10, f11, f12, f13, f14) = f1 in
let (r0, r1, r2, r3, r4) = r in
(as_nat5 f1 * as_nat5 r) % prime ==
(v f10 * as_nat5 r +
v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) +
v f12 * pow52 * as_nat5 r + v f13 * pow78 * as_nat5 r + v f14 * pow104 * as_nat5 r) % prime) | let mul_felem5_lemma_1 f1 r =
let (f10, f11, f12, f13, f14) = f1 in
let (r0, r1, r2, r3, r4) = r in
let tmp = v f10 * as_nat5 r + v f12 * pow52 * as_nat5 r + v f13 * pow78 * as_nat5 r + v f14 * pow104 * as_nat5 r in
calc (==) {
(as_nat5 f1 * as_nat5 r) % prime;
(==) { }
(v f10 + v f11 * pow26 + v f12 * pow52 + v f13 * pow78 + v f14 * pow104) * as_nat5 r % prime;
(==) { lemma_mul5_distr_r (v f10) (v f11 * pow26) (v f12 * pow52) (v f13 * pow78) (v f14 * pow104) (as_nat5 r) }
(v f10 * as_nat5 r + v f11 * pow26 * as_nat5 r + v f12 * pow52 * as_nat5 r + v f13 * pow78 * as_nat5 r + v f14 * pow104 * as_nat5 r) % prime;
(==) {
FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp (v f11 * pow26 * as_nat5 r) prime }
(tmp + (v f11 * pow26 * as_nat5 r) % prime) % prime;
(==) {
FStar.Math.Lemmas.paren_mul_right (v f11) pow26 (as_nat5 r);
FStar.Math.Lemmas.lemma_mod_mul_distr_r (v f11) (pow26 * as_nat5 r) prime }
(tmp + v f11 * (pow26 * as_nat5 r % prime) % prime) % prime;
(==) { lemma_fmul5_pow26 r }
(tmp + v f11 * (as_nat5 (r4 *! u64 5, r0, r1, r2, r3) % prime) % prime) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (v f11) (as_nat5 (r4 *! u64 5, r0, r1, r2, r3)) prime }
(tmp + v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) % prime) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp (v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3)) prime }
(tmp + v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3)) % prime;
};
assert ((as_nat5 f1 * as_nat5 r) % prime == (tmp + v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3)) % prime) | {
"file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas0.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 108,
"end_line": 513,
"start_col": 0,
"start_line": 488
} | module Hacl.Poly1305.Field32xN.Lemmas0
open Lib.IntTypes
open Lib.IntVector
open Lib.Sequence
open FStar.Mul
open FStar.Calc
open Hacl.Spec.Poly1305.Vec
include Hacl.Spec.Poly1305.Field32xN
#reset-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0"
val lemma_prime: unit -> Lemma (pow2 130 % prime = 5)
let lemma_prime () =
assert_norm (pow2 130 % prime = 5 % prime);
assert_norm (5 < prime);
FStar.Math.Lemmas.modulo_lemma 5 prime
val lemma_mult_le: a:nat -> b:nat -> c:nat -> d:nat -> Lemma
(requires a <= b /\ c <= d)
(ensures a * c <= b * d)
let lemma_mult_le a b c d = ()
val lemma_mul5_distr_l: a:nat -> b:nat -> c:nat -> d:nat -> e:nat -> f:nat -> Lemma
(a * (b + c + d + e + f) == a * b + a * c + a * d + a * e + a * f)
let lemma_mul5_distr_l a b c d e f = ()
val lemma_mul5_distr_r: a:nat -> b:nat -> c:nat -> d:nat -> e:nat -> f:nat -> Lemma
((a + b + c + d + e) * f == a * f + b * f + c * f + d * f + e * f)
let lemma_mul5_distr_r a b c d e f = ()
val smul_mod_lemma:
#m1:scale32
-> #m2:scale32
-> a:nat{a <= m1 * max26}
-> b:nat{b <= m2 * max26} ->
Lemma (a * b % pow2 64 == a * b)
let smul_mod_lemma #m1 #m2 a b =
lemma_mult_le a (m1 * max26) b (m2 * max26);
assert (a * b <= m1 * m2 * max26 * max26);
FStar.Math.Lemmas.modulo_lemma (a * b) (pow2 64)
val smul_add_mod_lemma:
#m1:scale32
-> #m2:scale32
-> #m3:scale64{m3 + m1 * m2 <= 4096}
-> a:nat{a <= m1 * max26}
-> b:nat{b <= m2 * max26}
-> c:nat{c <= m3 * max26 * max26} ->
Lemma ((c + a * b % pow2 64) % pow2 64 == c + a * b)
let smul_add_mod_lemma #m1 #m2 #m3 a b c =
assert_norm ((m3 + m1 * m2) * max26 * max26 < pow2 64);
lemma_mult_le a (m1 * max26) b (m2 * max26);
assert (c + a * b <= m3 * max26 * max26 + m1 * m2 * max26 * max26);
FStar.Math.Lemmas.modulo_lemma (c + a * b) (pow2 64)
val add5_lemma1: ma:scale64 -> mb:scale64 -> a:uint64 -> b:uint64 -> Lemma
(requires v a <= ma * max26 /\ v b <= mb * max26 /\ ma + mb <= 64)
(ensures v (a +. b) == v a + v b /\ v (a +. b) <= (ma + mb) * max26)
let add5_lemma1 ma mb a b =
assert (v a + v b <= (ma + mb) * max26);
Math.Lemmas.lemma_mult_le_right max26 (ma + mb) 64;
assert (v a + v b <= 64 * max26);
assert_norm (64 * max26 < pow2 32);
Math.Lemmas.small_mod (v a + v b) (pow2 32)
#set-options "--ifuel 1"
val fadd5_eval_lemma_i:
#w:lanes
-> f1:felem5 w{felem_fits5 f1 (2,2,2,2,2)}
-> f2:felem5 w{felem_fits5 f2 (1,1,1,1,1)}
-> i:nat{i < w} ->
Lemma ((feval5 (fadd5 f1 f2)).[i] == pfadd (feval5 f1).[i] (feval5 f2).[i])
let fadd5_eval_lemma_i #w f1 f2 i =
let o = fadd5 f1 f2 in
let (f10, f11, f12, f13, f14) = as_tup64_i f1 i in
let (f20, f21, f22, f23, f24) = as_tup64_i f2 i in
let (o0, o1, o2, o3, o4) = as_tup64_i o i in
add5_lemma1 2 1 f10 f20;
add5_lemma1 2 1 f11 f21;
add5_lemma1 2 1 f12 f22;
add5_lemma1 2 1 f13 f23;
add5_lemma1 2 1 f14 f24;
assert (as_nat5 (o0, o1, o2, o3, o4) ==
as_nat5 (f10, f11, f12, f13, f14) + as_nat5 (f20, f21, f22, f23, f24));
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (f10, f11, f12, f13, f14)) (as_nat5 (f20, f21, f22, f23, f24)) prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
(as_nat5 (f10, f11, f12, f13, f14) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime
val smul_felem5_fits_lemma_i:
#w:lanes
-> #m1:scale32
-> #m2:scale32
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:uint64xN w{felem_fits1 f2 m2}
-> i:nat{i < w} ->
Lemma ((uint64xN_v (vec_mul_mod f2 u1)).[i] <= m1 * m2 * max26 * max26)
let smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 i =
let o = vec_mul_mod f2 u1 in
smul_mod_lemma #m1 #m2 (uint64xN_v u1).[i] (uint64xN_v f2).[i];
assert ((uint64xN_v o).[i] == (uint64xN_v u1).[i] * (uint64xN_v f2).[i]);
lemma_mult_le (uint64xN_v u1).[i] (m1 * max26) (uint64xN_v f2).[i] (m2 * max26)
val smul_felem5_eval_lemma_i:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2}
-> i:nat{i < w} ->
Lemma ((fas_nat5 (smul_felem5 #w u1 f2)).[i] == (uint64xN_v u1).[i] * (fas_nat5 f2).[i])
let smul_felem5_eval_lemma_i #w #m1 #m2 u1 f2 i =
let o = smul_felem5 #w u1 f2 in
let (m20, m21, m22, m23, m24) = m2 in
let vu1 = (uint64xN_v u1).[i] in
let (tf20, tf21, tf22, tf23, tf24) = as_tup64_i f2 i in
let (to0, to1, to2, to3, to4) = as_tup64_i o i in
smul_mod_lemma #m1 #m20 vu1 (v tf20);
smul_mod_lemma #m1 #m21 vu1 (v tf21);
smul_mod_lemma #m1 #m22 vu1 (v tf22);
smul_mod_lemma #m1 #m23 vu1 (v tf23);
smul_mod_lemma #m1 #m24 vu1 (v tf24);
assert ((fas_nat5 o).[i] == vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 +
vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104);
calc (==) {
vu1 * (fas_nat5 f2).[i];
(==) { }
vu1 * (v tf20 + v tf21 * pow26 + v tf22 * pow52 + v tf23 * pow78 + v tf24 * pow104);
(==) { lemma_mul5_distr_l vu1 (v tf20) (v tf21 * pow26) (v tf22 * pow52) (v tf23 * pow78) (v tf24 * pow104)}
vu1 * v tf20 + vu1 * (v tf21 * pow26) + vu1 * (v tf22 * pow52) + vu1 * (v tf23 * pow78) + vu1 * (v tf24 * pow104);
(==) {
FStar.Math.Lemmas.paren_mul_right vu1 (v tf21) pow26;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf22) pow52;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf23) pow78;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf24) pow104}
vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 + vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104;
};
assert (vu1 * (fas_nat5 f2).[i] == (fas_nat5 o).[i])
val smul_felem5_fits_lemma1:
#w:lanes
-> #m1:scale32
-> #m2:scale32
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:uint64xN w{felem_fits1 f2 m2} ->
Lemma (felem_wide_fits1 (vec_mul_mod f2 u1) (m1 * m2))
let smul_felem5_fits_lemma1 #w #m1 #m2 u1 f2 =
match w with
| 1 ->
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 0
| 2 ->
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 0;
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 1
| 4 ->
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 0;
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 1;
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 2;
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 3
val smul_felem5_fits_lemma:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2} ->
Lemma (felem_wide_fits5 (smul_felem5 #w u1 f2) (m1 *^ m2))
let smul_felem5_fits_lemma #w #m1 #m2 u1 f2 =
let (f20, f21, f22, f23, f24) = f2 in
let (m20, m21, m22, m23, m24) = m2 in
smul_felem5_fits_lemma1 #w #m1 #m20 u1 f20;
smul_felem5_fits_lemma1 #w #m1 #m21 u1 f21;
smul_felem5_fits_lemma1 #w #m1 #m22 u1 f22;
smul_felem5_fits_lemma1 #w #m1 #m23 u1 f23;
smul_felem5_fits_lemma1 #w #m1 #m24 u1 f24
val smul_felem5_eval_lemma:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2} ->
Lemma (fas_nat5 (smul_felem5 #w u1 f2) ==
map2 #nat #nat #nat (fun a b -> a * b) (uint64xN_v u1) (fas_nat5 f2))
let smul_felem5_eval_lemma #w #m1 #m2 u1 f2 =
FStar.Classical.forall_intro (smul_felem5_eval_lemma_i #w #m1 #m2 u1 f2);
eq_intro (fas_nat5 (smul_felem5 #w u1 f2))
(map2 #nat #nat #nat (fun a b -> a * b) (uint64xN_v u1) (fas_nat5 f2))
val smul_add_felem5_fits_lemma_i:
#w:lanes
-> #m1:scale32
-> #m2:scale32
-> #m3:scale64{m3 + m1 * m2 <= 4096}
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:uint64xN w{felem_fits1 f2 m2}
-> acc1:uint64xN w{felem_wide_fits1 acc1 m3}
-> i:nat{i < w} ->
Lemma ((uint64xN_v (vec_add_mod acc1 (vec_mul_mod f2 u1))).[i] <= (m3 + m1 * m2) * max26 * max26)
#push-options "--z3rlimit 200"
let smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 i =
let o = vec_add_mod acc1 (vec_mul_mod f2 u1) in
smul_add_mod_lemma #m1 #m2 #m3 (uint64xN_v u1).[i] (uint64xN_v f2).[i] (uint64xN_v acc1).[i];
assert ((uint64xN_v o).[i] == (uint64xN_v acc1).[i] + (uint64xN_v u1).[i] * (uint64xN_v f2).[i]);
lemma_mult_le (uint64xN_v u1).[i] (m1 * max26) (uint64xN_v f2).[i] (m2 * max26);
assert ((uint64xN_v o).[i] <= m3 * max26 * max26 + m1 * m2 * max26 * max26)
#pop-options
val smul_add_felem5_eval_lemma_i:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> #m3:scale64_5{m3 +* m1 *^ m2 <=* s64x5 4096}
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2}
-> acc1:felem_wide5 w{felem_wide_fits5 acc1 m3}
-> i:nat{i < w} ->
Lemma ((fas_nat5 (smul_add_felem5 #w u1 f2 acc1)).[i] ==
(fas_nat5 acc1).[i] + (uint64xN_v u1).[i] * (fas_nat5 f2).[i])
let smul_add_felem5_eval_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 i =
let o = smul_add_felem5 #w u1 f2 acc1 in
let (m20, m21, m22, m23, m24) = m2 in
let (m30, m31, m32, m33, m34) = m3 in
let vu1 = (uint64xN_v u1).[i] in
let (tf20, tf21, tf22, tf23, tf24) = as_tup64_i f2 i in
let (ta0, ta1, ta2, ta3, ta4) = as_tup64_i acc1 i in
let (to0, to1, to2, to3, to4) = as_tup64_i o i in
smul_add_mod_lemma #m1 #m20 #m30 vu1 (v tf20) (v ta0);
smul_add_mod_lemma #m1 #m21 #m31 vu1 (v tf21) (v ta1);
smul_add_mod_lemma #m1 #m22 #m32 vu1 (v tf22) (v ta2);
smul_add_mod_lemma #m1 #m23 #m33 vu1 (v tf23) (v ta3);
smul_add_mod_lemma #m1 #m24 #m34 vu1 (v tf24) (v ta4);
calc (==) {
(fas_nat5 o).[i];
(==) { }
v ta0 + vu1 * v tf20 + (v ta1 + vu1 * v tf21) * pow26 + (v ta2 + vu1 * v tf22) * pow52 +
(v ta3 + vu1 * v tf23) * pow78 + (v ta4 + vu1 * v tf24) * pow104;
(==) {
FStar.Math.Lemmas.distributivity_add_left (v ta1) (vu1 * v tf21) pow26;
FStar.Math.Lemmas.distributivity_add_left (v ta2) (vu1 * v tf22) pow52;
FStar.Math.Lemmas.distributivity_add_left (v ta3) (vu1 * v tf23) pow78;
FStar.Math.Lemmas.distributivity_add_left (v ta1) (vu1 * v tf24) pow104 }
v ta0 + v ta1 * pow26 + v ta2 * pow52 + v ta3 * pow78 + v ta4 * pow104 +
vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 + vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104;
(==) { }
(fas_nat5 acc1).[i] + vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 + vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104;
};
assert ((fas_nat5 o).[i] == (fas_nat5 acc1).[i] +
vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 + vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104);
calc (==) {
vu1 * (fas_nat5 f2).[i];
(==) { }
vu1 * (v tf20 + v tf21 * pow26 + v tf22 * pow52 + v tf23 * pow78 + v tf24 * pow104);
(==) { lemma_mul5_distr_l vu1 (v tf20) (v tf21 * pow26) (v tf22 * pow52) (v tf23 * pow78) (v tf24 * pow104)}
vu1 * v tf20 + vu1 * (v tf21 * pow26) + vu1 * (v tf22 * pow52) + vu1 * (v tf23 * pow78) + vu1 * (v tf24 * pow104);
(==) {
FStar.Math.Lemmas.paren_mul_right vu1 (v tf21) pow26;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf22) pow52;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf23) pow78;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf24) pow104}
vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 + vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104;
};
assert ((fas_nat5 o).[i] == (fas_nat5 acc1).[i] + vu1 * (fas_nat5 f2).[i])
val smul_add_felem5_fits_lemma1:
#w:lanes
-> #m1:scale32
-> #m2:scale32
-> #m3:scale64{m3 + m1 * m2 <= 4096}
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:uint64xN w{felem_fits1 f2 m2}
-> acc1:uint64xN w{felem_wide_fits1 acc1 m3} ->
Lemma (felem_wide_fits1 (vec_add_mod acc1 (vec_mul_mod f2 u1)) (m3 + m1 * m2))
let smul_add_felem5_fits_lemma1 #w #m1 #m2 #m3 u1 f2 acc1 =
match w with
| 1 ->
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 0
| 2 ->
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 0;
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 1
| 4 ->
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 0;
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 1;
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 2;
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 3
val smul_add_felem5_fits_lemma:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> #m3:scale64_5{m3 +* m1 *^ m2 <=* s64x5 4096}
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2}
-> acc1:felem_wide5 w{felem_wide_fits5 acc1 m3} ->
Lemma (felem_wide_fits5 (smul_add_felem5 #w u1 f2 acc1) (m3 +* m1 *^ m2))
let smul_add_felem5_fits_lemma #w #m1 #m2 #m3 u1 f2 acc1 =
let (f20, f21, f22, f23, f24) = f2 in
let (m20, m21, m22, m23, m24) = m2 in
let (a0, a1, a2, a3, a4) = acc1 in
let (m30, m31, m32, m33, m34) = m3 in
smul_add_felem5_fits_lemma1 #w #m1 #m20 #m30 u1 f20 a0;
smul_add_felem5_fits_lemma1 #w #m1 #m21 #m31 u1 f21 a1;
smul_add_felem5_fits_lemma1 #w #m1 #m22 #m32 u1 f22 a2;
smul_add_felem5_fits_lemma1 #w #m1 #m23 #m33 u1 f23 a3;
smul_add_felem5_fits_lemma1 #w #m1 #m24 #m34 u1 f24 a4
val smul_add_felem5_eval_lemma:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> #m3:scale64_5{m3 +* m1 *^ m2 <=* s64x5 4096}
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2}
-> acc1:felem_wide5 w{felem_wide_fits5 acc1 m3} ->
Lemma (fas_nat5 (smul_add_felem5 #w u1 f2 acc1) ==
map2 #nat #nat #nat (fun a b -> a + b) (fas_nat5 acc1)
(map2 #nat #nat #nat (fun a b -> a * b) (uint64xN_v u1) (fas_nat5 f2)))
let smul_add_felem5_eval_lemma #w #m1 #m2 #m3 u1 f2 acc1 =
let tmp =
map2 #nat #nat #nat (fun a b -> a + b) (fas_nat5 acc1)
(map2 #nat #nat #nat (fun a b -> a * b) (uint64xN_v u1) (fas_nat5 f2)) in
FStar.Classical.forall_intro (smul_add_felem5_eval_lemma_i #w #m1 #m2 #m3 u1 f2 acc1);
eq_intro (fas_nat5 (smul_add_felem5 #w u1 f2 acc1)) tmp
val lemma_fmul5_pow26: r:tup64_5 -> Lemma
(requires (let (r0, r1, r2, r3, r4) = r in v r4 * 5 <= 10 * pow26))
(ensures (let (r0, r1, r2, r3, r4) = r in
(pow26 * as_nat5 r) % prime == as_nat5 (r4 *! u64 5, r0, r1, r2, r3) % prime))
let lemma_fmul5_pow26 r =
let (r0, r1, r2, r3, r4) = r in
calc (==) {
(pow26 * as_nat5 r) % prime;
(==) { }
(pow26 * (v r0 + v r1 * pow26 + v r2 * pow52 + v r3 * pow78 + v r4 * pow104)) % prime;
(==) { lemma_mul5_distr_l pow26 (v r0) (v r1 * pow26) (v r2 * pow52) (v r3 * pow78) (v r4 * pow104) }
(v r0 * pow26 + pow26 * v r1 * pow26 + pow26 * v r2 * pow52 + pow26 * v r3 * pow78 + pow26 * v r4 * pow104) % prime;
(==) { }
(v r0 * pow26 + v r1 * pow26 * pow26 + v r2 * pow26 * pow52 + v r3 * pow26 * pow78 + v r4 * pow26 * pow104) % prime;
(==) {
assert_norm (pow26 * pow26 = pow52);
assert_norm (pow26 * pow52 = pow78);
assert_norm (pow26 * pow78 = pow104);
assert_norm (pow26 * pow104 = pow2 130) }
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + v r4 * pow2 130) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104) (v r4 * pow2 130) prime }
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + (v r4 * pow2 130) % prime) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (v r4) (pow2 130) prime }
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + (v r4 * (pow2 130 % prime)) % prime) % prime;
(==) { lemma_prime () }
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + (v r4 * 5) % prime) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104) (v r4 * 5) prime }
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + v r4 * 5) % prime;
};
assert ((pow26 * as_nat5 r) % prime ==
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + v r4 * 5) % prime)
val lemma_fmul5_pow52: r:tup64_5 -> Lemma
(requires (let (r0, r1, r2, r3, r4) = r in
v r4 * 5 <= 10 * pow26 /\ v r3 * 5 <= 10 * pow26))
(ensures (let (r0, r1, r2, r3, r4) = r in
(pow52 * as_nat5 r) % prime == as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) % prime))
let lemma_fmul5_pow52 r =
let (r0, r1, r2, r3, r4) = r in
calc (==) {
(pow52 * as_nat5 r) % prime;
(==) { assert_norm (pow52 == pow26 * pow26) }
(pow26 * pow26 * as_nat5 r) % prime;
(==) {
FStar.Math.Lemmas.paren_mul_right pow26 pow26 (as_nat5 r);
FStar.Math.Lemmas.lemma_mod_mul_distr_r pow26 (pow26 * as_nat5 r) prime }
(pow26 * (pow26 * as_nat5 r % prime)) % prime;
(==) { lemma_fmul5_pow26 r }
(pow26 * (as_nat5 (r4 *! u64 5, r0, r1, r2, r3) % prime)) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r pow26 (as_nat5 (r4 *! u64 5, r0, r1, r2, r3)) prime }
(pow26 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3)) % prime;
(==) { lemma_fmul5_pow26 (r4 *! u64 5, r0, r1, r2, r3) }
as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) % prime;
};
assert ((pow52 * as_nat5 r) % prime == as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) % prime)
val lemma_fmul5_pow78: r:tup64_5 -> Lemma
(requires (let (r0, r1, r2, r3, r4) = r in
v r4 * 5 <= 10 * pow26 /\ v r3 * 5 <= 10 * pow26 /\ v r2 * 5 <= 10 * pow26))
(ensures (let (r0, r1, r2, r3, r4) = r in
(pow78 * as_nat5 r) % prime == as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) % prime))
let lemma_fmul5_pow78 r =
let (r0, r1, r2, r3, r4) = r in
calc (==) {
(pow78 * as_nat5 r) % prime;
(==) { assert_norm (pow78 == pow26 * pow52) }
(pow26 * pow52 * as_nat5 r) % prime;
(==) {
FStar.Math.Lemmas.paren_mul_right pow26 pow52 (as_nat5 r);
FStar.Math.Lemmas.lemma_mod_mul_distr_r pow26 (pow52 * as_nat5 r) prime }
(pow26 * (pow52 * as_nat5 r % prime)) % prime;
(==) { lemma_fmul5_pow52 r }
(pow26 * (as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) % prime)) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r pow26 (as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2)) prime }
(pow26 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2)) % prime;
(==) { lemma_fmul5_pow26 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) }
as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) % prime;
};
assert ((pow78 * as_nat5 r) % prime == as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) % prime)
val lemma_fmul5_pow104: r:tup64_5 -> Lemma
(requires (let (r0, r1, r2, r3, r4) = r in
v r4 * 5 <= 10 * pow26 /\ v r3 * 5 <= 10 * pow26 /\
v r2 * 5 <= 10 * pow26 /\ v r1 * 5 <= 10 * pow26))
(ensures (let (r0, r1, r2, r3, r4) = r in
(pow104 * as_nat5 r) % prime == as_nat5 (r1 *! u64 5, r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0) % prime))
let lemma_fmul5_pow104 r =
let (r0, r1, r2, r3, r4) = r in
calc (==) {
(pow104 * as_nat5 r) % prime;
(==) { assert_norm (pow104 == pow26 * pow78) }
(pow26 * pow78 * as_nat5 r) % prime;
(==) {
FStar.Math.Lemmas.paren_mul_right pow26 pow78 (as_nat5 r);
FStar.Math.Lemmas.lemma_mod_mul_distr_r pow26 (pow78 * as_nat5 r) prime }
(pow26 * (pow78 * as_nat5 r % prime)) % prime;
(==) { lemma_fmul5_pow78 r }
(pow26 * (as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) % prime)) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r pow26 (as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1)) prime }
(pow26 * as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1)) % prime;
(==) { lemma_fmul5_pow26 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) }
as_nat5 (r1 *! u64 5, r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0) % prime;
};
assert ((pow104 * as_nat5 r) % prime == as_nat5 (r1 *! u64 5, r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0) % prime)
val mul_felem5_lemma_1:
f1:tup64_5{tup64_fits5 f1 (3, 3, 3, 3, 3)}
-> r:tup64_5{tup64_fits5 r (2, 2, 2, 2, 2)} ->
Lemma
(let (f10, f11, f12, f13, f14) = f1 in
let (r0, r1, r2, r3, r4) = r in
(as_nat5 f1 * as_nat5 r) % prime ==
(v f10 * as_nat5 r +
v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) +
v f12 * pow52 * as_nat5 r + v f13 * pow78 * as_nat5 r + v f14 * pow104 * as_nat5 r) % prime) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Poly1305.Vec.fst.checked",
"Hacl.Spec.Poly1305.Field32xN.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Poly1305.Field32xN.Lemmas0.fst"
} | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Poly1305.Field32xN",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Poly1305.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Poly1305.Field32xN",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Poly1305.Field32xN",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
f1:
Hacl.Spec.Poly1305.Field32xN.tup64_5
{Hacl.Spec.Poly1305.Field32xN.tup64_fits5 f1 (3, 3, 3, 3, 3)} ->
r:
Hacl.Spec.Poly1305.Field32xN.tup64_5
{Hacl.Spec.Poly1305.Field32xN.tup64_fits5 r (2, 2, 2, 2, 2)}
-> FStar.Pervasives.Lemma
(ensures
(let _ = f1 in
(let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ f10 f11 f12 f13 f14 = _ in
let _ = r in
(let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ r0 r1 r2 r3 r4 = _ in
Hacl.Spec.Poly1305.Field32xN.as_nat5 f1 * Hacl.Spec.Poly1305.Field32xN.as_nat5 r %
Hacl.Spec.Poly1305.Vec.prime ==
(Lib.IntTypes.v f10 * Hacl.Spec.Poly1305.Field32xN.as_nat5 r +
Lib.IntTypes.v f11 *
Hacl.Spec.Poly1305.Field32xN.as_nat5 (r4 *! Lib.IntTypes.u64 5, r0, r1, r2, r3) +
(Lib.IntTypes.v f12 * Hacl.Spec.Poly1305.Field32xN.pow52) *
Hacl.Spec.Poly1305.Field32xN.as_nat5 r +
(Lib.IntTypes.v f13 * Hacl.Spec.Poly1305.Field32xN.pow78) *
Hacl.Spec.Poly1305.Field32xN.as_nat5 r +
(Lib.IntTypes.v f14 * Hacl.Spec.Poly1305.Field32xN.pow104) *
Hacl.Spec.Poly1305.Field32xN.as_nat5 r) %
Hacl.Spec.Poly1305.Vec.prime)
<:
Type0)
<:
Type0)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Hacl.Spec.Poly1305.Field32xN.tup64_5",
"Hacl.Spec.Poly1305.Field32xN.tup64_fits5",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Lib.IntTypes.uint64",
"Prims._assert",
"Prims.eq2",
"Prims.int",
"Prims.op_Modulus",
"FStar.Mul.op_Star",
"Hacl.Spec.Poly1305.Field32xN.as_nat5",
"Hacl.Spec.Poly1305.Vec.prime",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.u64",
"Prims.unit",
"FStar.Calc.calc_finish",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"FStar.Calc.calc_step",
"Hacl.Spec.Poly1305.Field32xN.pow26",
"Hacl.Spec.Poly1305.Field32xN.pow52",
"Hacl.Spec.Poly1305.Field32xN.pow78",
"Hacl.Spec.Poly1305.Field32xN.pow104",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Prims.squash",
"Hacl.Poly1305.Field32xN.Lemmas0.lemma_mul5_distr_r",
"FStar.Math.Lemmas.lemma_mod_plus_distr_r",
"FStar.Math.Lemmas.lemma_mod_mul_distr_r",
"FStar.Math.Lemmas.paren_mul_right",
"Hacl.Poly1305.Field32xN.Lemmas0.lemma_fmul5_pow26"
] | [] | false | false | true | false | false | let mul_felem5_lemma_1 f1 r =
| let f10, f11, f12, f13, f14 = f1 in
let r0, r1, r2, r3, r4 = r in
let tmp =
v f10 * as_nat5 r + (v f12 * pow52) * as_nat5 r + (v f13 * pow78) * as_nat5 r +
(v f14 * pow104) * as_nat5 r
in
calc ( == ) {
(as_nat5 f1 * as_nat5 r) % prime;
( == ) { () }
(v f10 + v f11 * pow26 + v f12 * pow52 + v f13 * pow78 + v f14 * pow104) * as_nat5 r % prime;
( == ) { lemma_mul5_distr_r (v f10)
(v f11 * pow26)
(v f12 * pow52)
(v f13 * pow78)
(v f14 * pow104)
(as_nat5 r) }
(v f10 * as_nat5 r + (v f11 * pow26) * as_nat5 r + (v f12 * pow52) * as_nat5 r +
(v f13 * pow78) * as_nat5 r +
(v f14 * pow104) * as_nat5 r) %
prime;
( == ) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp ((v f11 * pow26) * as_nat5 r) prime }
(tmp + ((v f11 * pow26) * as_nat5 r) % prime) % prime;
( == ) { (FStar.Math.Lemmas.paren_mul_right (v f11) pow26 (as_nat5 r);
FStar.Math.Lemmas.lemma_mod_mul_distr_r (v f11) (pow26 * as_nat5 r) prime) }
(tmp + v f11 * (pow26 * as_nat5 r % prime) % prime) % prime;
( == ) { lemma_fmul5_pow26 r }
(tmp + v f11 * (as_nat5 (r4 *! u64 5, r0, r1, r2, r3) % prime) % prime) % prime;
( == ) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (v f11)
(as_nat5 (r4 *! u64 5, r0, r1, r2, r3))
prime }
(tmp + v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) % prime) % prime;
( == ) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp
(v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3))
prime }
(tmp + v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3)) % prime;
};
assert ((as_nat5 f1 * as_nat5 r) % prime ==
(tmp + v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3)) % prime) | false |
MerkleTree.fsti | MerkleTree.mt_free_path | val mt_free_path (path: path_p) : HST.ST unit pf pt | val mt_free_path (path: path_p) : HST.ST unit pf pt | let mt_free_path (path:path_p): HST.ST unit pf pt = MTNL.free_path path | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 71,
"end_line": 50,
"start_col": 0,
"start_line": 50
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r
[@ (Comment " Destructor for hashes") "c_inline"]
let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h
[@ (Comment " Constructor for paths") "c_inline"]
let mt_init_path (hash_size:hash_size_t) (mtr:HH.rid) (r:HST.erid): HST.ST path_p pf pt = MTNL.init_path hash_size mtr r | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | path: MerkleTree.path_p -> FStar.HyperStack.ST.ST Prims.unit | FStar.HyperStack.ST.ST | [] | [] | [
"MerkleTree.path_p",
"MerkleTree.Low.free_path",
"Prims.unit",
"MerkleTree.pf",
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.pt"
] | [] | false | true | false | false | false | let mt_free_path (path: path_p) : HST.ST unit pf pt =
| MTNL.free_path path | false |
MerkleTree.fsti | MerkleTree.mt_init_path | val mt_init_path (hash_size: hash_size_t) (mtr: HH.rid) (r: HST.erid) : HST.ST path_p pf pt | val mt_init_path (hash_size: hash_size_t) (mtr: HH.rid) (r: HST.erid) : HST.ST path_p pf pt | let mt_init_path (hash_size:hash_size_t) (mtr:HH.rid) (r:HST.erid): HST.ST path_p pf pt = MTNL.init_path hash_size mtr r | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 120,
"end_line": 47,
"start_col": 0,
"start_line": 47
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r
[@ (Comment " Destructor for hashes") "c_inline"]
let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 |
hash_size: MerkleTree.hash_size_t ->
mtr: FStar.Monotonic.HyperHeap.rid ->
r: FStar.HyperStack.ST.erid
-> FStar.HyperStack.ST.ST MerkleTree.path_p | FStar.HyperStack.ST.ST | [] | [] | [
"MerkleTree.hash_size_t",
"FStar.Monotonic.HyperHeap.rid",
"FStar.HyperStack.ST.erid",
"MerkleTree.Low.init_path",
"MerkleTree.Low.path_p",
"MerkleTree.path_p",
"MerkleTree.pf",
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.pt"
] | [] | false | true | false | false | false | let mt_init_path (hash_size: hash_size_t) (mtr: HH.rid) (r: HST.erid) : HST.ST path_p pf pt =
| MTNL.init_path hash_size mtr r | false |
MerkleTree.fsti | MerkleTree.mt_get_path_length | val mt_get_path_length (mtr: HH.rid) (path: const_path_p) : HST.ST U32.t pf pt | val mt_get_path_length (mtr: HH.rid) (path: const_path_p) : HST.ST U32.t pf pt | let mt_get_path_length (mtr:HH.rid) (path:const_path_p): HST.ST U32.t pf pt = MTNL.mt_get_path_length mtr path | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 110,
"end_line": 57,
"start_col": 0,
"start_line": 57
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r
[@ (Comment " Destructor for hashes") "c_inline"]
let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h
[@ (Comment " Constructor for paths") "c_inline"]
let mt_init_path (hash_size:hash_size_t) (mtr:HH.rid) (r:HST.erid): HST.ST path_p pf pt = MTNL.init_path hash_size mtr r
[@ (Comment " Destructor for paths") "c_inline"]
let mt_free_path (path:path_p): HST.ST unit pf pt = MTNL.free_path path
[@ (Comment " Length of a path
@param[in] p Path | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | mtr: FStar.Monotonic.HyperHeap.rid -> path: MerkleTree.const_path_p
-> FStar.HyperStack.ST.ST FStar.UInt32.t | FStar.HyperStack.ST.ST | [] | [] | [
"FStar.Monotonic.HyperHeap.rid",
"MerkleTree.const_path_p",
"MerkleTree.Low.mt_get_path_length",
"LowStar.Vector.uint32_t",
"FStar.UInt32.t",
"MerkleTree.pf",
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.pt"
] | [] | false | true | false | false | false | let mt_get_path_length (mtr: HH.rid) (path: const_path_p) : HST.ST U32.t pf pt =
| MTNL.mt_get_path_length mtr path | false |
MerkleTree.fsti | MerkleTree.tree_hash_size | val tree_hash_size : mt: MerkleTree.mt_p -> Prims.GTot MerkleTree.Low.Datastructures.hash_size_t | let tree_hash_size (#h:HS.mem) (mt:mt_p) = MTNL.MT?.hash_size (B.get h mt 0) | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 76,
"end_line": 77,
"start_col": 0,
"start_line": 77
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r
[@ (Comment " Destructor for hashes") "c_inline"]
let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h
[@ (Comment " Constructor for paths") "c_inline"]
let mt_init_path (hash_size:hash_size_t) (mtr:HH.rid) (r:HST.erid): HST.ST path_p pf pt = MTNL.init_path hash_size mtr r
[@ (Comment " Destructor for paths") "c_inline"]
let mt_free_path (path:path_p): HST.ST unit pf pt = MTNL.free_path path
[@ (Comment " Length of a path
@param[in] p Path
return The length of the path") "c_inline"]
let mt_get_path_length (mtr:HH.rid) (path:const_path_p): HST.ST U32.t pf pt = MTNL.mt_get_path_length mtr path
[@ (Comment " Insert hash into path
@param[in] p Path
@param[in] hash Hash to insert") "c_inline"]
let mt_path_insert
(#h:HS.mem)
(#mtr:HH.rid)
(path:path_p)
(hash:hash #(MTNL.Path?.hash_size (B.get h path 0)))
: HST.ST unit pf pt
= let hash_size = MTNL.Path?.hash_size (B.index path 0ul) in
MTNL.mt_path_insert #hash_size mtr path hash
inline_for_extraction
let path_hash_size (#h:HS.mem) (path:path_p) = MTNL.Path?.hash_size (B.get h path 0)
inline_for_extraction
let const_path_hash_size (#h:HS.mem) (path:const_path_p) = path_hash_size #h (CB.cast path) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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.mt_p -> Prims.GTot MerkleTree.Low.Datastructures.hash_size_t | Prims.GTot | [
"sometrivial"
] | [] | [
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.mt_p",
"MerkleTree.Low.__proj__MT__item__hash_size",
"LowStar.Monotonic.Buffer.get",
"MerkleTree.Low.merkle_tree",
"LowStar.Buffer.trivial_preorder",
"MerkleTree.Low.Datastructures.hash_size_t"
] | [] | false | false | false | false | false | let tree_hash_size (#h: HS.mem) (mt: mt_p) =
| MTNL.MT?.hash_size (B.get h mt 0) | false |
|
MerkleTree.fsti | MerkleTree.mt_free_hash | val mt_free_hash (#hash_size: Ghost.erased hash_size_t) (h: hash #hash_size) : HST.ST unit pf pt | val mt_free_hash (#hash_size: Ghost.erased hash_size_t) (h: hash #hash_size) : HST.ST unit pf pt | let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 114,
"end_line": 43,
"start_col": 0,
"start_line": 43
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | h: MerkleTree.hash -> FStar.HyperStack.ST.ST Prims.unit | FStar.HyperStack.ST.ST | [] | [] | [
"FStar.Ghost.erased",
"MerkleTree.hash_size_t",
"MerkleTree.hash",
"FStar.Ghost.reveal",
"MerkleTree.Low.Hashfunctions.free_hash",
"Prims.unit",
"MerkleTree.pf",
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.pt"
] | [] | false | true | false | false | false | let mt_free_hash (#hash_size: Ghost.erased hash_size_t) (h: hash #hash_size) : HST.ST unit pf pt =
| MTNLHF.free_hash h | false |
MerkleTree.fsti | MerkleTree.mt_init_hash | val mt_init_hash (hash_size: hash_size_t) (r: HST.erid) : HST.ST (hash #hash_size) pf pt | val mt_init_hash (hash_size: hash_size_t) (r: HST.erid) : HST.ST (hash #hash_size) pf pt | let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 116,
"end_line": 40,
"start_col": 0,
"start_line": 40
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | hash_size: MerkleTree.hash_size_t -> r: FStar.HyperStack.ST.erid
-> FStar.HyperStack.ST.ST MerkleTree.hash | FStar.HyperStack.ST.ST | [] | [] | [
"MerkleTree.hash_size_t",
"FStar.HyperStack.ST.erid",
"MerkleTree.Low.Hashfunctions.init_hash",
"MerkleTree.Low.Datastructures.hash",
"MerkleTree.hash",
"MerkleTree.pf",
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.pt"
] | [] | false | true | false | false | false | let mt_init_hash (hash_size: hash_size_t) (r: HST.erid) : HST.ST (hash #hash_size) pf pt =
| MTNLHF.init_hash hash_size r | false |
MerkleTree.fsti | MerkleTree.const_tree_hash_size | val const_tree_hash_size : mt: MerkleTree.const_mt_p -> Prims.GTot MerkleTree.Low.Datastructures.hash_size_t | let const_tree_hash_size (#h:HS.mem) (mt:const_mt_p) = tree_hash_size #h (CB.cast mt) | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 85,
"end_line": 79,
"start_col": 0,
"start_line": 79
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r
[@ (Comment " Destructor for hashes") "c_inline"]
let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h
[@ (Comment " Constructor for paths") "c_inline"]
let mt_init_path (hash_size:hash_size_t) (mtr:HH.rid) (r:HST.erid): HST.ST path_p pf pt = MTNL.init_path hash_size mtr r
[@ (Comment " Destructor for paths") "c_inline"]
let mt_free_path (path:path_p): HST.ST unit pf pt = MTNL.free_path path
[@ (Comment " Length of a path
@param[in] p Path
return The length of the path") "c_inline"]
let mt_get_path_length (mtr:HH.rid) (path:const_path_p): HST.ST U32.t pf pt = MTNL.mt_get_path_length mtr path
[@ (Comment " Insert hash into path
@param[in] p Path
@param[in] hash Hash to insert") "c_inline"]
let mt_path_insert
(#h:HS.mem)
(#mtr:HH.rid)
(path:path_p)
(hash:hash #(MTNL.Path?.hash_size (B.get h path 0)))
: HST.ST unit pf pt
= let hash_size = MTNL.Path?.hash_size (B.index path 0ul) in
MTNL.mt_path_insert #hash_size mtr path hash
inline_for_extraction
let path_hash_size (#h:HS.mem) (path:path_p) = MTNL.Path?.hash_size (B.get h path 0)
inline_for_extraction
let const_path_hash_size (#h:HS.mem) (path:const_path_p) = path_hash_size #h (CB.cast path)
inline_for_extraction
let tree_hash_size (#h:HS.mem) (mt:mt_p) = MTNL.MT?.hash_size (B.get h mt 0) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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.const_mt_p -> Prims.GTot MerkleTree.Low.Datastructures.hash_size_t | Prims.GTot | [
"sometrivial"
] | [] | [
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.const_mt_p",
"MerkleTree.tree_hash_size",
"LowStar.ConstBuffer.cast",
"MerkleTree.Low.merkle_tree",
"MerkleTree.Low.Datastructures.hash_size_t"
] | [] | false | false | false | false | false | let const_tree_hash_size (#h: HS.mem) (mt: const_mt_p) =
| tree_hash_size #h (CB.cast mt) | false |
|
MerkleTree.fsti | MerkleTree.mt_get_path_step | val mt_get_path_step (#h: HS.mem) (#mtr: HH.rid) (path: const_path_p) (i: U32.t)
: HST.ST (hash #(const_path_hash_size #h path)) pf pt | val mt_get_path_step (#h: HS.mem) (#mtr: HH.rid) (path: const_path_p) (i: U32.t)
: HST.ST (hash #(const_path_hash_size #h path)) pf pt | let mt_get_path_step
(#h:HS.mem)
(#mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST (hash #(const_path_hash_size #h path)) pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step #hash_size mtr path i | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 45,
"end_line": 94,
"start_col": 0,
"start_line": 87
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r
[@ (Comment " Destructor for hashes") "c_inline"]
let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h
[@ (Comment " Constructor for paths") "c_inline"]
let mt_init_path (hash_size:hash_size_t) (mtr:HH.rid) (r:HST.erid): HST.ST path_p pf pt = MTNL.init_path hash_size mtr r
[@ (Comment " Destructor for paths") "c_inline"]
let mt_free_path (path:path_p): HST.ST unit pf pt = MTNL.free_path path
[@ (Comment " Length of a path
@param[in] p Path
return The length of the path") "c_inline"]
let mt_get_path_length (mtr:HH.rid) (path:const_path_p): HST.ST U32.t pf pt = MTNL.mt_get_path_length mtr path
[@ (Comment " Insert hash into path
@param[in] p Path
@param[in] hash Hash to insert") "c_inline"]
let mt_path_insert
(#h:HS.mem)
(#mtr:HH.rid)
(path:path_p)
(hash:hash #(MTNL.Path?.hash_size (B.get h path 0)))
: HST.ST unit pf pt
= let hash_size = MTNL.Path?.hash_size (B.index path 0ul) in
MTNL.mt_path_insert #hash_size mtr path hash
inline_for_extraction
let path_hash_size (#h:HS.mem) (path:path_p) = MTNL.Path?.hash_size (B.get h path 0)
inline_for_extraction
let const_path_hash_size (#h:HS.mem) (path:const_path_p) = path_hash_size #h (CB.cast path)
inline_for_extraction
let tree_hash_size (#h:HS.mem) (mt:mt_p) = MTNL.MT?.hash_size (B.get h mt 0)
inline_for_extraction
let const_tree_hash_size (#h:HS.mem) (mt:const_mt_p) = tree_hash_size #h (CB.cast mt)
[@ (Comment " Get step on a path
@param[in] p Path
@param[in] i Path step index | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | path: MerkleTree.const_path_p -> i: FStar.UInt32.t -> FStar.HyperStack.ST.ST MerkleTree.hash | FStar.HyperStack.ST.ST | [] | [] | [
"FStar.Monotonic.HyperStack.mem",
"FStar.Monotonic.HyperHeap.rid",
"MerkleTree.const_path_p",
"FStar.UInt32.t",
"MerkleTree.Low.mt_get_path_step",
"FStar.Ghost.hide",
"MerkleTree.Low.Datastructures.hash_size_t",
"MerkleTree.Low.Datastructures.hash",
"FStar.Ghost.reveal",
"MerkleTree.Low.__proj__Path__item__hash_size",
"MerkleTree.Low.path",
"LowStar.Monotonic.Buffer.index",
"MerkleTree.path",
"LowStar.ConstBuffer.qbuf_pre",
"LowStar.ConstBuffer.as_qbuf",
"LowStar.ConstBuffer.cast",
"FStar.UInt32.__uint_to_t",
"MerkleTree.hash",
"MerkleTree.const_path_hash_size",
"MerkleTree.pf",
"MerkleTree.pt"
] | [] | false | true | false | false | false | let mt_get_path_step (#h: HS.mem) (#mtr: HH.rid) (path: const_path_p) (i: U32.t)
: HST.ST (hash #(const_path_hash_size #h path)) pf pt =
| let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step #hash_size mtr path i | false |
MerkleTree.fsti | MerkleTree.path_hash_size | val path_hash_size : path: MerkleTree.path_p -> Prims.GTot MerkleTree.Low.Datastructures.hash_size_t | let path_hash_size (#h:HS.mem) (path:path_p) = MTNL.Path?.hash_size (B.get h path 0) | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 84,
"end_line": 73,
"start_col": 0,
"start_line": 73
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r
[@ (Comment " Destructor for hashes") "c_inline"]
let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h
[@ (Comment " Constructor for paths") "c_inline"]
let mt_init_path (hash_size:hash_size_t) (mtr:HH.rid) (r:HST.erid): HST.ST path_p pf pt = MTNL.init_path hash_size mtr r
[@ (Comment " Destructor for paths") "c_inline"]
let mt_free_path (path:path_p): HST.ST unit pf pt = MTNL.free_path path
[@ (Comment " Length of a path
@param[in] p Path
return The length of the path") "c_inline"]
let mt_get_path_length (mtr:HH.rid) (path:const_path_p): HST.ST U32.t pf pt = MTNL.mt_get_path_length mtr path
[@ (Comment " Insert hash into path
@param[in] p Path
@param[in] hash Hash to insert") "c_inline"]
let mt_path_insert
(#h:HS.mem)
(#mtr:HH.rid)
(path:path_p)
(hash:hash #(MTNL.Path?.hash_size (B.get h path 0)))
: HST.ST unit pf pt
= let hash_size = MTNL.Path?.hash_size (B.index path 0ul) in
MTNL.mt_path_insert #hash_size mtr path hash | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | path: MerkleTree.path_p -> Prims.GTot MerkleTree.Low.Datastructures.hash_size_t | Prims.GTot | [
"sometrivial"
] | [] | [
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.path_p",
"MerkleTree.Low.__proj__Path__item__hash_size",
"LowStar.Monotonic.Buffer.get",
"MerkleTree.path",
"LowStar.Buffer.trivial_preorder",
"MerkleTree.Low.Datastructures.hash_size_t"
] | [] | false | false | false | false | false | let path_hash_size (#h: HS.mem) (path: path_p) =
| MTNL.Path?.hash_size (B.get h path 0) | false |
|
MerkleTree.fsti | MerkleTree.const_path_hash_size | val const_path_hash_size : path: MerkleTree.const_path_p -> Prims.GTot MerkleTree.Low.Datastructures.hash_size_t | let const_path_hash_size (#h:HS.mem) (path:const_path_p) = path_hash_size #h (CB.cast path) | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 91,
"end_line": 75,
"start_col": 0,
"start_line": 75
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r
[@ (Comment " Destructor for hashes") "c_inline"]
let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h
[@ (Comment " Constructor for paths") "c_inline"]
let mt_init_path (hash_size:hash_size_t) (mtr:HH.rid) (r:HST.erid): HST.ST path_p pf pt = MTNL.init_path hash_size mtr r
[@ (Comment " Destructor for paths") "c_inline"]
let mt_free_path (path:path_p): HST.ST unit pf pt = MTNL.free_path path
[@ (Comment " Length of a path
@param[in] p Path
return The length of the path") "c_inline"]
let mt_get_path_length (mtr:HH.rid) (path:const_path_p): HST.ST U32.t pf pt = MTNL.mt_get_path_length mtr path
[@ (Comment " Insert hash into path
@param[in] p Path
@param[in] hash Hash to insert") "c_inline"]
let mt_path_insert
(#h:HS.mem)
(#mtr:HH.rid)
(path:path_p)
(hash:hash #(MTNL.Path?.hash_size (B.get h path 0)))
: HST.ST unit pf pt
= let hash_size = MTNL.Path?.hash_size (B.index path 0ul) in
MTNL.mt_path_insert #hash_size mtr path hash
inline_for_extraction
let path_hash_size (#h:HS.mem) (path:path_p) = MTNL.Path?.hash_size (B.get h path 0) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | path: MerkleTree.const_path_p -> Prims.GTot MerkleTree.Low.Datastructures.hash_size_t | Prims.GTot | [
"sometrivial"
] | [] | [
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.const_path_p",
"MerkleTree.path_hash_size",
"LowStar.ConstBuffer.cast",
"MerkleTree.path",
"MerkleTree.Low.Datastructures.hash_size_t"
] | [] | false | false | false | false | false | let const_path_hash_size (#h: HS.mem) (path: const_path_p) =
| path_hash_size #h (CB.cast path) | false |
|
Hacl.Poly1305.Field32xN.Lemmas0.fst | Hacl.Poly1305.Field32xN.Lemmas0.mul_felem5_lemma_3 | val mul_felem5_lemma_3:
f1:tup64_5{tup64_fits5 f1 (3, 3, 3, 3, 3)}
-> r:tup64_5{tup64_fits5 r (2, 2, 2, 2, 2)} ->
Lemma
(let (f10, f11, f12, f13, f14) = f1 in
let (r0, r1, r2, r3, r4) = r in
(as_nat5 f1 * as_nat5 r) % prime ==
(v f10 * as_nat5 r +
v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) +
v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) +
v f13 * as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) +
v f14 * pow104 * as_nat5 r) % prime) | val mul_felem5_lemma_3:
f1:tup64_5{tup64_fits5 f1 (3, 3, 3, 3, 3)}
-> r:tup64_5{tup64_fits5 r (2, 2, 2, 2, 2)} ->
Lemma
(let (f10, f11, f12, f13, f14) = f1 in
let (r0, r1, r2, r3, r4) = r in
(as_nat5 f1 * as_nat5 r) % prime ==
(v f10 * as_nat5 r +
v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) +
v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) +
v f13 * as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) +
v f14 * pow104 * as_nat5 r) % prime) | let mul_felem5_lemma_3 f1 r =
let (f10, f11, f12, f13, f14) = f1 in
let (r0, r1, r2, r3, r4) = r in
let tmp =
v f10 * as_nat5 r + v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) +
v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) + v f14 * pow104 * as_nat5 r in
calc (==) {
(as_nat5 f1 * as_nat5 r) % prime;
(==) { mul_felem5_lemma_2 f1 r }
(tmp + v f13 * pow78 * as_nat5 r) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp (v f13 * pow78 * as_nat5 r) prime }
(tmp + (v f13 * pow78 * as_nat5 r) % prime) % prime;
(==) {
FStar.Math.Lemmas.paren_mul_right (v f13) pow78 (as_nat5 r);
FStar.Math.Lemmas.lemma_mod_mul_distr_r (v f13) (pow78 * as_nat5 r) prime }
(tmp + v f13 * (pow78 * as_nat5 r % prime) % prime) % prime;
(==) { lemma_fmul5_pow78 r }
(tmp + v f13 * (as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) % prime) % prime) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (v f13) (as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1)) prime }
(tmp + v f13 * as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) % prime) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp (v f13 * as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1)) prime }
(tmp + v f13 * as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1)) % prime;
};
assert ((as_nat5 f1 * as_nat5 r) % prime == (tmp + v f13 * as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1)) % prime) | {
"file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas0.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 126,
"end_line": 592,
"start_col": 0,
"start_line": 568
} | module Hacl.Poly1305.Field32xN.Lemmas0
open Lib.IntTypes
open Lib.IntVector
open Lib.Sequence
open FStar.Mul
open FStar.Calc
open Hacl.Spec.Poly1305.Vec
include Hacl.Spec.Poly1305.Field32xN
#reset-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0"
val lemma_prime: unit -> Lemma (pow2 130 % prime = 5)
let lemma_prime () =
assert_norm (pow2 130 % prime = 5 % prime);
assert_norm (5 < prime);
FStar.Math.Lemmas.modulo_lemma 5 prime
val lemma_mult_le: a:nat -> b:nat -> c:nat -> d:nat -> Lemma
(requires a <= b /\ c <= d)
(ensures a * c <= b * d)
let lemma_mult_le a b c d = ()
val lemma_mul5_distr_l: a:nat -> b:nat -> c:nat -> d:nat -> e:nat -> f:nat -> Lemma
(a * (b + c + d + e + f) == a * b + a * c + a * d + a * e + a * f)
let lemma_mul5_distr_l a b c d e f = ()
val lemma_mul5_distr_r: a:nat -> b:nat -> c:nat -> d:nat -> e:nat -> f:nat -> Lemma
((a + b + c + d + e) * f == a * f + b * f + c * f + d * f + e * f)
let lemma_mul5_distr_r a b c d e f = ()
val smul_mod_lemma:
#m1:scale32
-> #m2:scale32
-> a:nat{a <= m1 * max26}
-> b:nat{b <= m2 * max26} ->
Lemma (a * b % pow2 64 == a * b)
let smul_mod_lemma #m1 #m2 a b =
lemma_mult_le a (m1 * max26) b (m2 * max26);
assert (a * b <= m1 * m2 * max26 * max26);
FStar.Math.Lemmas.modulo_lemma (a * b) (pow2 64)
val smul_add_mod_lemma:
#m1:scale32
-> #m2:scale32
-> #m3:scale64{m3 + m1 * m2 <= 4096}
-> a:nat{a <= m1 * max26}
-> b:nat{b <= m2 * max26}
-> c:nat{c <= m3 * max26 * max26} ->
Lemma ((c + a * b % pow2 64) % pow2 64 == c + a * b)
let smul_add_mod_lemma #m1 #m2 #m3 a b c =
assert_norm ((m3 + m1 * m2) * max26 * max26 < pow2 64);
lemma_mult_le a (m1 * max26) b (m2 * max26);
assert (c + a * b <= m3 * max26 * max26 + m1 * m2 * max26 * max26);
FStar.Math.Lemmas.modulo_lemma (c + a * b) (pow2 64)
val add5_lemma1: ma:scale64 -> mb:scale64 -> a:uint64 -> b:uint64 -> Lemma
(requires v a <= ma * max26 /\ v b <= mb * max26 /\ ma + mb <= 64)
(ensures v (a +. b) == v a + v b /\ v (a +. b) <= (ma + mb) * max26)
let add5_lemma1 ma mb a b =
assert (v a + v b <= (ma + mb) * max26);
Math.Lemmas.lemma_mult_le_right max26 (ma + mb) 64;
assert (v a + v b <= 64 * max26);
assert_norm (64 * max26 < pow2 32);
Math.Lemmas.small_mod (v a + v b) (pow2 32)
#set-options "--ifuel 1"
val fadd5_eval_lemma_i:
#w:lanes
-> f1:felem5 w{felem_fits5 f1 (2,2,2,2,2)}
-> f2:felem5 w{felem_fits5 f2 (1,1,1,1,1)}
-> i:nat{i < w} ->
Lemma ((feval5 (fadd5 f1 f2)).[i] == pfadd (feval5 f1).[i] (feval5 f2).[i])
let fadd5_eval_lemma_i #w f1 f2 i =
let o = fadd5 f1 f2 in
let (f10, f11, f12, f13, f14) = as_tup64_i f1 i in
let (f20, f21, f22, f23, f24) = as_tup64_i f2 i in
let (o0, o1, o2, o3, o4) = as_tup64_i o i in
add5_lemma1 2 1 f10 f20;
add5_lemma1 2 1 f11 f21;
add5_lemma1 2 1 f12 f22;
add5_lemma1 2 1 f13 f23;
add5_lemma1 2 1 f14 f24;
assert (as_nat5 (o0, o1, o2, o3, o4) ==
as_nat5 (f10, f11, f12, f13, f14) + as_nat5 (f20, f21, f22, f23, f24));
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (f10, f11, f12, f13, f14)) (as_nat5 (f20, f21, f22, f23, f24)) prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
(as_nat5 (f10, f11, f12, f13, f14) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime
val smul_felem5_fits_lemma_i:
#w:lanes
-> #m1:scale32
-> #m2:scale32
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:uint64xN w{felem_fits1 f2 m2}
-> i:nat{i < w} ->
Lemma ((uint64xN_v (vec_mul_mod f2 u1)).[i] <= m1 * m2 * max26 * max26)
let smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 i =
let o = vec_mul_mod f2 u1 in
smul_mod_lemma #m1 #m2 (uint64xN_v u1).[i] (uint64xN_v f2).[i];
assert ((uint64xN_v o).[i] == (uint64xN_v u1).[i] * (uint64xN_v f2).[i]);
lemma_mult_le (uint64xN_v u1).[i] (m1 * max26) (uint64xN_v f2).[i] (m2 * max26)
val smul_felem5_eval_lemma_i:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2}
-> i:nat{i < w} ->
Lemma ((fas_nat5 (smul_felem5 #w u1 f2)).[i] == (uint64xN_v u1).[i] * (fas_nat5 f2).[i])
let smul_felem5_eval_lemma_i #w #m1 #m2 u1 f2 i =
let o = smul_felem5 #w u1 f2 in
let (m20, m21, m22, m23, m24) = m2 in
let vu1 = (uint64xN_v u1).[i] in
let (tf20, tf21, tf22, tf23, tf24) = as_tup64_i f2 i in
let (to0, to1, to2, to3, to4) = as_tup64_i o i in
smul_mod_lemma #m1 #m20 vu1 (v tf20);
smul_mod_lemma #m1 #m21 vu1 (v tf21);
smul_mod_lemma #m1 #m22 vu1 (v tf22);
smul_mod_lemma #m1 #m23 vu1 (v tf23);
smul_mod_lemma #m1 #m24 vu1 (v tf24);
assert ((fas_nat5 o).[i] == vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 +
vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104);
calc (==) {
vu1 * (fas_nat5 f2).[i];
(==) { }
vu1 * (v tf20 + v tf21 * pow26 + v tf22 * pow52 + v tf23 * pow78 + v tf24 * pow104);
(==) { lemma_mul5_distr_l vu1 (v tf20) (v tf21 * pow26) (v tf22 * pow52) (v tf23 * pow78) (v tf24 * pow104)}
vu1 * v tf20 + vu1 * (v tf21 * pow26) + vu1 * (v tf22 * pow52) + vu1 * (v tf23 * pow78) + vu1 * (v tf24 * pow104);
(==) {
FStar.Math.Lemmas.paren_mul_right vu1 (v tf21) pow26;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf22) pow52;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf23) pow78;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf24) pow104}
vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 + vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104;
};
assert (vu1 * (fas_nat5 f2).[i] == (fas_nat5 o).[i])
val smul_felem5_fits_lemma1:
#w:lanes
-> #m1:scale32
-> #m2:scale32
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:uint64xN w{felem_fits1 f2 m2} ->
Lemma (felem_wide_fits1 (vec_mul_mod f2 u1) (m1 * m2))
let smul_felem5_fits_lemma1 #w #m1 #m2 u1 f2 =
match w with
| 1 ->
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 0
| 2 ->
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 0;
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 1
| 4 ->
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 0;
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 1;
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 2;
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 3
val smul_felem5_fits_lemma:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2} ->
Lemma (felem_wide_fits5 (smul_felem5 #w u1 f2) (m1 *^ m2))
let smul_felem5_fits_lemma #w #m1 #m2 u1 f2 =
let (f20, f21, f22, f23, f24) = f2 in
let (m20, m21, m22, m23, m24) = m2 in
smul_felem5_fits_lemma1 #w #m1 #m20 u1 f20;
smul_felem5_fits_lemma1 #w #m1 #m21 u1 f21;
smul_felem5_fits_lemma1 #w #m1 #m22 u1 f22;
smul_felem5_fits_lemma1 #w #m1 #m23 u1 f23;
smul_felem5_fits_lemma1 #w #m1 #m24 u1 f24
val smul_felem5_eval_lemma:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2} ->
Lemma (fas_nat5 (smul_felem5 #w u1 f2) ==
map2 #nat #nat #nat (fun a b -> a * b) (uint64xN_v u1) (fas_nat5 f2))
let smul_felem5_eval_lemma #w #m1 #m2 u1 f2 =
FStar.Classical.forall_intro (smul_felem5_eval_lemma_i #w #m1 #m2 u1 f2);
eq_intro (fas_nat5 (smul_felem5 #w u1 f2))
(map2 #nat #nat #nat (fun a b -> a * b) (uint64xN_v u1) (fas_nat5 f2))
val smul_add_felem5_fits_lemma_i:
#w:lanes
-> #m1:scale32
-> #m2:scale32
-> #m3:scale64{m3 + m1 * m2 <= 4096}
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:uint64xN w{felem_fits1 f2 m2}
-> acc1:uint64xN w{felem_wide_fits1 acc1 m3}
-> i:nat{i < w} ->
Lemma ((uint64xN_v (vec_add_mod acc1 (vec_mul_mod f2 u1))).[i] <= (m3 + m1 * m2) * max26 * max26)
#push-options "--z3rlimit 200"
let smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 i =
let o = vec_add_mod acc1 (vec_mul_mod f2 u1) in
smul_add_mod_lemma #m1 #m2 #m3 (uint64xN_v u1).[i] (uint64xN_v f2).[i] (uint64xN_v acc1).[i];
assert ((uint64xN_v o).[i] == (uint64xN_v acc1).[i] + (uint64xN_v u1).[i] * (uint64xN_v f2).[i]);
lemma_mult_le (uint64xN_v u1).[i] (m1 * max26) (uint64xN_v f2).[i] (m2 * max26);
assert ((uint64xN_v o).[i] <= m3 * max26 * max26 + m1 * m2 * max26 * max26)
#pop-options
val smul_add_felem5_eval_lemma_i:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> #m3:scale64_5{m3 +* m1 *^ m2 <=* s64x5 4096}
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2}
-> acc1:felem_wide5 w{felem_wide_fits5 acc1 m3}
-> i:nat{i < w} ->
Lemma ((fas_nat5 (smul_add_felem5 #w u1 f2 acc1)).[i] ==
(fas_nat5 acc1).[i] + (uint64xN_v u1).[i] * (fas_nat5 f2).[i])
let smul_add_felem5_eval_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 i =
let o = smul_add_felem5 #w u1 f2 acc1 in
let (m20, m21, m22, m23, m24) = m2 in
let (m30, m31, m32, m33, m34) = m3 in
let vu1 = (uint64xN_v u1).[i] in
let (tf20, tf21, tf22, tf23, tf24) = as_tup64_i f2 i in
let (ta0, ta1, ta2, ta3, ta4) = as_tup64_i acc1 i in
let (to0, to1, to2, to3, to4) = as_tup64_i o i in
smul_add_mod_lemma #m1 #m20 #m30 vu1 (v tf20) (v ta0);
smul_add_mod_lemma #m1 #m21 #m31 vu1 (v tf21) (v ta1);
smul_add_mod_lemma #m1 #m22 #m32 vu1 (v tf22) (v ta2);
smul_add_mod_lemma #m1 #m23 #m33 vu1 (v tf23) (v ta3);
smul_add_mod_lemma #m1 #m24 #m34 vu1 (v tf24) (v ta4);
calc (==) {
(fas_nat5 o).[i];
(==) { }
v ta0 + vu1 * v tf20 + (v ta1 + vu1 * v tf21) * pow26 + (v ta2 + vu1 * v tf22) * pow52 +
(v ta3 + vu1 * v tf23) * pow78 + (v ta4 + vu1 * v tf24) * pow104;
(==) {
FStar.Math.Lemmas.distributivity_add_left (v ta1) (vu1 * v tf21) pow26;
FStar.Math.Lemmas.distributivity_add_left (v ta2) (vu1 * v tf22) pow52;
FStar.Math.Lemmas.distributivity_add_left (v ta3) (vu1 * v tf23) pow78;
FStar.Math.Lemmas.distributivity_add_left (v ta1) (vu1 * v tf24) pow104 }
v ta0 + v ta1 * pow26 + v ta2 * pow52 + v ta3 * pow78 + v ta4 * pow104 +
vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 + vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104;
(==) { }
(fas_nat5 acc1).[i] + vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 + vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104;
};
assert ((fas_nat5 o).[i] == (fas_nat5 acc1).[i] +
vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 + vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104);
calc (==) {
vu1 * (fas_nat5 f2).[i];
(==) { }
vu1 * (v tf20 + v tf21 * pow26 + v tf22 * pow52 + v tf23 * pow78 + v tf24 * pow104);
(==) { lemma_mul5_distr_l vu1 (v tf20) (v tf21 * pow26) (v tf22 * pow52) (v tf23 * pow78) (v tf24 * pow104)}
vu1 * v tf20 + vu1 * (v tf21 * pow26) + vu1 * (v tf22 * pow52) + vu1 * (v tf23 * pow78) + vu1 * (v tf24 * pow104);
(==) {
FStar.Math.Lemmas.paren_mul_right vu1 (v tf21) pow26;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf22) pow52;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf23) pow78;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf24) pow104}
vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 + vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104;
};
assert ((fas_nat5 o).[i] == (fas_nat5 acc1).[i] + vu1 * (fas_nat5 f2).[i])
val smul_add_felem5_fits_lemma1:
#w:lanes
-> #m1:scale32
-> #m2:scale32
-> #m3:scale64{m3 + m1 * m2 <= 4096}
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:uint64xN w{felem_fits1 f2 m2}
-> acc1:uint64xN w{felem_wide_fits1 acc1 m3} ->
Lemma (felem_wide_fits1 (vec_add_mod acc1 (vec_mul_mod f2 u1)) (m3 + m1 * m2))
let smul_add_felem5_fits_lemma1 #w #m1 #m2 #m3 u1 f2 acc1 =
match w with
| 1 ->
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 0
| 2 ->
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 0;
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 1
| 4 ->
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 0;
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 1;
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 2;
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 3
val smul_add_felem5_fits_lemma:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> #m3:scale64_5{m3 +* m1 *^ m2 <=* s64x5 4096}
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2}
-> acc1:felem_wide5 w{felem_wide_fits5 acc1 m3} ->
Lemma (felem_wide_fits5 (smul_add_felem5 #w u1 f2 acc1) (m3 +* m1 *^ m2))
let smul_add_felem5_fits_lemma #w #m1 #m2 #m3 u1 f2 acc1 =
let (f20, f21, f22, f23, f24) = f2 in
let (m20, m21, m22, m23, m24) = m2 in
let (a0, a1, a2, a3, a4) = acc1 in
let (m30, m31, m32, m33, m34) = m3 in
smul_add_felem5_fits_lemma1 #w #m1 #m20 #m30 u1 f20 a0;
smul_add_felem5_fits_lemma1 #w #m1 #m21 #m31 u1 f21 a1;
smul_add_felem5_fits_lemma1 #w #m1 #m22 #m32 u1 f22 a2;
smul_add_felem5_fits_lemma1 #w #m1 #m23 #m33 u1 f23 a3;
smul_add_felem5_fits_lemma1 #w #m1 #m24 #m34 u1 f24 a4
val smul_add_felem5_eval_lemma:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> #m3:scale64_5{m3 +* m1 *^ m2 <=* s64x5 4096}
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2}
-> acc1:felem_wide5 w{felem_wide_fits5 acc1 m3} ->
Lemma (fas_nat5 (smul_add_felem5 #w u1 f2 acc1) ==
map2 #nat #nat #nat (fun a b -> a + b) (fas_nat5 acc1)
(map2 #nat #nat #nat (fun a b -> a * b) (uint64xN_v u1) (fas_nat5 f2)))
let smul_add_felem5_eval_lemma #w #m1 #m2 #m3 u1 f2 acc1 =
let tmp =
map2 #nat #nat #nat (fun a b -> a + b) (fas_nat5 acc1)
(map2 #nat #nat #nat (fun a b -> a * b) (uint64xN_v u1) (fas_nat5 f2)) in
FStar.Classical.forall_intro (smul_add_felem5_eval_lemma_i #w #m1 #m2 #m3 u1 f2 acc1);
eq_intro (fas_nat5 (smul_add_felem5 #w u1 f2 acc1)) tmp
val lemma_fmul5_pow26: r:tup64_5 -> Lemma
(requires (let (r0, r1, r2, r3, r4) = r in v r4 * 5 <= 10 * pow26))
(ensures (let (r0, r1, r2, r3, r4) = r in
(pow26 * as_nat5 r) % prime == as_nat5 (r4 *! u64 5, r0, r1, r2, r3) % prime))
let lemma_fmul5_pow26 r =
let (r0, r1, r2, r3, r4) = r in
calc (==) {
(pow26 * as_nat5 r) % prime;
(==) { }
(pow26 * (v r0 + v r1 * pow26 + v r2 * pow52 + v r3 * pow78 + v r4 * pow104)) % prime;
(==) { lemma_mul5_distr_l pow26 (v r0) (v r1 * pow26) (v r2 * pow52) (v r3 * pow78) (v r4 * pow104) }
(v r0 * pow26 + pow26 * v r1 * pow26 + pow26 * v r2 * pow52 + pow26 * v r3 * pow78 + pow26 * v r4 * pow104) % prime;
(==) { }
(v r0 * pow26 + v r1 * pow26 * pow26 + v r2 * pow26 * pow52 + v r3 * pow26 * pow78 + v r4 * pow26 * pow104) % prime;
(==) {
assert_norm (pow26 * pow26 = pow52);
assert_norm (pow26 * pow52 = pow78);
assert_norm (pow26 * pow78 = pow104);
assert_norm (pow26 * pow104 = pow2 130) }
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + v r4 * pow2 130) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104) (v r4 * pow2 130) prime }
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + (v r4 * pow2 130) % prime) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (v r4) (pow2 130) prime }
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + (v r4 * (pow2 130 % prime)) % prime) % prime;
(==) { lemma_prime () }
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + (v r4 * 5) % prime) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104) (v r4 * 5) prime }
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + v r4 * 5) % prime;
};
assert ((pow26 * as_nat5 r) % prime ==
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + v r4 * 5) % prime)
val lemma_fmul5_pow52: r:tup64_5 -> Lemma
(requires (let (r0, r1, r2, r3, r4) = r in
v r4 * 5 <= 10 * pow26 /\ v r3 * 5 <= 10 * pow26))
(ensures (let (r0, r1, r2, r3, r4) = r in
(pow52 * as_nat5 r) % prime == as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) % prime))
let lemma_fmul5_pow52 r =
let (r0, r1, r2, r3, r4) = r in
calc (==) {
(pow52 * as_nat5 r) % prime;
(==) { assert_norm (pow52 == pow26 * pow26) }
(pow26 * pow26 * as_nat5 r) % prime;
(==) {
FStar.Math.Lemmas.paren_mul_right pow26 pow26 (as_nat5 r);
FStar.Math.Lemmas.lemma_mod_mul_distr_r pow26 (pow26 * as_nat5 r) prime }
(pow26 * (pow26 * as_nat5 r % prime)) % prime;
(==) { lemma_fmul5_pow26 r }
(pow26 * (as_nat5 (r4 *! u64 5, r0, r1, r2, r3) % prime)) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r pow26 (as_nat5 (r4 *! u64 5, r0, r1, r2, r3)) prime }
(pow26 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3)) % prime;
(==) { lemma_fmul5_pow26 (r4 *! u64 5, r0, r1, r2, r3) }
as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) % prime;
};
assert ((pow52 * as_nat5 r) % prime == as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) % prime)
val lemma_fmul5_pow78: r:tup64_5 -> Lemma
(requires (let (r0, r1, r2, r3, r4) = r in
v r4 * 5 <= 10 * pow26 /\ v r3 * 5 <= 10 * pow26 /\ v r2 * 5 <= 10 * pow26))
(ensures (let (r0, r1, r2, r3, r4) = r in
(pow78 * as_nat5 r) % prime == as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) % prime))
let lemma_fmul5_pow78 r =
let (r0, r1, r2, r3, r4) = r in
calc (==) {
(pow78 * as_nat5 r) % prime;
(==) { assert_norm (pow78 == pow26 * pow52) }
(pow26 * pow52 * as_nat5 r) % prime;
(==) {
FStar.Math.Lemmas.paren_mul_right pow26 pow52 (as_nat5 r);
FStar.Math.Lemmas.lemma_mod_mul_distr_r pow26 (pow52 * as_nat5 r) prime }
(pow26 * (pow52 * as_nat5 r % prime)) % prime;
(==) { lemma_fmul5_pow52 r }
(pow26 * (as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) % prime)) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r pow26 (as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2)) prime }
(pow26 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2)) % prime;
(==) { lemma_fmul5_pow26 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) }
as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) % prime;
};
assert ((pow78 * as_nat5 r) % prime == as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) % prime)
val lemma_fmul5_pow104: r:tup64_5 -> Lemma
(requires (let (r0, r1, r2, r3, r4) = r in
v r4 * 5 <= 10 * pow26 /\ v r3 * 5 <= 10 * pow26 /\
v r2 * 5 <= 10 * pow26 /\ v r1 * 5 <= 10 * pow26))
(ensures (let (r0, r1, r2, r3, r4) = r in
(pow104 * as_nat5 r) % prime == as_nat5 (r1 *! u64 5, r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0) % prime))
let lemma_fmul5_pow104 r =
let (r0, r1, r2, r3, r4) = r in
calc (==) {
(pow104 * as_nat5 r) % prime;
(==) { assert_norm (pow104 == pow26 * pow78) }
(pow26 * pow78 * as_nat5 r) % prime;
(==) {
FStar.Math.Lemmas.paren_mul_right pow26 pow78 (as_nat5 r);
FStar.Math.Lemmas.lemma_mod_mul_distr_r pow26 (pow78 * as_nat5 r) prime }
(pow26 * (pow78 * as_nat5 r % prime)) % prime;
(==) { lemma_fmul5_pow78 r }
(pow26 * (as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) % prime)) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r pow26 (as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1)) prime }
(pow26 * as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1)) % prime;
(==) { lemma_fmul5_pow26 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) }
as_nat5 (r1 *! u64 5, r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0) % prime;
};
assert ((pow104 * as_nat5 r) % prime == as_nat5 (r1 *! u64 5, r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0) % prime)
val mul_felem5_lemma_1:
f1:tup64_5{tup64_fits5 f1 (3, 3, 3, 3, 3)}
-> r:tup64_5{tup64_fits5 r (2, 2, 2, 2, 2)} ->
Lemma
(let (f10, f11, f12, f13, f14) = f1 in
let (r0, r1, r2, r3, r4) = r in
(as_nat5 f1 * as_nat5 r) % prime ==
(v f10 * as_nat5 r +
v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) +
v f12 * pow52 * as_nat5 r + v f13 * pow78 * as_nat5 r + v f14 * pow104 * as_nat5 r) % prime)
let mul_felem5_lemma_1 f1 r =
let (f10, f11, f12, f13, f14) = f1 in
let (r0, r1, r2, r3, r4) = r in
let tmp = v f10 * as_nat5 r + v f12 * pow52 * as_nat5 r + v f13 * pow78 * as_nat5 r + v f14 * pow104 * as_nat5 r in
calc (==) {
(as_nat5 f1 * as_nat5 r) % prime;
(==) { }
(v f10 + v f11 * pow26 + v f12 * pow52 + v f13 * pow78 + v f14 * pow104) * as_nat5 r % prime;
(==) { lemma_mul5_distr_r (v f10) (v f11 * pow26) (v f12 * pow52) (v f13 * pow78) (v f14 * pow104) (as_nat5 r) }
(v f10 * as_nat5 r + v f11 * pow26 * as_nat5 r + v f12 * pow52 * as_nat5 r + v f13 * pow78 * as_nat5 r + v f14 * pow104 * as_nat5 r) % prime;
(==) {
FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp (v f11 * pow26 * as_nat5 r) prime }
(tmp + (v f11 * pow26 * as_nat5 r) % prime) % prime;
(==) {
FStar.Math.Lemmas.paren_mul_right (v f11) pow26 (as_nat5 r);
FStar.Math.Lemmas.lemma_mod_mul_distr_r (v f11) (pow26 * as_nat5 r) prime }
(tmp + v f11 * (pow26 * as_nat5 r % prime) % prime) % prime;
(==) { lemma_fmul5_pow26 r }
(tmp + v f11 * (as_nat5 (r4 *! u64 5, r0, r1, r2, r3) % prime) % prime) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (v f11) (as_nat5 (r4 *! u64 5, r0, r1, r2, r3)) prime }
(tmp + v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) % prime) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp (v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3)) prime }
(tmp + v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3)) % prime;
};
assert ((as_nat5 f1 * as_nat5 r) % prime == (tmp + v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3)) % prime)
val mul_felem5_lemma_2:
f1:tup64_5{tup64_fits5 f1 (3, 3, 3, 3, 3)}
-> r:tup64_5{tup64_fits5 r (2, 2, 2, 2, 2)} ->
Lemma
(let (f10, f11, f12, f13, f14) = f1 in
let (r0, r1, r2, r3, r4) = r in
(as_nat5 f1 * as_nat5 r) % prime ==
(v f10 * as_nat5 r +
v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) +
v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) +
v f13 * pow78 * as_nat5 r + v f14 * pow104 * as_nat5 r) % prime)
let mul_felem5_lemma_2 f1 r =
let (f10, f11, f12, f13, f14) = f1 in
let (r0, r1, r2, r3, r4) = r in
let tmp =
v f10 * as_nat5 r + v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) +
v f13 * pow78 * as_nat5 r + v f14 * pow104 * as_nat5 r in
calc (==) {
(as_nat5 f1 * as_nat5 r) % prime;
(==) { mul_felem5_lemma_1 f1 r }
(tmp + v f12 * pow52 * as_nat5 r) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp (v f12 * pow52 * as_nat5 r) prime }
(tmp + (v f12 * pow52 * as_nat5 r) % prime) % prime;
(==) {
FStar.Math.Lemmas.paren_mul_right (v f12) pow52 (as_nat5 r);
FStar.Math.Lemmas.lemma_mod_mul_distr_r (v f12) (pow52 * as_nat5 r) prime }
(tmp + v f12 * (pow52 * as_nat5 r % prime) % prime) % prime;
(==) { lemma_fmul5_pow52 r }
(tmp + v f12 * (as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) % prime) % prime) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (v f12) (as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2)) prime }
(tmp + v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) % prime) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp (v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2)) prime }
(tmp + v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2)) % prime;
};
assert ((as_nat5 f1 * as_nat5 r) % prime == (tmp + v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2)) % prime)
val mul_felem5_lemma_3:
f1:tup64_5{tup64_fits5 f1 (3, 3, 3, 3, 3)}
-> r:tup64_5{tup64_fits5 r (2, 2, 2, 2, 2)} ->
Lemma
(let (f10, f11, f12, f13, f14) = f1 in
let (r0, r1, r2, r3, r4) = r in
(as_nat5 f1 * as_nat5 r) % prime ==
(v f10 * as_nat5 r +
v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) +
v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) +
v f13 * as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) +
v f14 * pow104 * as_nat5 r) % prime) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Poly1305.Vec.fst.checked",
"Hacl.Spec.Poly1305.Field32xN.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Poly1305.Field32xN.Lemmas0.fst"
} | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Poly1305.Field32xN",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Poly1305.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Poly1305.Field32xN",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Poly1305.Field32xN",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
f1:
Hacl.Spec.Poly1305.Field32xN.tup64_5
{Hacl.Spec.Poly1305.Field32xN.tup64_fits5 f1 (3, 3, 3, 3, 3)} ->
r:
Hacl.Spec.Poly1305.Field32xN.tup64_5
{Hacl.Spec.Poly1305.Field32xN.tup64_fits5 r (2, 2, 2, 2, 2)}
-> FStar.Pervasives.Lemma
(ensures
(let _ = f1 in
(let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ f10 f11 f12 f13 f14 = _ in
let _ = r in
(let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ r0 r1 r2 r3 r4 = _ in
Hacl.Spec.Poly1305.Field32xN.as_nat5 f1 * Hacl.Spec.Poly1305.Field32xN.as_nat5 r %
Hacl.Spec.Poly1305.Vec.prime ==
(Lib.IntTypes.v f10 * Hacl.Spec.Poly1305.Field32xN.as_nat5 r +
Lib.IntTypes.v f11 *
Hacl.Spec.Poly1305.Field32xN.as_nat5 (r4 *! Lib.IntTypes.u64 5, r0, r1, r2, r3) +
Lib.IntTypes.v f12 *
Hacl.Spec.Poly1305.Field32xN.as_nat5 (r3 *! Lib.IntTypes.u64 5,
r4 *! Lib.IntTypes.u64 5,
r0,
r1,
r2) +
Lib.IntTypes.v f13 *
Hacl.Spec.Poly1305.Field32xN.as_nat5 (r2 *! Lib.IntTypes.u64 5,
r3 *! Lib.IntTypes.u64 5,
r4 *! Lib.IntTypes.u64 5,
r0,
r1) +
(Lib.IntTypes.v f14 * Hacl.Spec.Poly1305.Field32xN.pow104) *
Hacl.Spec.Poly1305.Field32xN.as_nat5 r) %
Hacl.Spec.Poly1305.Vec.prime)
<:
Type0)
<:
Type0)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Hacl.Spec.Poly1305.Field32xN.tup64_5",
"Hacl.Spec.Poly1305.Field32xN.tup64_fits5",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Lib.IntTypes.uint64",
"Prims._assert",
"Prims.eq2",
"Prims.int",
"Prims.op_Modulus",
"FStar.Mul.op_Star",
"Hacl.Spec.Poly1305.Field32xN.as_nat5",
"Hacl.Spec.Poly1305.Vec.prime",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.u64",
"Prims.unit",
"FStar.Calc.calc_finish",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"FStar.Calc.calc_step",
"Hacl.Spec.Poly1305.Field32xN.pow78",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Hacl.Poly1305.Field32xN.Lemmas0.mul_felem5_lemma_2",
"Prims.squash",
"FStar.Math.Lemmas.lemma_mod_plus_distr_r",
"FStar.Math.Lemmas.lemma_mod_mul_distr_r",
"FStar.Math.Lemmas.paren_mul_right",
"Hacl.Poly1305.Field32xN.Lemmas0.lemma_fmul5_pow78",
"Hacl.Spec.Poly1305.Field32xN.pow104"
] | [] | false | false | true | false | false | let mul_felem5_lemma_3 f1 r =
| let f10, f11, f12, f13, f14 = f1 in
let r0, r1, r2, r3, r4 = r in
let tmp =
v f10 * as_nat5 r + v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) +
v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) +
(v f14 * pow104) * as_nat5 r
in
calc ( == ) {
(as_nat5 f1 * as_nat5 r) % prime;
( == ) { mul_felem5_lemma_2 f1 r }
(tmp + (v f13 * pow78) * as_nat5 r) % prime;
( == ) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp ((v f13 * pow78) * as_nat5 r) prime }
(tmp + ((v f13 * pow78) * as_nat5 r) % prime) % prime;
( == ) { (FStar.Math.Lemmas.paren_mul_right (v f13) pow78 (as_nat5 r);
FStar.Math.Lemmas.lemma_mod_mul_distr_r (v f13) (pow78 * as_nat5 r) prime) }
(tmp + v f13 * (pow78 * as_nat5 r % prime) % prime) % prime;
( == ) { lemma_fmul5_pow78 r }
(tmp + v f13 * (as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) % prime) % prime) % prime;
( == ) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (v f13)
(as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1))
prime }
(tmp + v f13 * as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) % prime) % prime;
( == ) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp
(v f13 * as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1))
prime }
(tmp + v f13 * as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1)) % prime;
};
assert ((as_nat5 f1 * as_nat5 r) % prime ==
(tmp + v f13 * as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1)) % prime) | false |
MerkleTree.fsti | MerkleTree.mt_get_path_step_pre | val mt_get_path_step_pre (#h: HS.mem) (mtr: HH.rid) (path: const_path_p) (i: U32.t)
: HST.ST bool pf pt | val mt_get_path_step_pre (#h: HS.mem) (mtr: HH.rid) (path: const_path_p) (i: U32.t)
: HST.ST bool pf pt | let mt_get_path_step_pre
(#h:HS.mem)
(mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST bool pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step_pre #hash_size mtr path i | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 49,
"end_line": 104,
"start_col": 0,
"start_line": 97
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r
[@ (Comment " Destructor for hashes") "c_inline"]
let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h
[@ (Comment " Constructor for paths") "c_inline"]
let mt_init_path (hash_size:hash_size_t) (mtr:HH.rid) (r:HST.erid): HST.ST path_p pf pt = MTNL.init_path hash_size mtr r
[@ (Comment " Destructor for paths") "c_inline"]
let mt_free_path (path:path_p): HST.ST unit pf pt = MTNL.free_path path
[@ (Comment " Length of a path
@param[in] p Path
return The length of the path") "c_inline"]
let mt_get_path_length (mtr:HH.rid) (path:const_path_p): HST.ST U32.t pf pt = MTNL.mt_get_path_length mtr path
[@ (Comment " Insert hash into path
@param[in] p Path
@param[in] hash Hash to insert") "c_inline"]
let mt_path_insert
(#h:HS.mem)
(#mtr:HH.rid)
(path:path_p)
(hash:hash #(MTNL.Path?.hash_size (B.get h path 0)))
: HST.ST unit pf pt
= let hash_size = MTNL.Path?.hash_size (B.index path 0ul) in
MTNL.mt_path_insert #hash_size mtr path hash
inline_for_extraction
let path_hash_size (#h:HS.mem) (path:path_p) = MTNL.Path?.hash_size (B.get h path 0)
inline_for_extraction
let const_path_hash_size (#h:HS.mem) (path:const_path_p) = path_hash_size #h (CB.cast path)
inline_for_extraction
let tree_hash_size (#h:HS.mem) (mt:mt_p) = MTNL.MT?.hash_size (B.get h mt 0)
inline_for_extraction
let const_tree_hash_size (#h:HS.mem) (mt:const_mt_p) = tree_hash_size #h (CB.cast mt)
[@ (Comment " Get step on a path
@param[in] p Path
@param[in] i Path step index
return The hash at step i of p") "c_inline"]
let mt_get_path_step
(#h:HS.mem)
(#mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST (hash #(const_path_hash_size #h path)) pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step #hash_size mtr path i | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | mtr: FStar.Monotonic.HyperHeap.rid -> path: MerkleTree.const_path_p -> i: FStar.UInt32.t
-> FStar.HyperStack.ST.ST Prims.bool | FStar.HyperStack.ST.ST | [] | [] | [
"FStar.Monotonic.HyperStack.mem",
"FStar.Monotonic.HyperHeap.rid",
"MerkleTree.const_path_p",
"FStar.UInt32.t",
"MerkleTree.Low.mt_get_path_step_pre",
"FStar.Ghost.hide",
"MerkleTree.Low.Datastructures.hash_size_t",
"Prims.bool",
"MerkleTree.Low.__proj__Path__item__hash_size",
"MerkleTree.Low.path",
"LowStar.Monotonic.Buffer.index",
"MerkleTree.path",
"LowStar.ConstBuffer.qbuf_pre",
"LowStar.ConstBuffer.as_qbuf",
"LowStar.ConstBuffer.cast",
"FStar.UInt32.__uint_to_t",
"MerkleTree.pf",
"MerkleTree.pt"
] | [] | false | true | false | false | false | let mt_get_path_step_pre (#h: HS.mem) (mtr: HH.rid) (path: const_path_p) (i: U32.t)
: HST.ST bool pf pt =
| let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step_pre #hash_size mtr path i | false |
MerkleTree.fsti | MerkleTree.mt_free | val mt_free (mt: mt_p) : HST.ST unit pf pt | val mt_free (mt: mt_p) : HST.ST unit pf pt | let mt_free (mt:mt_p): HST.ST unit pf pt = MTNL.mt_free mt | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 58,
"end_line": 126,
"start_col": 0,
"start_line": 126
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r
[@ (Comment " Destructor for hashes") "c_inline"]
let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h
[@ (Comment " Constructor for paths") "c_inline"]
let mt_init_path (hash_size:hash_size_t) (mtr:HH.rid) (r:HST.erid): HST.ST path_p pf pt = MTNL.init_path hash_size mtr r
[@ (Comment " Destructor for paths") "c_inline"]
let mt_free_path (path:path_p): HST.ST unit pf pt = MTNL.free_path path
[@ (Comment " Length of a path
@param[in] p Path
return The length of the path") "c_inline"]
let mt_get_path_length (mtr:HH.rid) (path:const_path_p): HST.ST U32.t pf pt = MTNL.mt_get_path_length mtr path
[@ (Comment " Insert hash into path
@param[in] p Path
@param[in] hash Hash to insert") "c_inline"]
let mt_path_insert
(#h:HS.mem)
(#mtr:HH.rid)
(path:path_p)
(hash:hash #(MTNL.Path?.hash_size (B.get h path 0)))
: HST.ST unit pf pt
= let hash_size = MTNL.Path?.hash_size (B.index path 0ul) in
MTNL.mt_path_insert #hash_size mtr path hash
inline_for_extraction
let path_hash_size (#h:HS.mem) (path:path_p) = MTNL.Path?.hash_size (B.get h path 0)
inline_for_extraction
let const_path_hash_size (#h:HS.mem) (path:const_path_p) = path_hash_size #h (CB.cast path)
inline_for_extraction
let tree_hash_size (#h:HS.mem) (mt:mt_p) = MTNL.MT?.hash_size (B.get h mt 0)
inline_for_extraction
let const_tree_hash_size (#h:HS.mem) (mt:const_mt_p) = tree_hash_size #h (CB.cast mt)
[@ (Comment " Get step on a path
@param[in] p Path
@param[in] i Path step index
return The hash at step i of p") "c_inline"]
let mt_get_path_step
(#h:HS.mem)
(#mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST (hash #(const_path_hash_size #h path)) pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step #hash_size mtr path i
[@ (Comment " Precondition predicate for mt_get_path_step") "c_inline"]
let mt_get_path_step_pre
(#h:HS.mem)
(mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST bool pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step_pre #hash_size mtr path i
[@ (Comment " Construction with custom hash functions
@param[in] hash_size Hash size (in bytes)
@param[in] i The initial hash
return The new Merkle tree") "c_inline"]
let mt_create_custom
(hash_size:hash_size_t)
(hash_spec:Ghost.erased (MTS.hash_fun_t #(U32.v hash_size)))
(r:HST.erid)
(i:hash #hash_size)
(hash_fun:MTNLHF.hash_fun_t #hash_size #hash_spec)
: HST.ST mt_p pf pt
= MTNL.mt_create_custom hash_size hash_spec r i hash_fun
[@ (Comment " Destruction | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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.mt_p -> FStar.HyperStack.ST.ST Prims.unit | FStar.HyperStack.ST.ST | [] | [] | [
"MerkleTree.mt_p",
"MerkleTree.Low.mt_free",
"Prims.unit",
"MerkleTree.pf",
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.pt"
] | [] | false | true | false | false | false | let mt_free (mt: mt_p) : HST.ST unit pf pt =
| MTNL.mt_free mt | false |
Vale.X64.InsSha.fsti | Vale.X64.InsSha.va_wp_SHA256_msg1 | val va_wp_SHA256_msg1
(dst src: va_operand_xmm)
(t: counter)
(block: block_w)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | val va_wp_SHA256_msg1
(dst src: va_operand_xmm)
(t: counter)
(block: block_w)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | let va_wp_SHA256_msg1 (dst:va_operand_xmm) (src:va_operand_xmm) (t:counter) (block:block_w)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\ ((16 <=
t && t < size_k_w_256)) /\ va_eval_xmm va_s0 dst == ws_quad32 (t - 16) block /\ (va_eval_xmm
va_s0 src).lo0 == ws_opaque block (t - 12) /\ (forall (va_x_dst:va_value_xmm) . let va_sM =
va_upd_operand_xmm dst va_x_dst va_s0 in va_get_ok va_sM /\ va_eval_xmm va_sM dst == ws_partial
t block ==> va_k va_sM (()))) | {
"file_name": "obj/Vale.X64.InsSha.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 33,
"end_line": 84,
"start_col": 0,
"start_line": 78
} | module Vale.X64.InsSha
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Spec.SHA2
open Spec.Hash.Definitions
open Vale.SHA.SHA_helpers
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.QuickCode
open Vale.X64.InsVector
open FStar.UInt32
open FStar.Seq
open Spec.Loops
open Vale.X64.CPU_Features_s
//-- SHA256_rnds2
val va_code_SHA256_rnds2 : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code
val va_codegen_success_SHA256_rnds2 : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool
val va_lemma_SHA256_rnds2 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> t:counter -> block:block_w -> hash_orig:hash256
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_SHA256_rnds2 dst src) va_s0 /\ va_is_dst_xmm dst va_s0
/\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\ t + 1 < size_k_w_256 /\
(va_get_xmm 0 va_s0).lo0 == add_wrap (word_to_nat32 (index k t)) (ws_opaque block t) /\
(va_get_xmm 0 va_s0).lo1 == add_wrap (word_to_nat32 (index k (t + 1))) (ws_opaque block (t +
1)) /\ make_hash (va_eval_xmm va_s0 src) (va_eval_xmm va_s0 dst) == repeat_range 0 t
(shuffle_core_opaque block) hash_orig))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
make_hash (va_eval_xmm va_sM dst) (va_eval_xmm va_s0 src) == repeat_range 0 (t + 2)
(shuffle_core_opaque block) hash_orig /\ va_state_eq va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0))))
[@ va_qattr]
let va_wp_SHA256_rnds2 (dst:va_operand_xmm) (src:va_operand_xmm) (t:counter) (block:block_w)
(hash_orig:hash256) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\ t + 1 <
size_k_w_256 /\ (va_get_xmm 0 va_s0).lo0 == add_wrap (word_to_nat32 (index k t)) (ws_opaque
block t) /\ (va_get_xmm 0 va_s0).lo1 == add_wrap (word_to_nat32 (index k (t + 1))) (ws_opaque
block (t + 1)) /\ make_hash (va_eval_xmm va_s0 src) (va_eval_xmm va_s0 dst) == repeat_range 0 t
(shuffle_core_opaque block) hash_orig /\ (forall (va_x_dst:va_value_xmm) . let va_sM =
va_upd_operand_xmm dst va_x_dst va_s0 in va_get_ok va_sM /\ make_hash (va_eval_xmm va_sM dst)
(va_eval_xmm va_s0 src) == repeat_range 0 (t + 2) (shuffle_core_opaque block) hash_orig ==>
va_k va_sM (())))
val va_wpProof_SHA256_rnds2 : dst:va_operand_xmm -> src:va_operand_xmm -> t:counter ->
block:block_w -> hash_orig:hash256 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_SHA256_rnds2 dst src t block hash_orig va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_SHA256_rnds2 dst src) ([va_mod_xmm
dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_SHA256_rnds2 (dst:va_operand_xmm) (src:va_operand_xmm) (t:counter) (block:block_w)
(hash_orig:hash256) : (va_quickCode unit (va_code_SHA256_rnds2 dst src)) =
(va_QProc (va_code_SHA256_rnds2 dst src) ([va_mod_xmm dst]) (va_wp_SHA256_rnds2 dst src t block
hash_orig) (va_wpProof_SHA256_rnds2 dst src t block hash_orig))
//--
//-- SHA256_msg1
val va_code_SHA256_msg1 : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code
val va_codegen_success_SHA256_msg1 : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool
val va_lemma_SHA256_msg1 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> t:counter -> block:block_w
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_SHA256_msg1 dst src) va_s0 /\ va_is_dst_xmm dst va_s0
/\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\ ((16 <= t && t < size_k_w_256))
/\ va_eval_xmm va_s0 dst == ws_quad32 (t - 16) block /\ (va_eval_xmm va_s0 src).lo0 ==
ws_opaque block (t - 12)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == ws_partial t block /\ va_state_eq va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0)))) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.InsVector.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.SHA.SHA_helpers.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.fsti.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.InsSha.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Loops",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"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 |
dst: Vale.X64.Decls.va_operand_xmm ->
src: Vale.X64.Decls.va_operand_xmm ->
t: Vale.SHA.SHA_helpers.counter ->
block: Vale.SHA.SHA_helpers.block_w ->
va_s0: Vale.X64.Decls.va_state ->
va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Decls.va_operand_xmm",
"Vale.SHA.SHA_helpers.counter",
"Vale.SHA.SHA_helpers.block_w",
"Vale.X64.Decls.va_state",
"Prims.unit",
"Prims.l_and",
"Vale.X64.Decls.va_is_dst_xmm",
"Vale.X64.Decls.va_is_src_xmm",
"Prims.b2t",
"Vale.X64.Decls.va_get_ok",
"Vale.X64.CPU_Features_s.sha_enabled",
"Prims.op_AmpAmp",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Vale.SHA.SHA_helpers.size_k_w_256",
"Prims.eq2",
"Vale.Def.Types_s.quad32",
"Vale.X64.Decls.va_eval_xmm",
"Vale.SHA.SHA_helpers.ws_quad32",
"Prims.op_Subtraction",
"Vale.Def.Words_s.nat32",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0",
"Vale.Def.Types_s.nat32",
"Vale.SHA.SHA_helpers.ws_opaque",
"Prims.l_Forall",
"Vale.X64.Decls.va_value_xmm",
"Prims.l_imp",
"Vale.SHA.SHA_helpers.ws_partial",
"Vale.X64.State.vale_state",
"Vale.X64.Decls.va_upd_operand_xmm"
] | [] | false | false | false | true | true | let va_wp_SHA256_msg1
(dst src: va_operand_xmm)
(t: counter)
(block: block_w)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 =
| (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\
((16 <= t && t < size_k_w_256)) /\ va_eval_xmm va_s0 dst == ws_quad32 (t - 16) block /\
(va_eval_xmm va_s0 src).lo0 == ws_opaque block (t - 12) /\
(forall (va_x_dst: va_value_xmm).
let va_sM = va_upd_operand_xmm dst va_x_dst va_s0 in
va_get_ok va_sM /\ va_eval_xmm va_sM dst == ws_partial t block ==> va_k va_sM (()))) | false |
MerkleTree.fsti | MerkleTree.mt_create_custom | val mt_create_custom
(hash_size: hash_size_t)
(hash_spec: Ghost.erased (MTS.hash_fun_t #(U32.v hash_size)))
(r: HST.erid)
(i: hash #hash_size)
(hash_fun: MTNLHF.hash_fun_t #hash_size #hash_spec)
: HST.ST mt_p pf pt | val mt_create_custom
(hash_size: hash_size_t)
(hash_spec: Ghost.erased (MTS.hash_fun_t #(U32.v hash_size)))
(r: HST.erid)
(i: hash #hash_size)
(hash_fun: MTNLHF.hash_fun_t #hash_size #hash_spec)
: HST.ST mt_p pf pt | let mt_create_custom
(hash_size:hash_size_t)
(hash_spec:Ghost.erased (MTS.hash_fun_t #(U32.v hash_size)))
(r:HST.erid)
(i:hash #hash_size)
(hash_fun:MTNLHF.hash_fun_t #hash_size #hash_spec)
: HST.ST mt_p pf pt
= MTNL.mt_create_custom hash_size hash_spec r i hash_fun | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 56,
"end_line": 120,
"start_col": 0,
"start_line": 113
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r
[@ (Comment " Destructor for hashes") "c_inline"]
let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h
[@ (Comment " Constructor for paths") "c_inline"]
let mt_init_path (hash_size:hash_size_t) (mtr:HH.rid) (r:HST.erid): HST.ST path_p pf pt = MTNL.init_path hash_size mtr r
[@ (Comment " Destructor for paths") "c_inline"]
let mt_free_path (path:path_p): HST.ST unit pf pt = MTNL.free_path path
[@ (Comment " Length of a path
@param[in] p Path
return The length of the path") "c_inline"]
let mt_get_path_length (mtr:HH.rid) (path:const_path_p): HST.ST U32.t pf pt = MTNL.mt_get_path_length mtr path
[@ (Comment " Insert hash into path
@param[in] p Path
@param[in] hash Hash to insert") "c_inline"]
let mt_path_insert
(#h:HS.mem)
(#mtr:HH.rid)
(path:path_p)
(hash:hash #(MTNL.Path?.hash_size (B.get h path 0)))
: HST.ST unit pf pt
= let hash_size = MTNL.Path?.hash_size (B.index path 0ul) in
MTNL.mt_path_insert #hash_size mtr path hash
inline_for_extraction
let path_hash_size (#h:HS.mem) (path:path_p) = MTNL.Path?.hash_size (B.get h path 0)
inline_for_extraction
let const_path_hash_size (#h:HS.mem) (path:const_path_p) = path_hash_size #h (CB.cast path)
inline_for_extraction
let tree_hash_size (#h:HS.mem) (mt:mt_p) = MTNL.MT?.hash_size (B.get h mt 0)
inline_for_extraction
let const_tree_hash_size (#h:HS.mem) (mt:const_mt_p) = tree_hash_size #h (CB.cast mt)
[@ (Comment " Get step on a path
@param[in] p Path
@param[in] i Path step index
return The hash at step i of p") "c_inline"]
let mt_get_path_step
(#h:HS.mem)
(#mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST (hash #(const_path_hash_size #h path)) pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step #hash_size mtr path i
[@ (Comment " Precondition predicate for mt_get_path_step") "c_inline"]
let mt_get_path_step_pre
(#h:HS.mem)
(mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST bool pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step_pre #hash_size mtr path i
[@ (Comment " Construction with custom hash functions
@param[in] hash_size Hash size (in bytes)
@param[in] i The initial hash | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 |
hash_size: MerkleTree.hash_size_t ->
hash_spec: FStar.Ghost.erased MerkleTree.Spec.hash_fun_t ->
r: FStar.HyperStack.ST.erid ->
i: MerkleTree.hash ->
hash_fun: MerkleTree.Low.Hashfunctions.hash_fun_t
-> FStar.HyperStack.ST.ST MerkleTree.mt_p | FStar.HyperStack.ST.ST | [] | [] | [
"MerkleTree.hash_size_t",
"FStar.Ghost.erased",
"MerkleTree.Spec.hash_fun_t",
"FStar.UInt32.v",
"FStar.HyperStack.ST.erid",
"MerkleTree.hash",
"MerkleTree.Low.Hashfunctions.hash_fun_t",
"MerkleTree.Low.mt_create_custom",
"MerkleTree.Low.mt_p",
"MerkleTree.mt_p",
"MerkleTree.pf",
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.pt"
] | [] | false | true | false | false | false | let mt_create_custom
(hash_size: hash_size_t)
(hash_spec: Ghost.erased (MTS.hash_fun_t #(U32.v hash_size)))
(r: HST.erid)
(i: hash #hash_size)
(hash_fun: MTNLHF.hash_fun_t #hash_size #hash_spec)
: HST.ST mt_p pf pt =
| MTNL.mt_create_custom hash_size hash_spec r i hash_fun | false |
MerkleTree.fsti | MerkleTree.mt_path_insert | val mt_path_insert
(#h: HS.mem)
(#mtr: HH.rid)
(path: path_p)
(hash: hash #(MTNL.Path?.hash_size (B.get h path 0)))
: HST.ST unit pf pt | val mt_path_insert
(#h: HS.mem)
(#mtr: HH.rid)
(path: path_p)
(hash: hash #(MTNL.Path?.hash_size (B.get h path 0)))
: HST.ST unit pf pt | let mt_path_insert
(#h:HS.mem)
(#mtr:HH.rid)
(path:path_p)
(hash:hash #(MTNL.Path?.hash_size (B.get h path 0)))
: HST.ST unit pf pt
= let hash_size = MTNL.Path?.hash_size (B.index path 0ul) in
MTNL.mt_path_insert #hash_size mtr path hash | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 46,
"end_line": 70,
"start_col": 0,
"start_line": 63
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r
[@ (Comment " Destructor for hashes") "c_inline"]
let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h
[@ (Comment " Constructor for paths") "c_inline"]
let mt_init_path (hash_size:hash_size_t) (mtr:HH.rid) (r:HST.erid): HST.ST path_p pf pt = MTNL.init_path hash_size mtr r
[@ (Comment " Destructor for paths") "c_inline"]
let mt_free_path (path:path_p): HST.ST unit pf pt = MTNL.free_path path
[@ (Comment " Length of a path
@param[in] p Path
return The length of the path") "c_inline"]
let mt_get_path_length (mtr:HH.rid) (path:const_path_p): HST.ST U32.t pf pt = MTNL.mt_get_path_length mtr path
[@ (Comment " Insert hash into path
@param[in] p Path | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | path: MerkleTree.path_p -> hash: MerkleTree.hash -> FStar.HyperStack.ST.ST Prims.unit | FStar.HyperStack.ST.ST | [] | [] | [
"FStar.Monotonic.HyperStack.mem",
"FStar.Monotonic.HyperHeap.rid",
"MerkleTree.path_p",
"MerkleTree.hash",
"MerkleTree.Low.__proj__Path__item__hash_size",
"LowStar.Monotonic.Buffer.get",
"MerkleTree.path",
"LowStar.Buffer.trivial_preorder",
"MerkleTree.Low.mt_path_insert",
"Prims.unit",
"MerkleTree.Low.Datastructures.hash_size_t",
"MerkleTree.Low.path",
"LowStar.Monotonic.Buffer.index",
"FStar.UInt32.__uint_to_t",
"MerkleTree.pf",
"MerkleTree.pt"
] | [] | false | true | false | false | false | let mt_path_insert
(#h: HS.mem)
(#mtr: HH.rid)
(path: path_p)
(hash: hash #(MTNL.Path?.hash_size (B.get h path 0)))
: HST.ST unit pf pt =
| let hash_size = MTNL.Path?.hash_size (B.index path 0ul) in
MTNL.mt_path_insert #hash_size mtr path hash | false |
MerkleTree.fsti | MerkleTree.mt_get_root | val mt_get_root (#h: HS.mem) (mt: const_mt_p) (root: hash #(const_tree_hash_size #h mt))
: HST.ST unit pf pt | val mt_get_root (#h: HS.mem) (mt: const_mt_p) (root: hash #(const_tree_hash_size #h mt))
: HST.ST unit pf pt | let mt_get_root
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root #hash_size mt root | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 37,
"end_line": 163,
"start_col": 0,
"start_line": 157
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r
[@ (Comment " Destructor for hashes") "c_inline"]
let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h
[@ (Comment " Constructor for paths") "c_inline"]
let mt_init_path (hash_size:hash_size_t) (mtr:HH.rid) (r:HST.erid): HST.ST path_p pf pt = MTNL.init_path hash_size mtr r
[@ (Comment " Destructor for paths") "c_inline"]
let mt_free_path (path:path_p): HST.ST unit pf pt = MTNL.free_path path
[@ (Comment " Length of a path
@param[in] p Path
return The length of the path") "c_inline"]
let mt_get_path_length (mtr:HH.rid) (path:const_path_p): HST.ST U32.t pf pt = MTNL.mt_get_path_length mtr path
[@ (Comment " Insert hash into path
@param[in] p Path
@param[in] hash Hash to insert") "c_inline"]
let mt_path_insert
(#h:HS.mem)
(#mtr:HH.rid)
(path:path_p)
(hash:hash #(MTNL.Path?.hash_size (B.get h path 0)))
: HST.ST unit pf pt
= let hash_size = MTNL.Path?.hash_size (B.index path 0ul) in
MTNL.mt_path_insert #hash_size mtr path hash
inline_for_extraction
let path_hash_size (#h:HS.mem) (path:path_p) = MTNL.Path?.hash_size (B.get h path 0)
inline_for_extraction
let const_path_hash_size (#h:HS.mem) (path:const_path_p) = path_hash_size #h (CB.cast path)
inline_for_extraction
let tree_hash_size (#h:HS.mem) (mt:mt_p) = MTNL.MT?.hash_size (B.get h mt 0)
inline_for_extraction
let const_tree_hash_size (#h:HS.mem) (mt:const_mt_p) = tree_hash_size #h (CB.cast mt)
[@ (Comment " Get step on a path
@param[in] p Path
@param[in] i Path step index
return The hash at step i of p") "c_inline"]
let mt_get_path_step
(#h:HS.mem)
(#mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST (hash #(const_path_hash_size #h path)) pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step #hash_size mtr path i
[@ (Comment " Precondition predicate for mt_get_path_step") "c_inline"]
let mt_get_path_step_pre
(#h:HS.mem)
(mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST bool pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step_pre #hash_size mtr path i
[@ (Comment " Construction with custom hash functions
@param[in] hash_size Hash size (in bytes)
@param[in] i The initial hash
return The new Merkle tree") "c_inline"]
let mt_create_custom
(hash_size:hash_size_t)
(hash_spec:Ghost.erased (MTS.hash_fun_t #(U32.v hash_size)))
(r:HST.erid)
(i:hash #hash_size)
(hash_fun:MTNLHF.hash_fun_t #hash_size #hash_spec)
: HST.ST mt_p pf pt
= MTNL.mt_create_custom hash_size hash_spec r i hash_fun
[@ (Comment " Destruction
@param[in] mt The Merkle tree") "c_inline"]
let mt_free (mt:mt_p): HST.ST unit pf pt = MTNL.mt_free mt
[@ (Comment " Insertion
@param[in] mt The Merkle tree
@param[in] v The tree does not take ownership of the hash, it makes a copy of its content.
Note: The content of the hash will be overwritten with an arbitrary value.") "c_inline"]
let mt_insert
(#h:HS.mem)
(mt:mt_p)
(v:hash #(tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index mt 0ul) in
MTNL.mt_insert hash_size mt v
[@ (Comment " Precondition predicate for mt_insert") "c_inline"]
let mt_insert_pre
(#h:HS.mem)
(mt:const_mt_p)
(v:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_insert_pre #hash_size mt v
[@ (Comment " Getting the Merkle root
@param[in] mt The Merkle tree | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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.const_mt_p -> root: MerkleTree.hash -> FStar.HyperStack.ST.ST Prims.unit | FStar.HyperStack.ST.ST | [] | [] | [
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.const_mt_p",
"MerkleTree.hash",
"MerkleTree.const_tree_hash_size",
"MerkleTree.Low.mt_get_root",
"FStar.Ghost.hide",
"MerkleTree.Low.Datastructures.hash_size_t",
"Prims.unit",
"MerkleTree.Low.__proj__MT__item__hash_size",
"MerkleTree.Low.merkle_tree",
"LowStar.Monotonic.Buffer.index",
"LowStar.ConstBuffer.qbuf_pre",
"LowStar.ConstBuffer.as_qbuf",
"LowStar.ConstBuffer.cast",
"FStar.UInt32.__uint_to_t",
"MerkleTree.pf",
"MerkleTree.pt"
] | [] | false | true | false | false | false | let mt_get_root (#h: HS.mem) (mt: const_mt_p) (root: hash #(const_tree_hash_size #h mt))
: HST.ST unit pf pt =
| let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root #hash_size mt root | false |
MerkleTree.fsti | MerkleTree.mt_insert | val mt_insert (#h: HS.mem) (mt: mt_p) (v: hash #(tree_hash_size #h mt)) : HST.ST unit pf pt | val mt_insert (#h: HS.mem) (mt: mt_p) (v: hash #(tree_hash_size #h mt)) : HST.ST unit pf pt | let mt_insert
(#h:HS.mem)
(mt:mt_p)
(v:hash #(tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index mt 0ul) in
MTNL.mt_insert hash_size mt v | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 31,
"end_line": 141,
"start_col": 0,
"start_line": 135
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r
[@ (Comment " Destructor for hashes") "c_inline"]
let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h
[@ (Comment " Constructor for paths") "c_inline"]
let mt_init_path (hash_size:hash_size_t) (mtr:HH.rid) (r:HST.erid): HST.ST path_p pf pt = MTNL.init_path hash_size mtr r
[@ (Comment " Destructor for paths") "c_inline"]
let mt_free_path (path:path_p): HST.ST unit pf pt = MTNL.free_path path
[@ (Comment " Length of a path
@param[in] p Path
return The length of the path") "c_inline"]
let mt_get_path_length (mtr:HH.rid) (path:const_path_p): HST.ST U32.t pf pt = MTNL.mt_get_path_length mtr path
[@ (Comment " Insert hash into path
@param[in] p Path
@param[in] hash Hash to insert") "c_inline"]
let mt_path_insert
(#h:HS.mem)
(#mtr:HH.rid)
(path:path_p)
(hash:hash #(MTNL.Path?.hash_size (B.get h path 0)))
: HST.ST unit pf pt
= let hash_size = MTNL.Path?.hash_size (B.index path 0ul) in
MTNL.mt_path_insert #hash_size mtr path hash
inline_for_extraction
let path_hash_size (#h:HS.mem) (path:path_p) = MTNL.Path?.hash_size (B.get h path 0)
inline_for_extraction
let const_path_hash_size (#h:HS.mem) (path:const_path_p) = path_hash_size #h (CB.cast path)
inline_for_extraction
let tree_hash_size (#h:HS.mem) (mt:mt_p) = MTNL.MT?.hash_size (B.get h mt 0)
inline_for_extraction
let const_tree_hash_size (#h:HS.mem) (mt:const_mt_p) = tree_hash_size #h (CB.cast mt)
[@ (Comment " Get step on a path
@param[in] p Path
@param[in] i Path step index
return The hash at step i of p") "c_inline"]
let mt_get_path_step
(#h:HS.mem)
(#mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST (hash #(const_path_hash_size #h path)) pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step #hash_size mtr path i
[@ (Comment " Precondition predicate for mt_get_path_step") "c_inline"]
let mt_get_path_step_pre
(#h:HS.mem)
(mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST bool pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step_pre #hash_size mtr path i
[@ (Comment " Construction with custom hash functions
@param[in] hash_size Hash size (in bytes)
@param[in] i The initial hash
return The new Merkle tree") "c_inline"]
let mt_create_custom
(hash_size:hash_size_t)
(hash_spec:Ghost.erased (MTS.hash_fun_t #(U32.v hash_size)))
(r:HST.erid)
(i:hash #hash_size)
(hash_fun:MTNLHF.hash_fun_t #hash_size #hash_spec)
: HST.ST mt_p pf pt
= MTNL.mt_create_custom hash_size hash_spec r i hash_fun
[@ (Comment " Destruction
@param[in] mt The Merkle tree") "c_inline"]
let mt_free (mt:mt_p): HST.ST unit pf pt = MTNL.mt_free mt
[@ (Comment " Insertion
@param[in] mt The Merkle tree
@param[in] v The tree does not take ownership of the hash, it makes a copy of its content. | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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.mt_p -> v: MerkleTree.hash -> FStar.HyperStack.ST.ST Prims.unit | FStar.HyperStack.ST.ST | [] | [] | [
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.mt_p",
"MerkleTree.hash",
"MerkleTree.tree_hash_size",
"MerkleTree.Low.mt_insert",
"FStar.Ghost.hide",
"MerkleTree.Low.Datastructures.hash_size_t",
"Prims.unit",
"MerkleTree.Low.__proj__MT__item__hash_size",
"MerkleTree.Low.merkle_tree",
"LowStar.Monotonic.Buffer.index",
"LowStar.Buffer.trivial_preorder",
"FStar.UInt32.__uint_to_t",
"MerkleTree.pf",
"MerkleTree.pt"
] | [] | false | true | false | false | false | let mt_insert (#h: HS.mem) (mt: mt_p) (v: hash #(tree_hash_size #h mt)) : HST.ST unit pf pt =
| let hash_size = MTNL.MT?.hash_size (B.index mt 0ul) in
MTNL.mt_insert hash_size mt v | false |
Vale.X64.InsSha.fsti | Vale.X64.InsSha.va_quick_SHA256_msg1 | val va_quick_SHA256_msg1 (dst src: va_operand_xmm) (t: counter) (block: block_w)
: (va_quickCode unit (va_code_SHA256_msg1 dst src)) | val va_quick_SHA256_msg1 (dst src: va_operand_xmm) (t: counter) (block: block_w)
: (va_quickCode unit (va_code_SHA256_msg1 dst src)) | let va_quick_SHA256_msg1 (dst:va_operand_xmm) (src:va_operand_xmm) (t:counter) (block:block_w) :
(va_quickCode unit (va_code_SHA256_msg1 dst src)) =
(va_QProc (va_code_SHA256_msg1 dst src) ([va_mod_xmm dst]) (va_wp_SHA256_msg1 dst src t block)
(va_wpProof_SHA256_msg1 dst src t block)) | {
"file_name": "obj/Vale.X64.InsSha.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 45,
"end_line": 96,
"start_col": 0,
"start_line": 93
} | module Vale.X64.InsSha
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Spec.SHA2
open Spec.Hash.Definitions
open Vale.SHA.SHA_helpers
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.QuickCode
open Vale.X64.InsVector
open FStar.UInt32
open FStar.Seq
open Spec.Loops
open Vale.X64.CPU_Features_s
//-- SHA256_rnds2
val va_code_SHA256_rnds2 : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code
val va_codegen_success_SHA256_rnds2 : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool
val va_lemma_SHA256_rnds2 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> t:counter -> block:block_w -> hash_orig:hash256
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_SHA256_rnds2 dst src) va_s0 /\ va_is_dst_xmm dst va_s0
/\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\ t + 1 < size_k_w_256 /\
(va_get_xmm 0 va_s0).lo0 == add_wrap (word_to_nat32 (index k t)) (ws_opaque block t) /\
(va_get_xmm 0 va_s0).lo1 == add_wrap (word_to_nat32 (index k (t + 1))) (ws_opaque block (t +
1)) /\ make_hash (va_eval_xmm va_s0 src) (va_eval_xmm va_s0 dst) == repeat_range 0 t
(shuffle_core_opaque block) hash_orig))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
make_hash (va_eval_xmm va_sM dst) (va_eval_xmm va_s0 src) == repeat_range 0 (t + 2)
(shuffle_core_opaque block) hash_orig /\ va_state_eq va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0))))
[@ va_qattr]
let va_wp_SHA256_rnds2 (dst:va_operand_xmm) (src:va_operand_xmm) (t:counter) (block:block_w)
(hash_orig:hash256) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\ t + 1 <
size_k_w_256 /\ (va_get_xmm 0 va_s0).lo0 == add_wrap (word_to_nat32 (index k t)) (ws_opaque
block t) /\ (va_get_xmm 0 va_s0).lo1 == add_wrap (word_to_nat32 (index k (t + 1))) (ws_opaque
block (t + 1)) /\ make_hash (va_eval_xmm va_s0 src) (va_eval_xmm va_s0 dst) == repeat_range 0 t
(shuffle_core_opaque block) hash_orig /\ (forall (va_x_dst:va_value_xmm) . let va_sM =
va_upd_operand_xmm dst va_x_dst va_s0 in va_get_ok va_sM /\ make_hash (va_eval_xmm va_sM dst)
(va_eval_xmm va_s0 src) == repeat_range 0 (t + 2) (shuffle_core_opaque block) hash_orig ==>
va_k va_sM (())))
val va_wpProof_SHA256_rnds2 : dst:va_operand_xmm -> src:va_operand_xmm -> t:counter ->
block:block_w -> hash_orig:hash256 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_SHA256_rnds2 dst src t block hash_orig va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_SHA256_rnds2 dst src) ([va_mod_xmm
dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_SHA256_rnds2 (dst:va_operand_xmm) (src:va_operand_xmm) (t:counter) (block:block_w)
(hash_orig:hash256) : (va_quickCode unit (va_code_SHA256_rnds2 dst src)) =
(va_QProc (va_code_SHA256_rnds2 dst src) ([va_mod_xmm dst]) (va_wp_SHA256_rnds2 dst src t block
hash_orig) (va_wpProof_SHA256_rnds2 dst src t block hash_orig))
//--
//-- SHA256_msg1
val va_code_SHA256_msg1 : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code
val va_codegen_success_SHA256_msg1 : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool
val va_lemma_SHA256_msg1 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> t:counter -> block:block_w
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_SHA256_msg1 dst src) va_s0 /\ va_is_dst_xmm dst va_s0
/\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\ ((16 <= t && t < size_k_w_256))
/\ va_eval_xmm va_s0 dst == ws_quad32 (t - 16) block /\ (va_eval_xmm va_s0 src).lo0 ==
ws_opaque block (t - 12)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == ws_partial t block /\ va_state_eq va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0))))
[@ va_qattr]
let va_wp_SHA256_msg1 (dst:va_operand_xmm) (src:va_operand_xmm) (t:counter) (block:block_w)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\ ((16 <=
t && t < size_k_w_256)) /\ va_eval_xmm va_s0 dst == ws_quad32 (t - 16) block /\ (va_eval_xmm
va_s0 src).lo0 == ws_opaque block (t - 12) /\ (forall (va_x_dst:va_value_xmm) . let va_sM =
va_upd_operand_xmm dst va_x_dst va_s0 in va_get_ok va_sM /\ va_eval_xmm va_sM dst == ws_partial
t block ==> va_k va_sM (())))
val va_wpProof_SHA256_msg1 : dst:va_operand_xmm -> src:va_operand_xmm -> t:counter -> block:block_w
-> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_SHA256_msg1 dst src t block va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_SHA256_msg1 dst src) ([va_mod_xmm
dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.InsVector.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.SHA.SHA_helpers.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.fsti.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.InsSha.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Loops",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"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 |
dst: Vale.X64.Decls.va_operand_xmm ->
src: Vale.X64.Decls.va_operand_xmm ->
t: Vale.SHA.SHA_helpers.counter ->
block: Vale.SHA.SHA_helpers.block_w
-> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.X64.InsSha.va_code_SHA256_msg1 dst src) | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Decls.va_operand_xmm",
"Vale.SHA.SHA_helpers.counter",
"Vale.SHA.SHA_helpers.block_w",
"Vale.X64.QuickCode.va_QProc",
"Prims.unit",
"Vale.X64.InsSha.va_code_SHA256_msg1",
"Prims.Cons",
"Vale.X64.QuickCode.mod_t",
"Vale.X64.QuickCode.va_mod_xmm",
"Prims.Nil",
"Vale.X64.InsSha.va_wp_SHA256_msg1",
"Vale.X64.InsSha.va_wpProof_SHA256_msg1",
"Vale.X64.QuickCode.va_quickCode"
] | [] | false | false | false | false | false | let va_quick_SHA256_msg1 (dst src: va_operand_xmm) (t: counter) (block: block_w)
: (va_quickCode unit (va_code_SHA256_msg1 dst src)) =
| (va_QProc (va_code_SHA256_msg1 dst src)
([va_mod_xmm dst])
(va_wp_SHA256_msg1 dst src t block)
(va_wpProof_SHA256_msg1 dst src t block)) | false |
MerkleTree.fsti | MerkleTree.mt_insert_pre | val mt_insert_pre (#h: HS.mem) (mt: const_mt_p) (v: hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt | val mt_insert_pre (#h: HS.mem) (mt: const_mt_p) (v: hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt | let mt_insert_pre
(#h:HS.mem)
(mt:const_mt_p)
(v:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_insert_pre #hash_size mt v | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 36,
"end_line": 150,
"start_col": 0,
"start_line": 144
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r
[@ (Comment " Destructor for hashes") "c_inline"]
let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h
[@ (Comment " Constructor for paths") "c_inline"]
let mt_init_path (hash_size:hash_size_t) (mtr:HH.rid) (r:HST.erid): HST.ST path_p pf pt = MTNL.init_path hash_size mtr r
[@ (Comment " Destructor for paths") "c_inline"]
let mt_free_path (path:path_p): HST.ST unit pf pt = MTNL.free_path path
[@ (Comment " Length of a path
@param[in] p Path
return The length of the path") "c_inline"]
let mt_get_path_length (mtr:HH.rid) (path:const_path_p): HST.ST U32.t pf pt = MTNL.mt_get_path_length mtr path
[@ (Comment " Insert hash into path
@param[in] p Path
@param[in] hash Hash to insert") "c_inline"]
let mt_path_insert
(#h:HS.mem)
(#mtr:HH.rid)
(path:path_p)
(hash:hash #(MTNL.Path?.hash_size (B.get h path 0)))
: HST.ST unit pf pt
= let hash_size = MTNL.Path?.hash_size (B.index path 0ul) in
MTNL.mt_path_insert #hash_size mtr path hash
inline_for_extraction
let path_hash_size (#h:HS.mem) (path:path_p) = MTNL.Path?.hash_size (B.get h path 0)
inline_for_extraction
let const_path_hash_size (#h:HS.mem) (path:const_path_p) = path_hash_size #h (CB.cast path)
inline_for_extraction
let tree_hash_size (#h:HS.mem) (mt:mt_p) = MTNL.MT?.hash_size (B.get h mt 0)
inline_for_extraction
let const_tree_hash_size (#h:HS.mem) (mt:const_mt_p) = tree_hash_size #h (CB.cast mt)
[@ (Comment " Get step on a path
@param[in] p Path
@param[in] i Path step index
return The hash at step i of p") "c_inline"]
let mt_get_path_step
(#h:HS.mem)
(#mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST (hash #(const_path_hash_size #h path)) pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step #hash_size mtr path i
[@ (Comment " Precondition predicate for mt_get_path_step") "c_inline"]
let mt_get_path_step_pre
(#h:HS.mem)
(mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST bool pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step_pre #hash_size mtr path i
[@ (Comment " Construction with custom hash functions
@param[in] hash_size Hash size (in bytes)
@param[in] i The initial hash
return The new Merkle tree") "c_inline"]
let mt_create_custom
(hash_size:hash_size_t)
(hash_spec:Ghost.erased (MTS.hash_fun_t #(U32.v hash_size)))
(r:HST.erid)
(i:hash #hash_size)
(hash_fun:MTNLHF.hash_fun_t #hash_size #hash_spec)
: HST.ST mt_p pf pt
= MTNL.mt_create_custom hash_size hash_spec r i hash_fun
[@ (Comment " Destruction
@param[in] mt The Merkle tree") "c_inline"]
let mt_free (mt:mt_p): HST.ST unit pf pt = MTNL.mt_free mt
[@ (Comment " Insertion
@param[in] mt The Merkle tree
@param[in] v The tree does not take ownership of the hash, it makes a copy of its content.
Note: The content of the hash will be overwritten with an arbitrary value.") "c_inline"]
let mt_insert
(#h:HS.mem)
(mt:mt_p)
(v:hash #(tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index mt 0ul) in
MTNL.mt_insert hash_size mt v | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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.const_mt_p -> v: MerkleTree.hash -> FStar.HyperStack.ST.ST Prims.bool | FStar.HyperStack.ST.ST | [] | [] | [
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.const_mt_p",
"MerkleTree.hash",
"MerkleTree.const_tree_hash_size",
"MerkleTree.Low.mt_insert_pre",
"FStar.Ghost.hide",
"MerkleTree.Low.Datastructures.hash_size_t",
"Prims.bool",
"MerkleTree.Low.__proj__MT__item__hash_size",
"MerkleTree.Low.merkle_tree",
"LowStar.Monotonic.Buffer.index",
"LowStar.ConstBuffer.qbuf_pre",
"LowStar.ConstBuffer.as_qbuf",
"LowStar.ConstBuffer.cast",
"FStar.UInt32.__uint_to_t",
"MerkleTree.pf",
"MerkleTree.pt"
] | [] | false | true | false | false | false | let mt_insert_pre (#h: HS.mem) (mt: const_mt_p) (v: hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt =
| let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_insert_pre #hash_size mt v | false |
MerkleTree.fsti | MerkleTree.mt_flush | val mt_flush (mt: mt_p) : HST.ST unit pf pt | val mt_flush (mt: mt_p) : HST.ST unit pf pt | let mt_flush (mt:mt_p): HST.ST unit pf pt = MTNL.mt_flush mt | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 60,
"end_line": 214,
"start_col": 0,
"start_line": 214
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r
[@ (Comment " Destructor for hashes") "c_inline"]
let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h
[@ (Comment " Constructor for paths") "c_inline"]
let mt_init_path (hash_size:hash_size_t) (mtr:HH.rid) (r:HST.erid): HST.ST path_p pf pt = MTNL.init_path hash_size mtr r
[@ (Comment " Destructor for paths") "c_inline"]
let mt_free_path (path:path_p): HST.ST unit pf pt = MTNL.free_path path
[@ (Comment " Length of a path
@param[in] p Path
return The length of the path") "c_inline"]
let mt_get_path_length (mtr:HH.rid) (path:const_path_p): HST.ST U32.t pf pt = MTNL.mt_get_path_length mtr path
[@ (Comment " Insert hash into path
@param[in] p Path
@param[in] hash Hash to insert") "c_inline"]
let mt_path_insert
(#h:HS.mem)
(#mtr:HH.rid)
(path:path_p)
(hash:hash #(MTNL.Path?.hash_size (B.get h path 0)))
: HST.ST unit pf pt
= let hash_size = MTNL.Path?.hash_size (B.index path 0ul) in
MTNL.mt_path_insert #hash_size mtr path hash
inline_for_extraction
let path_hash_size (#h:HS.mem) (path:path_p) = MTNL.Path?.hash_size (B.get h path 0)
inline_for_extraction
let const_path_hash_size (#h:HS.mem) (path:const_path_p) = path_hash_size #h (CB.cast path)
inline_for_extraction
let tree_hash_size (#h:HS.mem) (mt:mt_p) = MTNL.MT?.hash_size (B.get h mt 0)
inline_for_extraction
let const_tree_hash_size (#h:HS.mem) (mt:const_mt_p) = tree_hash_size #h (CB.cast mt)
[@ (Comment " Get step on a path
@param[in] p Path
@param[in] i Path step index
return The hash at step i of p") "c_inline"]
let mt_get_path_step
(#h:HS.mem)
(#mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST (hash #(const_path_hash_size #h path)) pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step #hash_size mtr path i
[@ (Comment " Precondition predicate for mt_get_path_step") "c_inline"]
let mt_get_path_step_pre
(#h:HS.mem)
(mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST bool pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step_pre #hash_size mtr path i
[@ (Comment " Construction with custom hash functions
@param[in] hash_size Hash size (in bytes)
@param[in] i The initial hash
return The new Merkle tree") "c_inline"]
let mt_create_custom
(hash_size:hash_size_t)
(hash_spec:Ghost.erased (MTS.hash_fun_t #(U32.v hash_size)))
(r:HST.erid)
(i:hash #hash_size)
(hash_fun:MTNLHF.hash_fun_t #hash_size #hash_spec)
: HST.ST mt_p pf pt
= MTNL.mt_create_custom hash_size hash_spec r i hash_fun
[@ (Comment " Destruction
@param[in] mt The Merkle tree") "c_inline"]
let mt_free (mt:mt_p): HST.ST unit pf pt = MTNL.mt_free mt
[@ (Comment " Insertion
@param[in] mt The Merkle tree
@param[in] v The tree does not take ownership of the hash, it makes a copy of its content.
Note: The content of the hash will be overwritten with an arbitrary value.") "c_inline"]
let mt_insert
(#h:HS.mem)
(mt:mt_p)
(v:hash #(tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index mt 0ul) in
MTNL.mt_insert hash_size mt v
[@ (Comment " Precondition predicate for mt_insert") "c_inline"]
let mt_insert_pre
(#h:HS.mem)
(mt:const_mt_p)
(v:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_insert_pre #hash_size mt v
[@ (Comment " Getting the Merkle root
@param[in] mt The Merkle tree
@param[out] root The Merkle root") "c_inline"]
let mt_get_root
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root #hash_size mt root
[@ (Comment " Precondition predicate for mt_get_root") "c_inline"]
let mt_get_root_pre
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root_pre #hash_size mt root
[@ (Comment " Getting a Merkle path
@param[in] mt The Merkle tree
@param[in] idx The index of the target hash
@param[out] path A resulting Merkle path that contains the leaf hash.
@param[out] root The Merkle root
return The number of elements in the tree
Notes:
- The resulting path contains pointers to hashes in the tree, not copies of
the hash values.
- idx must be within the currently held indices in the tree (past the
last flush index).") "c_inline"]
let mt_get_path
(#h:HS.mem)
(mt:const_mt_p)
(idx:offset_t)
(path:path_p{path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(path_hash_size #h path))
: HST.ST index_t pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_path #hash_size mt idx path root
[@ (Comment " Precondition predicate for mt_get_path") "c_inline"]
let mt_get_path_pre
(#h:HS.mem)
(mt:const_mt_p)
(idx:offset_t)
(path:const_path_p{const_path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(const_path_hash_size #h path))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_path_pre #hash_size mt idx path root
[@ (Comment " Flush the Merkle tree | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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.mt_p -> FStar.HyperStack.ST.ST Prims.unit | FStar.HyperStack.ST.ST | [] | [] | [
"MerkleTree.mt_p",
"MerkleTree.Low.mt_flush",
"Prims.unit",
"MerkleTree.pf",
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.pt"
] | [] | false | true | false | false | false | let mt_flush (mt: mt_p) : HST.ST unit pf pt =
| MTNL.mt_flush mt | false |
MerkleTree.fsti | MerkleTree.mt_flush_pre | val mt_flush_pre (mt: const_mt_p) : HST.ST bool pf pt | val mt_flush_pre (mt: const_mt_p) : HST.ST bool pf pt | let mt_flush_pre (mt:const_mt_p): HST.ST bool pf pt = MTNL.mt_flush_pre mt | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 74,
"end_line": 217,
"start_col": 0,
"start_line": 217
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r
[@ (Comment " Destructor for hashes") "c_inline"]
let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h
[@ (Comment " Constructor for paths") "c_inline"]
let mt_init_path (hash_size:hash_size_t) (mtr:HH.rid) (r:HST.erid): HST.ST path_p pf pt = MTNL.init_path hash_size mtr r
[@ (Comment " Destructor for paths") "c_inline"]
let mt_free_path (path:path_p): HST.ST unit pf pt = MTNL.free_path path
[@ (Comment " Length of a path
@param[in] p Path
return The length of the path") "c_inline"]
let mt_get_path_length (mtr:HH.rid) (path:const_path_p): HST.ST U32.t pf pt = MTNL.mt_get_path_length mtr path
[@ (Comment " Insert hash into path
@param[in] p Path
@param[in] hash Hash to insert") "c_inline"]
let mt_path_insert
(#h:HS.mem)
(#mtr:HH.rid)
(path:path_p)
(hash:hash #(MTNL.Path?.hash_size (B.get h path 0)))
: HST.ST unit pf pt
= let hash_size = MTNL.Path?.hash_size (B.index path 0ul) in
MTNL.mt_path_insert #hash_size mtr path hash
inline_for_extraction
let path_hash_size (#h:HS.mem) (path:path_p) = MTNL.Path?.hash_size (B.get h path 0)
inline_for_extraction
let const_path_hash_size (#h:HS.mem) (path:const_path_p) = path_hash_size #h (CB.cast path)
inline_for_extraction
let tree_hash_size (#h:HS.mem) (mt:mt_p) = MTNL.MT?.hash_size (B.get h mt 0)
inline_for_extraction
let const_tree_hash_size (#h:HS.mem) (mt:const_mt_p) = tree_hash_size #h (CB.cast mt)
[@ (Comment " Get step on a path
@param[in] p Path
@param[in] i Path step index
return The hash at step i of p") "c_inline"]
let mt_get_path_step
(#h:HS.mem)
(#mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST (hash #(const_path_hash_size #h path)) pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step #hash_size mtr path i
[@ (Comment " Precondition predicate for mt_get_path_step") "c_inline"]
let mt_get_path_step_pre
(#h:HS.mem)
(mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST bool pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step_pre #hash_size mtr path i
[@ (Comment " Construction with custom hash functions
@param[in] hash_size Hash size (in bytes)
@param[in] i The initial hash
return The new Merkle tree") "c_inline"]
let mt_create_custom
(hash_size:hash_size_t)
(hash_spec:Ghost.erased (MTS.hash_fun_t #(U32.v hash_size)))
(r:HST.erid)
(i:hash #hash_size)
(hash_fun:MTNLHF.hash_fun_t #hash_size #hash_spec)
: HST.ST mt_p pf pt
= MTNL.mt_create_custom hash_size hash_spec r i hash_fun
[@ (Comment " Destruction
@param[in] mt The Merkle tree") "c_inline"]
let mt_free (mt:mt_p): HST.ST unit pf pt = MTNL.mt_free mt
[@ (Comment " Insertion
@param[in] mt The Merkle tree
@param[in] v The tree does not take ownership of the hash, it makes a copy of its content.
Note: The content of the hash will be overwritten with an arbitrary value.") "c_inline"]
let mt_insert
(#h:HS.mem)
(mt:mt_p)
(v:hash #(tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index mt 0ul) in
MTNL.mt_insert hash_size mt v
[@ (Comment " Precondition predicate for mt_insert") "c_inline"]
let mt_insert_pre
(#h:HS.mem)
(mt:const_mt_p)
(v:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_insert_pre #hash_size mt v
[@ (Comment " Getting the Merkle root
@param[in] mt The Merkle tree
@param[out] root The Merkle root") "c_inline"]
let mt_get_root
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root #hash_size mt root
[@ (Comment " Precondition predicate for mt_get_root") "c_inline"]
let mt_get_root_pre
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root_pre #hash_size mt root
[@ (Comment " Getting a Merkle path
@param[in] mt The Merkle tree
@param[in] idx The index of the target hash
@param[out] path A resulting Merkle path that contains the leaf hash.
@param[out] root The Merkle root
return The number of elements in the tree
Notes:
- The resulting path contains pointers to hashes in the tree, not copies of
the hash values.
- idx must be within the currently held indices in the tree (past the
last flush index).") "c_inline"]
let mt_get_path
(#h:HS.mem)
(mt:const_mt_p)
(idx:offset_t)
(path:path_p{path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(path_hash_size #h path))
: HST.ST index_t pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_path #hash_size mt idx path root
[@ (Comment " Precondition predicate for mt_get_path") "c_inline"]
let mt_get_path_pre
(#h:HS.mem)
(mt:const_mt_p)
(idx:offset_t)
(path:const_path_p{const_path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(const_path_hash_size #h path))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_path_pre #hash_size mt idx path root
[@ (Comment " Flush the Merkle tree
@param[in] mt The Merkle tree") "c_inline"]
let mt_flush (mt:mt_p): HST.ST unit pf pt = MTNL.mt_flush mt | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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.const_mt_p -> FStar.HyperStack.ST.ST Prims.bool | FStar.HyperStack.ST.ST | [] | [] | [
"MerkleTree.const_mt_p",
"MerkleTree.Low.mt_flush_pre",
"Prims.bool",
"MerkleTree.pf",
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.pt"
] | [] | false | true | false | false | false | let mt_flush_pre (mt: const_mt_p) : HST.ST bool pf pt =
| MTNL.mt_flush_pre mt | false |
MerkleTree.fsti | MerkleTree.mt_flush_to | val mt_flush_to (mt: mt_p) (idx: offset_t) : HST.ST unit pf pt | val mt_flush_to (mt: mt_p) (idx: offset_t) : HST.ST unit pf pt | let mt_flush_to (mt:mt_p) (idx:offset_t): HST.ST unit pf pt = MTNL.mt_flush_to mt idx | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 85,
"end_line": 224,
"start_col": 0,
"start_line": 224
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r
[@ (Comment " Destructor for hashes") "c_inline"]
let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h
[@ (Comment " Constructor for paths") "c_inline"]
let mt_init_path (hash_size:hash_size_t) (mtr:HH.rid) (r:HST.erid): HST.ST path_p pf pt = MTNL.init_path hash_size mtr r
[@ (Comment " Destructor for paths") "c_inline"]
let mt_free_path (path:path_p): HST.ST unit pf pt = MTNL.free_path path
[@ (Comment " Length of a path
@param[in] p Path
return The length of the path") "c_inline"]
let mt_get_path_length (mtr:HH.rid) (path:const_path_p): HST.ST U32.t pf pt = MTNL.mt_get_path_length mtr path
[@ (Comment " Insert hash into path
@param[in] p Path
@param[in] hash Hash to insert") "c_inline"]
let mt_path_insert
(#h:HS.mem)
(#mtr:HH.rid)
(path:path_p)
(hash:hash #(MTNL.Path?.hash_size (B.get h path 0)))
: HST.ST unit pf pt
= let hash_size = MTNL.Path?.hash_size (B.index path 0ul) in
MTNL.mt_path_insert #hash_size mtr path hash
inline_for_extraction
let path_hash_size (#h:HS.mem) (path:path_p) = MTNL.Path?.hash_size (B.get h path 0)
inline_for_extraction
let const_path_hash_size (#h:HS.mem) (path:const_path_p) = path_hash_size #h (CB.cast path)
inline_for_extraction
let tree_hash_size (#h:HS.mem) (mt:mt_p) = MTNL.MT?.hash_size (B.get h mt 0)
inline_for_extraction
let const_tree_hash_size (#h:HS.mem) (mt:const_mt_p) = tree_hash_size #h (CB.cast mt)
[@ (Comment " Get step on a path
@param[in] p Path
@param[in] i Path step index
return The hash at step i of p") "c_inline"]
let mt_get_path_step
(#h:HS.mem)
(#mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST (hash #(const_path_hash_size #h path)) pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step #hash_size mtr path i
[@ (Comment " Precondition predicate for mt_get_path_step") "c_inline"]
let mt_get_path_step_pre
(#h:HS.mem)
(mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST bool pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step_pre #hash_size mtr path i
[@ (Comment " Construction with custom hash functions
@param[in] hash_size Hash size (in bytes)
@param[in] i The initial hash
return The new Merkle tree") "c_inline"]
let mt_create_custom
(hash_size:hash_size_t)
(hash_spec:Ghost.erased (MTS.hash_fun_t #(U32.v hash_size)))
(r:HST.erid)
(i:hash #hash_size)
(hash_fun:MTNLHF.hash_fun_t #hash_size #hash_spec)
: HST.ST mt_p pf pt
= MTNL.mt_create_custom hash_size hash_spec r i hash_fun
[@ (Comment " Destruction
@param[in] mt The Merkle tree") "c_inline"]
let mt_free (mt:mt_p): HST.ST unit pf pt = MTNL.mt_free mt
[@ (Comment " Insertion
@param[in] mt The Merkle tree
@param[in] v The tree does not take ownership of the hash, it makes a copy of its content.
Note: The content of the hash will be overwritten with an arbitrary value.") "c_inline"]
let mt_insert
(#h:HS.mem)
(mt:mt_p)
(v:hash #(tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index mt 0ul) in
MTNL.mt_insert hash_size mt v
[@ (Comment " Precondition predicate for mt_insert") "c_inline"]
let mt_insert_pre
(#h:HS.mem)
(mt:const_mt_p)
(v:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_insert_pre #hash_size mt v
[@ (Comment " Getting the Merkle root
@param[in] mt The Merkle tree
@param[out] root The Merkle root") "c_inline"]
let mt_get_root
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root #hash_size mt root
[@ (Comment " Precondition predicate for mt_get_root") "c_inline"]
let mt_get_root_pre
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root_pre #hash_size mt root
[@ (Comment " Getting a Merkle path
@param[in] mt The Merkle tree
@param[in] idx The index of the target hash
@param[out] path A resulting Merkle path that contains the leaf hash.
@param[out] root The Merkle root
return The number of elements in the tree
Notes:
- The resulting path contains pointers to hashes in the tree, not copies of
the hash values.
- idx must be within the currently held indices in the tree (past the
last flush index).") "c_inline"]
let mt_get_path
(#h:HS.mem)
(mt:const_mt_p)
(idx:offset_t)
(path:path_p{path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(path_hash_size #h path))
: HST.ST index_t pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_path #hash_size mt idx path root
[@ (Comment " Precondition predicate for mt_get_path") "c_inline"]
let mt_get_path_pre
(#h:HS.mem)
(mt:const_mt_p)
(idx:offset_t)
(path:const_path_p{const_path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(const_path_hash_size #h path))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_path_pre #hash_size mt idx path root
[@ (Comment " Flush the Merkle tree
@param[in] mt The Merkle tree") "c_inline"]
let mt_flush (mt:mt_p): HST.ST unit pf pt = MTNL.mt_flush mt
[@ (Comment " Precondition predicate for mt_flush") "c_inline"]
let mt_flush_pre (mt:const_mt_p): HST.ST bool pf pt = MTNL.mt_flush_pre mt
[@ (Comment " Flush the Merkle tree up to a given index
@param[in] mt The Merkle tree | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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.mt_p -> idx: MerkleTree.offset_t -> FStar.HyperStack.ST.ST Prims.unit | FStar.HyperStack.ST.ST | [] | [] | [
"MerkleTree.mt_p",
"MerkleTree.offset_t",
"MerkleTree.Low.mt_flush_to",
"Prims.unit",
"MerkleTree.pf",
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.pt"
] | [] | false | true | false | false | false | let mt_flush_to (mt: mt_p) (idx: offset_t) : HST.ST unit pf pt =
| MTNL.mt_flush_to mt idx | false |
MerkleTree.fsti | MerkleTree.mt_flush_to_pre | val mt_flush_to_pre (mt: const_mt_p) (idx: offset_t) : HST.ST bool pf pt | val mt_flush_to_pre (mt: const_mt_p) (idx: offset_t) : HST.ST bool pf pt | let mt_flush_to_pre (mt:const_mt_p) (idx:offset_t): HST.ST bool pf pt = MTNL.mt_flush_to_pre mt idx | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 99,
"end_line": 227,
"start_col": 0,
"start_line": 227
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r
[@ (Comment " Destructor for hashes") "c_inline"]
let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h
[@ (Comment " Constructor for paths") "c_inline"]
let mt_init_path (hash_size:hash_size_t) (mtr:HH.rid) (r:HST.erid): HST.ST path_p pf pt = MTNL.init_path hash_size mtr r
[@ (Comment " Destructor for paths") "c_inline"]
let mt_free_path (path:path_p): HST.ST unit pf pt = MTNL.free_path path
[@ (Comment " Length of a path
@param[in] p Path
return The length of the path") "c_inline"]
let mt_get_path_length (mtr:HH.rid) (path:const_path_p): HST.ST U32.t pf pt = MTNL.mt_get_path_length mtr path
[@ (Comment " Insert hash into path
@param[in] p Path
@param[in] hash Hash to insert") "c_inline"]
let mt_path_insert
(#h:HS.mem)
(#mtr:HH.rid)
(path:path_p)
(hash:hash #(MTNL.Path?.hash_size (B.get h path 0)))
: HST.ST unit pf pt
= let hash_size = MTNL.Path?.hash_size (B.index path 0ul) in
MTNL.mt_path_insert #hash_size mtr path hash
inline_for_extraction
let path_hash_size (#h:HS.mem) (path:path_p) = MTNL.Path?.hash_size (B.get h path 0)
inline_for_extraction
let const_path_hash_size (#h:HS.mem) (path:const_path_p) = path_hash_size #h (CB.cast path)
inline_for_extraction
let tree_hash_size (#h:HS.mem) (mt:mt_p) = MTNL.MT?.hash_size (B.get h mt 0)
inline_for_extraction
let const_tree_hash_size (#h:HS.mem) (mt:const_mt_p) = tree_hash_size #h (CB.cast mt)
[@ (Comment " Get step on a path
@param[in] p Path
@param[in] i Path step index
return The hash at step i of p") "c_inline"]
let mt_get_path_step
(#h:HS.mem)
(#mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST (hash #(const_path_hash_size #h path)) pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step #hash_size mtr path i
[@ (Comment " Precondition predicate for mt_get_path_step") "c_inline"]
let mt_get_path_step_pre
(#h:HS.mem)
(mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST bool pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step_pre #hash_size mtr path i
[@ (Comment " Construction with custom hash functions
@param[in] hash_size Hash size (in bytes)
@param[in] i The initial hash
return The new Merkle tree") "c_inline"]
let mt_create_custom
(hash_size:hash_size_t)
(hash_spec:Ghost.erased (MTS.hash_fun_t #(U32.v hash_size)))
(r:HST.erid)
(i:hash #hash_size)
(hash_fun:MTNLHF.hash_fun_t #hash_size #hash_spec)
: HST.ST mt_p pf pt
= MTNL.mt_create_custom hash_size hash_spec r i hash_fun
[@ (Comment " Destruction
@param[in] mt The Merkle tree") "c_inline"]
let mt_free (mt:mt_p): HST.ST unit pf pt = MTNL.mt_free mt
[@ (Comment " Insertion
@param[in] mt The Merkle tree
@param[in] v The tree does not take ownership of the hash, it makes a copy of its content.
Note: The content of the hash will be overwritten with an arbitrary value.") "c_inline"]
let mt_insert
(#h:HS.mem)
(mt:mt_p)
(v:hash #(tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index mt 0ul) in
MTNL.mt_insert hash_size mt v
[@ (Comment " Precondition predicate for mt_insert") "c_inline"]
let mt_insert_pre
(#h:HS.mem)
(mt:const_mt_p)
(v:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_insert_pre #hash_size mt v
[@ (Comment " Getting the Merkle root
@param[in] mt The Merkle tree
@param[out] root The Merkle root") "c_inline"]
let mt_get_root
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root #hash_size mt root
[@ (Comment " Precondition predicate for mt_get_root") "c_inline"]
let mt_get_root_pre
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root_pre #hash_size mt root
[@ (Comment " Getting a Merkle path
@param[in] mt The Merkle tree
@param[in] idx The index of the target hash
@param[out] path A resulting Merkle path that contains the leaf hash.
@param[out] root The Merkle root
return The number of elements in the tree
Notes:
- The resulting path contains pointers to hashes in the tree, not copies of
the hash values.
- idx must be within the currently held indices in the tree (past the
last flush index).") "c_inline"]
let mt_get_path
(#h:HS.mem)
(mt:const_mt_p)
(idx:offset_t)
(path:path_p{path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(path_hash_size #h path))
: HST.ST index_t pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_path #hash_size mt idx path root
[@ (Comment " Precondition predicate for mt_get_path") "c_inline"]
let mt_get_path_pre
(#h:HS.mem)
(mt:const_mt_p)
(idx:offset_t)
(path:const_path_p{const_path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(const_path_hash_size #h path))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_path_pre #hash_size mt idx path root
[@ (Comment " Flush the Merkle tree
@param[in] mt The Merkle tree") "c_inline"]
let mt_flush (mt:mt_p): HST.ST unit pf pt = MTNL.mt_flush mt
[@ (Comment " Precondition predicate for mt_flush") "c_inline"]
let mt_flush_pre (mt:const_mt_p): HST.ST bool pf pt = MTNL.mt_flush_pre mt
[@ (Comment " Flush the Merkle tree up to a given index
@param[in] mt The Merkle tree
@param[in] idx The index up to which to flush the tree") "c_inline"]
let mt_flush_to (mt:mt_p) (idx:offset_t): HST.ST unit pf pt = MTNL.mt_flush_to mt idx | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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.const_mt_p -> idx: MerkleTree.offset_t -> FStar.HyperStack.ST.ST Prims.bool | FStar.HyperStack.ST.ST | [] | [] | [
"MerkleTree.const_mt_p",
"MerkleTree.offset_t",
"MerkleTree.Low.mt_flush_to_pre",
"Prims.bool",
"MerkleTree.pf",
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.pt"
] | [] | false | true | false | false | false | let mt_flush_to_pre (mt: const_mt_p) (idx: offset_t) : HST.ST bool pf pt =
| MTNL.mt_flush_to_pre mt idx | false |
MerkleTree.fsti | MerkleTree.mt_get_root_pre | val mt_get_root_pre (#h: HS.mem) (mt: const_mt_p) (root: hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt | val mt_get_root_pre (#h: HS.mem) (mt: const_mt_p) (root: hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt | let mt_get_root_pre
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root_pre #hash_size mt root | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 41,
"end_line": 172,
"start_col": 0,
"start_line": 166
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r
[@ (Comment " Destructor for hashes") "c_inline"]
let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h
[@ (Comment " Constructor for paths") "c_inline"]
let mt_init_path (hash_size:hash_size_t) (mtr:HH.rid) (r:HST.erid): HST.ST path_p pf pt = MTNL.init_path hash_size mtr r
[@ (Comment " Destructor for paths") "c_inline"]
let mt_free_path (path:path_p): HST.ST unit pf pt = MTNL.free_path path
[@ (Comment " Length of a path
@param[in] p Path
return The length of the path") "c_inline"]
let mt_get_path_length (mtr:HH.rid) (path:const_path_p): HST.ST U32.t pf pt = MTNL.mt_get_path_length mtr path
[@ (Comment " Insert hash into path
@param[in] p Path
@param[in] hash Hash to insert") "c_inline"]
let mt_path_insert
(#h:HS.mem)
(#mtr:HH.rid)
(path:path_p)
(hash:hash #(MTNL.Path?.hash_size (B.get h path 0)))
: HST.ST unit pf pt
= let hash_size = MTNL.Path?.hash_size (B.index path 0ul) in
MTNL.mt_path_insert #hash_size mtr path hash
inline_for_extraction
let path_hash_size (#h:HS.mem) (path:path_p) = MTNL.Path?.hash_size (B.get h path 0)
inline_for_extraction
let const_path_hash_size (#h:HS.mem) (path:const_path_p) = path_hash_size #h (CB.cast path)
inline_for_extraction
let tree_hash_size (#h:HS.mem) (mt:mt_p) = MTNL.MT?.hash_size (B.get h mt 0)
inline_for_extraction
let const_tree_hash_size (#h:HS.mem) (mt:const_mt_p) = tree_hash_size #h (CB.cast mt)
[@ (Comment " Get step on a path
@param[in] p Path
@param[in] i Path step index
return The hash at step i of p") "c_inline"]
let mt_get_path_step
(#h:HS.mem)
(#mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST (hash #(const_path_hash_size #h path)) pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step #hash_size mtr path i
[@ (Comment " Precondition predicate for mt_get_path_step") "c_inline"]
let mt_get_path_step_pre
(#h:HS.mem)
(mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST bool pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step_pre #hash_size mtr path i
[@ (Comment " Construction with custom hash functions
@param[in] hash_size Hash size (in bytes)
@param[in] i The initial hash
return The new Merkle tree") "c_inline"]
let mt_create_custom
(hash_size:hash_size_t)
(hash_spec:Ghost.erased (MTS.hash_fun_t #(U32.v hash_size)))
(r:HST.erid)
(i:hash #hash_size)
(hash_fun:MTNLHF.hash_fun_t #hash_size #hash_spec)
: HST.ST mt_p pf pt
= MTNL.mt_create_custom hash_size hash_spec r i hash_fun
[@ (Comment " Destruction
@param[in] mt The Merkle tree") "c_inline"]
let mt_free (mt:mt_p): HST.ST unit pf pt = MTNL.mt_free mt
[@ (Comment " Insertion
@param[in] mt The Merkle tree
@param[in] v The tree does not take ownership of the hash, it makes a copy of its content.
Note: The content of the hash will be overwritten with an arbitrary value.") "c_inline"]
let mt_insert
(#h:HS.mem)
(mt:mt_p)
(v:hash #(tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index mt 0ul) in
MTNL.mt_insert hash_size mt v
[@ (Comment " Precondition predicate for mt_insert") "c_inline"]
let mt_insert_pre
(#h:HS.mem)
(mt:const_mt_p)
(v:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_insert_pre #hash_size mt v
[@ (Comment " Getting the Merkle root
@param[in] mt The Merkle tree
@param[out] root The Merkle root") "c_inline"]
let mt_get_root
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root #hash_size mt root | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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.const_mt_p -> root: MerkleTree.hash -> FStar.HyperStack.ST.ST Prims.bool | FStar.HyperStack.ST.ST | [] | [] | [
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.const_mt_p",
"MerkleTree.hash",
"MerkleTree.const_tree_hash_size",
"MerkleTree.Low.mt_get_root_pre",
"FStar.Ghost.hide",
"MerkleTree.Low.Datastructures.hash_size_t",
"Prims.bool",
"MerkleTree.Low.__proj__MT__item__hash_size",
"MerkleTree.Low.merkle_tree",
"LowStar.Monotonic.Buffer.index",
"LowStar.ConstBuffer.qbuf_pre",
"LowStar.ConstBuffer.as_qbuf",
"LowStar.ConstBuffer.cast",
"FStar.UInt32.__uint_to_t",
"MerkleTree.pf",
"MerkleTree.pt"
] | [] | false | true | false | false | false | let mt_get_root_pre (#h: HS.mem) (mt: const_mt_p) (root: hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt =
| let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root_pre #hash_size mt root | false |
MerkleTree.fsti | MerkleTree.mt_serialize_size | val mt_serialize_size (mt: const_mt_p) : HST.ST UInt64.t pf pt | val mt_serialize_size (mt: const_mt_p) : HST.ST UInt64.t pf pt | let mt_serialize_size (mt:const_mt_p): HST.ST UInt64.t pf pt = MTNLS.mt_serialize_size mt | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 89,
"end_line": 287,
"start_col": 0,
"start_line": 287
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r
[@ (Comment " Destructor for hashes") "c_inline"]
let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h
[@ (Comment " Constructor for paths") "c_inline"]
let mt_init_path (hash_size:hash_size_t) (mtr:HH.rid) (r:HST.erid): HST.ST path_p pf pt = MTNL.init_path hash_size mtr r
[@ (Comment " Destructor for paths") "c_inline"]
let mt_free_path (path:path_p): HST.ST unit pf pt = MTNL.free_path path
[@ (Comment " Length of a path
@param[in] p Path
return The length of the path") "c_inline"]
let mt_get_path_length (mtr:HH.rid) (path:const_path_p): HST.ST U32.t pf pt = MTNL.mt_get_path_length mtr path
[@ (Comment " Insert hash into path
@param[in] p Path
@param[in] hash Hash to insert") "c_inline"]
let mt_path_insert
(#h:HS.mem)
(#mtr:HH.rid)
(path:path_p)
(hash:hash #(MTNL.Path?.hash_size (B.get h path 0)))
: HST.ST unit pf pt
= let hash_size = MTNL.Path?.hash_size (B.index path 0ul) in
MTNL.mt_path_insert #hash_size mtr path hash
inline_for_extraction
let path_hash_size (#h:HS.mem) (path:path_p) = MTNL.Path?.hash_size (B.get h path 0)
inline_for_extraction
let const_path_hash_size (#h:HS.mem) (path:const_path_p) = path_hash_size #h (CB.cast path)
inline_for_extraction
let tree_hash_size (#h:HS.mem) (mt:mt_p) = MTNL.MT?.hash_size (B.get h mt 0)
inline_for_extraction
let const_tree_hash_size (#h:HS.mem) (mt:const_mt_p) = tree_hash_size #h (CB.cast mt)
[@ (Comment " Get step on a path
@param[in] p Path
@param[in] i Path step index
return The hash at step i of p") "c_inline"]
let mt_get_path_step
(#h:HS.mem)
(#mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST (hash #(const_path_hash_size #h path)) pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step #hash_size mtr path i
[@ (Comment " Precondition predicate for mt_get_path_step") "c_inline"]
let mt_get_path_step_pre
(#h:HS.mem)
(mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST bool pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step_pre #hash_size mtr path i
[@ (Comment " Construction with custom hash functions
@param[in] hash_size Hash size (in bytes)
@param[in] i The initial hash
return The new Merkle tree") "c_inline"]
let mt_create_custom
(hash_size:hash_size_t)
(hash_spec:Ghost.erased (MTS.hash_fun_t #(U32.v hash_size)))
(r:HST.erid)
(i:hash #hash_size)
(hash_fun:MTNLHF.hash_fun_t #hash_size #hash_spec)
: HST.ST mt_p pf pt
= MTNL.mt_create_custom hash_size hash_spec r i hash_fun
[@ (Comment " Destruction
@param[in] mt The Merkle tree") "c_inline"]
let mt_free (mt:mt_p): HST.ST unit pf pt = MTNL.mt_free mt
[@ (Comment " Insertion
@param[in] mt The Merkle tree
@param[in] v The tree does not take ownership of the hash, it makes a copy of its content.
Note: The content of the hash will be overwritten with an arbitrary value.") "c_inline"]
let mt_insert
(#h:HS.mem)
(mt:mt_p)
(v:hash #(tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index mt 0ul) in
MTNL.mt_insert hash_size mt v
[@ (Comment " Precondition predicate for mt_insert") "c_inline"]
let mt_insert_pre
(#h:HS.mem)
(mt:const_mt_p)
(v:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_insert_pre #hash_size mt v
[@ (Comment " Getting the Merkle root
@param[in] mt The Merkle tree
@param[out] root The Merkle root") "c_inline"]
let mt_get_root
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root #hash_size mt root
[@ (Comment " Precondition predicate for mt_get_root") "c_inline"]
let mt_get_root_pre
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root_pre #hash_size mt root
[@ (Comment " Getting a Merkle path
@param[in] mt The Merkle tree
@param[in] idx The index of the target hash
@param[out] path A resulting Merkle path that contains the leaf hash.
@param[out] root The Merkle root
return The number of elements in the tree
Notes:
- The resulting path contains pointers to hashes in the tree, not copies of
the hash values.
- idx must be within the currently held indices in the tree (past the
last flush index).") "c_inline"]
let mt_get_path
(#h:HS.mem)
(mt:const_mt_p)
(idx:offset_t)
(path:path_p{path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(path_hash_size #h path))
: HST.ST index_t pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_path #hash_size mt idx path root
[@ (Comment " Precondition predicate for mt_get_path") "c_inline"]
let mt_get_path_pre
(#h:HS.mem)
(mt:const_mt_p)
(idx:offset_t)
(path:const_path_p{const_path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(const_path_hash_size #h path))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_path_pre #hash_size mt idx path root
[@ (Comment " Flush the Merkle tree
@param[in] mt The Merkle tree") "c_inline"]
let mt_flush (mt:mt_p): HST.ST unit pf pt = MTNL.mt_flush mt
[@ (Comment " Precondition predicate for mt_flush") "c_inline"]
let mt_flush_pre (mt:const_mt_p): HST.ST bool pf pt = MTNL.mt_flush_pre mt
[@ (Comment " Flush the Merkle tree up to a given index
@param[in] mt The Merkle tree
@param[in] idx The index up to which to flush the tree") "c_inline"]
let mt_flush_to (mt:mt_p) (idx:offset_t): HST.ST unit pf pt = MTNL.mt_flush_to mt idx
[@ (Comment " Precondition predicate for mt_flush_to")]
let mt_flush_to_pre (mt:const_mt_p) (idx:offset_t): HST.ST bool pf pt = MTNL.mt_flush_to_pre mt idx
[@ (Comment " Retract the Merkle tree down to a given index
@param[in] mt The Merkle tree
@param[in] idx The index to retract the tree to
Note: The element and idx will remain in the tree.") "c_inline"]
let mt_retract_to (mt:mt_p) (idx:offset_t): HST.ST unit pf pt = MTNL.mt_retract_to mt idx
[@ (Comment " Precondition predicate for mt_retract_to") "c_inline"]
let mt_retract_to_pre (mt:const_mt_p) (idx:offset_t): HST.ST bool pf pt = MTNL.mt_retract_to_pre mt idx
[@ (Comment " Client-side verification
@param[in] mt The Merkle tree
@param[in] tgt The index of the target hash
@param[in] max The maximum index + 1 of the tree when the path was generated
@param[in] path The Merkle path to verify
@param[in] root
return true if the verification succeeded, false otherwise
Note: max - tgt must be less than 2^32.") "c_inline"]
let mt_verify
(#h:HS.mem)
(#hash_size:Ghost.erased hash_size_t)
(#hash_spec:MTS.hash_fun_t #(U32.v hash_size))
(mt:const_mt_p)
(tgt:UInt64.t)
(max:UInt64.t)
(mtr:HH.rid)
(path:const_path_p{let phs = const_path_hash_size #h path in phs = const_tree_hash_size #h mt /\ phs = Ghost.reveal hash_size})
(root:hash #(const_path_hash_size #h path))
: HST.ST bool pf pt
= let dmt = B.index (CB.cast mt) 0ul in
let hsz = MTNL.MT?.hash_size dmt in
MTNL.mt_verify #hsz #hash_spec mt tgt max mtr path root
[@ (Comment " Precondition predicate for mt_verify") "c_inline"]
let mt_verify_pre
(#h:HS.mem)
(mt:const_mt_p)
(tgt:UInt64.t)
(max:UInt64.t)
(mtr:HH.rid)
(path:const_path_p{const_path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(const_path_hash_size #h path))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_verify_pre #hash_size mt tgt max mtr path root
[@ (Comment " Serialization size
@param[in] mt The Merkle tree | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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.const_mt_p -> FStar.HyperStack.ST.ST FStar.UInt64.t | FStar.HyperStack.ST.ST | [] | [] | [
"MerkleTree.const_mt_p",
"MerkleTree.Low.Serialization.mt_serialize_size",
"MerkleTree.Low.Serialization.uint64_t",
"FStar.UInt64.t",
"MerkleTree.pf",
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.pt"
] | [] | false | true | false | false | false | let mt_serialize_size (mt: const_mt_p) : HST.ST UInt64.t pf pt =
| MTNLS.mt_serialize_size mt | false |
Vale.X64.InsSha.fsti | Vale.X64.InsSha.va_wp_SHA256_msg2 | val va_wp_SHA256_msg2
(dst src: va_operand_xmm)
(t: counter)
(block: block_w)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | val va_wp_SHA256_msg2
(dst src: va_operand_xmm)
(t: counter)
(block: block_w)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | let va_wp_SHA256_msg2 (dst:va_operand_xmm) (src:va_operand_xmm) (t:counter) (block:block_w)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\ ((16 <=
t && t < size_k_w_256 - 3)) /\ (let step1 = ws_partial t block in let t_minus_7 = ws_quad32 (t
- 7) block in va_eval_xmm va_s0 dst == add_wrap_quad32 step1 t_minus_7) /\ (va_eval_xmm va_s0
src).hi2 == ws_opaque block (t - 2) /\ (va_eval_xmm va_s0 src).hi3 == ws_opaque block (t - 1)
/\ (forall (va_x_dst:va_value_xmm) . let va_sM = va_upd_operand_xmm dst va_x_dst va_s0 in
va_get_ok va_sM /\ va_eval_xmm va_sM dst == ws_quad32 t block ==> va_k va_sM (()))) | {
"file_name": "obj/Vale.X64.InsSha.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 87,
"end_line": 123,
"start_col": 0,
"start_line": 116
} | module Vale.X64.InsSha
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Spec.SHA2
open Spec.Hash.Definitions
open Vale.SHA.SHA_helpers
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.QuickCode
open Vale.X64.InsVector
open FStar.UInt32
open FStar.Seq
open Spec.Loops
open Vale.X64.CPU_Features_s
//-- SHA256_rnds2
val va_code_SHA256_rnds2 : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code
val va_codegen_success_SHA256_rnds2 : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool
val va_lemma_SHA256_rnds2 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> t:counter -> block:block_w -> hash_orig:hash256
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_SHA256_rnds2 dst src) va_s0 /\ va_is_dst_xmm dst va_s0
/\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\ t + 1 < size_k_w_256 /\
(va_get_xmm 0 va_s0).lo0 == add_wrap (word_to_nat32 (index k t)) (ws_opaque block t) /\
(va_get_xmm 0 va_s0).lo1 == add_wrap (word_to_nat32 (index k (t + 1))) (ws_opaque block (t +
1)) /\ make_hash (va_eval_xmm va_s0 src) (va_eval_xmm va_s0 dst) == repeat_range 0 t
(shuffle_core_opaque block) hash_orig))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
make_hash (va_eval_xmm va_sM dst) (va_eval_xmm va_s0 src) == repeat_range 0 (t + 2)
(shuffle_core_opaque block) hash_orig /\ va_state_eq va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0))))
[@ va_qattr]
let va_wp_SHA256_rnds2 (dst:va_operand_xmm) (src:va_operand_xmm) (t:counter) (block:block_w)
(hash_orig:hash256) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\ t + 1 <
size_k_w_256 /\ (va_get_xmm 0 va_s0).lo0 == add_wrap (word_to_nat32 (index k t)) (ws_opaque
block t) /\ (va_get_xmm 0 va_s0).lo1 == add_wrap (word_to_nat32 (index k (t + 1))) (ws_opaque
block (t + 1)) /\ make_hash (va_eval_xmm va_s0 src) (va_eval_xmm va_s0 dst) == repeat_range 0 t
(shuffle_core_opaque block) hash_orig /\ (forall (va_x_dst:va_value_xmm) . let va_sM =
va_upd_operand_xmm dst va_x_dst va_s0 in va_get_ok va_sM /\ make_hash (va_eval_xmm va_sM dst)
(va_eval_xmm va_s0 src) == repeat_range 0 (t + 2) (shuffle_core_opaque block) hash_orig ==>
va_k va_sM (())))
val va_wpProof_SHA256_rnds2 : dst:va_operand_xmm -> src:va_operand_xmm -> t:counter ->
block:block_w -> hash_orig:hash256 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_SHA256_rnds2 dst src t block hash_orig va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_SHA256_rnds2 dst src) ([va_mod_xmm
dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_SHA256_rnds2 (dst:va_operand_xmm) (src:va_operand_xmm) (t:counter) (block:block_w)
(hash_orig:hash256) : (va_quickCode unit (va_code_SHA256_rnds2 dst src)) =
(va_QProc (va_code_SHA256_rnds2 dst src) ([va_mod_xmm dst]) (va_wp_SHA256_rnds2 dst src t block
hash_orig) (va_wpProof_SHA256_rnds2 dst src t block hash_orig))
//--
//-- SHA256_msg1
val va_code_SHA256_msg1 : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code
val va_codegen_success_SHA256_msg1 : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool
val va_lemma_SHA256_msg1 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> t:counter -> block:block_w
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_SHA256_msg1 dst src) va_s0 /\ va_is_dst_xmm dst va_s0
/\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\ ((16 <= t && t < size_k_w_256))
/\ va_eval_xmm va_s0 dst == ws_quad32 (t - 16) block /\ (va_eval_xmm va_s0 src).lo0 ==
ws_opaque block (t - 12)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == ws_partial t block /\ va_state_eq va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0))))
[@ va_qattr]
let va_wp_SHA256_msg1 (dst:va_operand_xmm) (src:va_operand_xmm) (t:counter) (block:block_w)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\ ((16 <=
t && t < size_k_w_256)) /\ va_eval_xmm va_s0 dst == ws_quad32 (t - 16) block /\ (va_eval_xmm
va_s0 src).lo0 == ws_opaque block (t - 12) /\ (forall (va_x_dst:va_value_xmm) . let va_sM =
va_upd_operand_xmm dst va_x_dst va_s0 in va_get_ok va_sM /\ va_eval_xmm va_sM dst == ws_partial
t block ==> va_k va_sM (())))
val va_wpProof_SHA256_msg1 : dst:va_operand_xmm -> src:va_operand_xmm -> t:counter -> block:block_w
-> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_SHA256_msg1 dst src t block va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_SHA256_msg1 dst src) ([va_mod_xmm
dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_SHA256_msg1 (dst:va_operand_xmm) (src:va_operand_xmm) (t:counter) (block:block_w) :
(va_quickCode unit (va_code_SHA256_msg1 dst src)) =
(va_QProc (va_code_SHA256_msg1 dst src) ([va_mod_xmm dst]) (va_wp_SHA256_msg1 dst src t block)
(va_wpProof_SHA256_msg1 dst src t block))
//--
//-- SHA256_msg2
val va_code_SHA256_msg2 : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code
val va_codegen_success_SHA256_msg2 : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool
val va_lemma_SHA256_msg2 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> t:counter -> block:block_w
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_SHA256_msg2 dst src) va_s0 /\ va_is_dst_xmm dst va_s0
/\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\ ((16 <= t && t < size_k_w_256 -
3)) /\ (let step1 = ws_partial t block in let t_minus_7 = ws_quad32 (t - 7) block in
va_eval_xmm va_s0 dst == add_wrap_quad32 step1 t_minus_7) /\ (va_eval_xmm va_s0 src).hi2 ==
ws_opaque block (t - 2) /\ (va_eval_xmm va_s0 src).hi3 == ws_opaque block (t - 1)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == ws_quad32 t block /\ va_state_eq va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0)))) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.InsVector.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.SHA.SHA_helpers.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.fsti.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.InsSha.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Loops",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"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 |
dst: Vale.X64.Decls.va_operand_xmm ->
src: Vale.X64.Decls.va_operand_xmm ->
t: Vale.SHA.SHA_helpers.counter ->
block: Vale.SHA.SHA_helpers.block_w ->
va_s0: Vale.X64.Decls.va_state ->
va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Decls.va_operand_xmm",
"Vale.SHA.SHA_helpers.counter",
"Vale.SHA.SHA_helpers.block_w",
"Vale.X64.Decls.va_state",
"Prims.unit",
"Prims.l_and",
"Vale.X64.Decls.va_is_dst_xmm",
"Vale.X64.Decls.va_is_src_xmm",
"Prims.b2t",
"Vale.X64.Decls.va_get_ok",
"Vale.X64.CPU_Features_s.sha_enabled",
"Prims.op_AmpAmp",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.op_Subtraction",
"Vale.SHA.SHA_helpers.size_k_w_256",
"Prims.eq2",
"Vale.Def.Types_s.quad32",
"Vale.X64.Decls.va_eval_xmm",
"Vale.Arch.Types.add_wrap_quad32",
"Vale.SHA.SHA_helpers.ws_quad32",
"Vale.SHA.SHA_helpers.ws_partial",
"Vale.Def.Words_s.nat32",
"Vale.Def.Words_s.__proj__Mkfour__item__hi2",
"Vale.Def.Types_s.nat32",
"Vale.SHA.SHA_helpers.ws_opaque",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"Prims.l_Forall",
"Vale.X64.Decls.va_value_xmm",
"Prims.l_imp",
"Vale.X64.State.vale_state",
"Vale.X64.Decls.va_upd_operand_xmm"
] | [] | false | false | false | true | true | let va_wp_SHA256_msg2
(dst src: va_operand_xmm)
(t: counter)
(block: block_w)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 =
| (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\
((16 <= t && t < size_k_w_256 - 3)) /\
(let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t - 7) block in
va_eval_xmm va_s0 dst == add_wrap_quad32 step1 t_minus_7) /\
(va_eval_xmm va_s0 src).hi2 == ws_opaque block (t - 2) /\
(va_eval_xmm va_s0 src).hi3 == ws_opaque block (t - 1) /\
(forall (va_x_dst: va_value_xmm).
let va_sM = va_upd_operand_xmm dst va_x_dst va_s0 in
va_get_ok va_sM /\ va_eval_xmm va_sM dst == ws_quad32 t block ==> va_k va_sM (()))) | false |
MerkleTree.fsti | MerkleTree.mt_get_path_pre | val mt_get_path_pre
(#h: HS.mem)
(mt: const_mt_p)
(idx: offset_t)
(path: const_path_p{const_path_hash_size #h path = const_tree_hash_size #h mt})
(root: hash #(const_path_hash_size #h path))
: HST.ST bool pf pt | val mt_get_path_pre
(#h: HS.mem)
(mt: const_mt_p)
(idx: offset_t)
(path: const_path_p{const_path_hash_size #h path = const_tree_hash_size #h mt})
(root: hash #(const_path_hash_size #h path))
: HST.ST bool pf pt | let mt_get_path_pre
(#h:HS.mem)
(mt:const_mt_p)
(idx:offset_t)
(path:const_path_p{const_path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(const_path_hash_size #h path))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_path_pre #hash_size mt idx path root | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 50,
"end_line": 208,
"start_col": 0,
"start_line": 200
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r
[@ (Comment " Destructor for hashes") "c_inline"]
let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h
[@ (Comment " Constructor for paths") "c_inline"]
let mt_init_path (hash_size:hash_size_t) (mtr:HH.rid) (r:HST.erid): HST.ST path_p pf pt = MTNL.init_path hash_size mtr r
[@ (Comment " Destructor for paths") "c_inline"]
let mt_free_path (path:path_p): HST.ST unit pf pt = MTNL.free_path path
[@ (Comment " Length of a path
@param[in] p Path
return The length of the path") "c_inline"]
let mt_get_path_length (mtr:HH.rid) (path:const_path_p): HST.ST U32.t pf pt = MTNL.mt_get_path_length mtr path
[@ (Comment " Insert hash into path
@param[in] p Path
@param[in] hash Hash to insert") "c_inline"]
let mt_path_insert
(#h:HS.mem)
(#mtr:HH.rid)
(path:path_p)
(hash:hash #(MTNL.Path?.hash_size (B.get h path 0)))
: HST.ST unit pf pt
= let hash_size = MTNL.Path?.hash_size (B.index path 0ul) in
MTNL.mt_path_insert #hash_size mtr path hash
inline_for_extraction
let path_hash_size (#h:HS.mem) (path:path_p) = MTNL.Path?.hash_size (B.get h path 0)
inline_for_extraction
let const_path_hash_size (#h:HS.mem) (path:const_path_p) = path_hash_size #h (CB.cast path)
inline_for_extraction
let tree_hash_size (#h:HS.mem) (mt:mt_p) = MTNL.MT?.hash_size (B.get h mt 0)
inline_for_extraction
let const_tree_hash_size (#h:HS.mem) (mt:const_mt_p) = tree_hash_size #h (CB.cast mt)
[@ (Comment " Get step on a path
@param[in] p Path
@param[in] i Path step index
return The hash at step i of p") "c_inline"]
let mt_get_path_step
(#h:HS.mem)
(#mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST (hash #(const_path_hash_size #h path)) pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step #hash_size mtr path i
[@ (Comment " Precondition predicate for mt_get_path_step") "c_inline"]
let mt_get_path_step_pre
(#h:HS.mem)
(mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST bool pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step_pre #hash_size mtr path i
[@ (Comment " Construction with custom hash functions
@param[in] hash_size Hash size (in bytes)
@param[in] i The initial hash
return The new Merkle tree") "c_inline"]
let mt_create_custom
(hash_size:hash_size_t)
(hash_spec:Ghost.erased (MTS.hash_fun_t #(U32.v hash_size)))
(r:HST.erid)
(i:hash #hash_size)
(hash_fun:MTNLHF.hash_fun_t #hash_size #hash_spec)
: HST.ST mt_p pf pt
= MTNL.mt_create_custom hash_size hash_spec r i hash_fun
[@ (Comment " Destruction
@param[in] mt The Merkle tree") "c_inline"]
let mt_free (mt:mt_p): HST.ST unit pf pt = MTNL.mt_free mt
[@ (Comment " Insertion
@param[in] mt The Merkle tree
@param[in] v The tree does not take ownership of the hash, it makes a copy of its content.
Note: The content of the hash will be overwritten with an arbitrary value.") "c_inline"]
let mt_insert
(#h:HS.mem)
(mt:mt_p)
(v:hash #(tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index mt 0ul) in
MTNL.mt_insert hash_size mt v
[@ (Comment " Precondition predicate for mt_insert") "c_inline"]
let mt_insert_pre
(#h:HS.mem)
(mt:const_mt_p)
(v:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_insert_pre #hash_size mt v
[@ (Comment " Getting the Merkle root
@param[in] mt The Merkle tree
@param[out] root The Merkle root") "c_inline"]
let mt_get_root
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root #hash_size mt root
[@ (Comment " Precondition predicate for mt_get_root") "c_inline"]
let mt_get_root_pre
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root_pre #hash_size mt root
[@ (Comment " Getting a Merkle path
@param[in] mt The Merkle tree
@param[in] idx The index of the target hash
@param[out] path A resulting Merkle path that contains the leaf hash.
@param[out] root The Merkle root
return The number of elements in the tree
Notes:
- The resulting path contains pointers to hashes in the tree, not copies of
the hash values.
- idx must be within the currently held indices in the tree (past the
last flush index).") "c_inline"]
let mt_get_path
(#h:HS.mem)
(mt:const_mt_p)
(idx:offset_t)
(path:path_p{path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(path_hash_size #h path))
: HST.ST index_t pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_path #hash_size mt idx path root | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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.const_mt_p ->
idx: MerkleTree.offset_t ->
path:
MerkleTree.const_path_p
{MerkleTree.const_path_hash_size path = MerkleTree.const_tree_hash_size mt} ->
root: MerkleTree.hash
-> FStar.HyperStack.ST.ST Prims.bool | FStar.HyperStack.ST.ST | [] | [] | [
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.const_mt_p",
"MerkleTree.offset_t",
"MerkleTree.const_path_p",
"Prims.b2t",
"Prims.op_Equality",
"MerkleTree.Low.Datastructures.hash_size_t",
"MerkleTree.const_path_hash_size",
"MerkleTree.const_tree_hash_size",
"MerkleTree.hash",
"MerkleTree.Low.mt_get_path_pre",
"FStar.Ghost.hide",
"Prims.bool",
"MerkleTree.Low.__proj__MT__item__hash_size",
"MerkleTree.Low.merkle_tree",
"LowStar.Monotonic.Buffer.index",
"LowStar.ConstBuffer.qbuf_pre",
"LowStar.ConstBuffer.as_qbuf",
"LowStar.ConstBuffer.cast",
"FStar.UInt32.__uint_to_t",
"MerkleTree.pf",
"MerkleTree.pt"
] | [] | false | true | false | false | false | let mt_get_path_pre
(#h: HS.mem)
(mt: const_mt_p)
(idx: offset_t)
(path: const_path_p{const_path_hash_size #h path = const_tree_hash_size #h mt})
(root: hash #(const_path_hash_size #h path))
: HST.ST bool pf pt =
| let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_path_pre #hash_size mt idx path root | false |
Vale.X64.InsSha.fsti | Vale.X64.InsSha.va_wp_SHA256_rnds2 | val va_wp_SHA256_rnds2
(dst src: va_operand_xmm)
(t: counter)
(block: block_w)
(hash_orig: hash256)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | val va_wp_SHA256_rnds2
(dst src: va_operand_xmm)
(t: counter)
(block: block_w)
(hash_orig: hash256)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | let va_wp_SHA256_rnds2 (dst:va_operand_xmm) (src:va_operand_xmm) (t:counter) (block:block_w)
(hash_orig:hash256) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\ t + 1 <
size_k_w_256 /\ (va_get_xmm 0 va_s0).lo0 == add_wrap (word_to_nat32 (index k t)) (ws_opaque
block t) /\ (va_get_xmm 0 va_s0).lo1 == add_wrap (word_to_nat32 (index k (t + 1))) (ws_opaque
block (t + 1)) /\ make_hash (va_eval_xmm va_s0 src) (va_eval_xmm va_s0 dst) == repeat_range 0 t
(shuffle_core_opaque block) hash_orig /\ (forall (va_x_dst:va_value_xmm) . let va_sM =
va_upd_operand_xmm dst va_x_dst va_s0 in va_get_ok va_sM /\ make_hash (va_eval_xmm va_sM dst)
(va_eval_xmm va_s0 src) == repeat_range 0 (t + 2) (shuffle_core_opaque block) hash_orig ==>
va_k va_sM (()))) | {
"file_name": "obj/Vale.X64.InsSha.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 21,
"end_line": 47,
"start_col": 0,
"start_line": 38
} | module Vale.X64.InsSha
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Spec.SHA2
open Spec.Hash.Definitions
open Vale.SHA.SHA_helpers
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.QuickCode
open Vale.X64.InsVector
open FStar.UInt32
open FStar.Seq
open Spec.Loops
open Vale.X64.CPU_Features_s
//-- SHA256_rnds2
val va_code_SHA256_rnds2 : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code
val va_codegen_success_SHA256_rnds2 : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool
val va_lemma_SHA256_rnds2 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> t:counter -> block:block_w -> hash_orig:hash256
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_SHA256_rnds2 dst src) va_s0 /\ va_is_dst_xmm dst va_s0
/\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\ t + 1 < size_k_w_256 /\
(va_get_xmm 0 va_s0).lo0 == add_wrap (word_to_nat32 (index k t)) (ws_opaque block t) /\
(va_get_xmm 0 va_s0).lo1 == add_wrap (word_to_nat32 (index k (t + 1))) (ws_opaque block (t +
1)) /\ make_hash (va_eval_xmm va_s0 src) (va_eval_xmm va_s0 dst) == repeat_range 0 t
(shuffle_core_opaque block) hash_orig))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
make_hash (va_eval_xmm va_sM dst) (va_eval_xmm va_s0 src) == repeat_range 0 (t + 2)
(shuffle_core_opaque block) hash_orig /\ va_state_eq va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0)))) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.InsVector.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.SHA.SHA_helpers.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.fsti.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.InsSha.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Loops",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"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 |
dst: Vale.X64.Decls.va_operand_xmm ->
src: Vale.X64.Decls.va_operand_xmm ->
t: Vale.SHA.SHA_helpers.counter ->
block: Vale.SHA.SHA_helpers.block_w ->
hash_orig: Vale.SHA.SHA_helpers.hash256 ->
va_s0: Vale.X64.Decls.va_state ->
va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Decls.va_operand_xmm",
"Vale.SHA.SHA_helpers.counter",
"Vale.SHA.SHA_helpers.block_w",
"Vale.SHA.SHA_helpers.hash256",
"Vale.X64.Decls.va_state",
"Prims.unit",
"Prims.l_and",
"Vale.X64.Decls.va_is_dst_xmm",
"Vale.X64.Decls.va_is_src_xmm",
"Prims.b2t",
"Vale.X64.Decls.va_get_ok",
"Vale.X64.CPU_Features_s.sha_enabled",
"Prims.op_LessThan",
"Prims.op_Addition",
"Vale.SHA.SHA_helpers.size_k_w_256",
"Prims.eq2",
"Vale.Def.Words_s.natN",
"Vale.Def.Words_s.pow2_32",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0",
"Vale.Def.Types_s.nat32",
"Vale.X64.Decls.va_get_xmm",
"Vale.Def.Types_s.add_wrap",
"Vale.SHA.SHA_helpers.word_to_nat32",
"FStar.Seq.Base.index",
"Vale.SHA.SHA_helpers.word",
"Vale.SHA.SHA_helpers.k",
"Vale.SHA.SHA_helpers.ws_opaque",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Vale.SHA.SHA_helpers.make_hash",
"Vale.X64.Decls.va_eval_xmm",
"Spec.Loops.repeat_range",
"Vale.SHA.SHA_helpers.shuffle_core_opaque",
"Prims.l_Forall",
"Vale.X64.Decls.va_value_xmm",
"Prims.l_imp",
"Vale.X64.State.vale_state",
"Vale.X64.Decls.va_upd_operand_xmm"
] | [] | false | false | false | true | true | let va_wp_SHA256_rnds2
(dst src: va_operand_xmm)
(t: counter)
(block: block_w)
(hash_orig: hash256)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 =
| (va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\
t + 1 < size_k_w_256 /\
(va_get_xmm 0 va_s0).lo0 == add_wrap (word_to_nat32 (index k t)) (ws_opaque block t) /\
(va_get_xmm 0 va_s0).lo1 == add_wrap (word_to_nat32 (index k (t + 1))) (ws_opaque block (t + 1)) /\
make_hash (va_eval_xmm va_s0 src) (va_eval_xmm va_s0 dst) ==
repeat_range 0 t (shuffle_core_opaque block) hash_orig /\
(forall (va_x_dst: va_value_xmm).
let va_sM = va_upd_operand_xmm dst va_x_dst va_s0 in
va_get_ok va_sM /\
make_hash (va_eval_xmm va_sM dst) (va_eval_xmm va_s0 src) ==
repeat_range 0 (t + 2) (shuffle_core_opaque block) hash_orig ==>
va_k va_sM (()))) | false |
MerkleTree.fsti | MerkleTree.mt_serialize | val mt_serialize (mt: const_mt_p) (buf: MTNLS.uint8_p) (len: UInt64.t) : HST.ST UInt64.t pf pt | val mt_serialize (mt: const_mt_p) (buf: MTNLS.uint8_p) (len: UInt64.t) : HST.ST UInt64.t pf pt | let mt_serialize (mt:const_mt_p) (buf:MTNLS.uint8_p) (len:UInt64.t): HST.ST UInt64.t pf pt = MTNLS.mt_serialize mt buf len | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 122,
"end_line": 300,
"start_col": 0,
"start_line": 300
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r
[@ (Comment " Destructor for hashes") "c_inline"]
let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h
[@ (Comment " Constructor for paths") "c_inline"]
let mt_init_path (hash_size:hash_size_t) (mtr:HH.rid) (r:HST.erid): HST.ST path_p pf pt = MTNL.init_path hash_size mtr r
[@ (Comment " Destructor for paths") "c_inline"]
let mt_free_path (path:path_p): HST.ST unit pf pt = MTNL.free_path path
[@ (Comment " Length of a path
@param[in] p Path
return The length of the path") "c_inline"]
let mt_get_path_length (mtr:HH.rid) (path:const_path_p): HST.ST U32.t pf pt = MTNL.mt_get_path_length mtr path
[@ (Comment " Insert hash into path
@param[in] p Path
@param[in] hash Hash to insert") "c_inline"]
let mt_path_insert
(#h:HS.mem)
(#mtr:HH.rid)
(path:path_p)
(hash:hash #(MTNL.Path?.hash_size (B.get h path 0)))
: HST.ST unit pf pt
= let hash_size = MTNL.Path?.hash_size (B.index path 0ul) in
MTNL.mt_path_insert #hash_size mtr path hash
inline_for_extraction
let path_hash_size (#h:HS.mem) (path:path_p) = MTNL.Path?.hash_size (B.get h path 0)
inline_for_extraction
let const_path_hash_size (#h:HS.mem) (path:const_path_p) = path_hash_size #h (CB.cast path)
inline_for_extraction
let tree_hash_size (#h:HS.mem) (mt:mt_p) = MTNL.MT?.hash_size (B.get h mt 0)
inline_for_extraction
let const_tree_hash_size (#h:HS.mem) (mt:const_mt_p) = tree_hash_size #h (CB.cast mt)
[@ (Comment " Get step on a path
@param[in] p Path
@param[in] i Path step index
return The hash at step i of p") "c_inline"]
let mt_get_path_step
(#h:HS.mem)
(#mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST (hash #(const_path_hash_size #h path)) pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step #hash_size mtr path i
[@ (Comment " Precondition predicate for mt_get_path_step") "c_inline"]
let mt_get_path_step_pre
(#h:HS.mem)
(mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST bool pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step_pre #hash_size mtr path i
[@ (Comment " Construction with custom hash functions
@param[in] hash_size Hash size (in bytes)
@param[in] i The initial hash
return The new Merkle tree") "c_inline"]
let mt_create_custom
(hash_size:hash_size_t)
(hash_spec:Ghost.erased (MTS.hash_fun_t #(U32.v hash_size)))
(r:HST.erid)
(i:hash #hash_size)
(hash_fun:MTNLHF.hash_fun_t #hash_size #hash_spec)
: HST.ST mt_p pf pt
= MTNL.mt_create_custom hash_size hash_spec r i hash_fun
[@ (Comment " Destruction
@param[in] mt The Merkle tree") "c_inline"]
let mt_free (mt:mt_p): HST.ST unit pf pt = MTNL.mt_free mt
[@ (Comment " Insertion
@param[in] mt The Merkle tree
@param[in] v The tree does not take ownership of the hash, it makes a copy of its content.
Note: The content of the hash will be overwritten with an arbitrary value.") "c_inline"]
let mt_insert
(#h:HS.mem)
(mt:mt_p)
(v:hash #(tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index mt 0ul) in
MTNL.mt_insert hash_size mt v
[@ (Comment " Precondition predicate for mt_insert") "c_inline"]
let mt_insert_pre
(#h:HS.mem)
(mt:const_mt_p)
(v:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_insert_pre #hash_size mt v
[@ (Comment " Getting the Merkle root
@param[in] mt The Merkle tree
@param[out] root The Merkle root") "c_inline"]
let mt_get_root
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root #hash_size mt root
[@ (Comment " Precondition predicate for mt_get_root") "c_inline"]
let mt_get_root_pre
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root_pre #hash_size mt root
[@ (Comment " Getting a Merkle path
@param[in] mt The Merkle tree
@param[in] idx The index of the target hash
@param[out] path A resulting Merkle path that contains the leaf hash.
@param[out] root The Merkle root
return The number of elements in the tree
Notes:
- The resulting path contains pointers to hashes in the tree, not copies of
the hash values.
- idx must be within the currently held indices in the tree (past the
last flush index).") "c_inline"]
let mt_get_path
(#h:HS.mem)
(mt:const_mt_p)
(idx:offset_t)
(path:path_p{path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(path_hash_size #h path))
: HST.ST index_t pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_path #hash_size mt idx path root
[@ (Comment " Precondition predicate for mt_get_path") "c_inline"]
let mt_get_path_pre
(#h:HS.mem)
(mt:const_mt_p)
(idx:offset_t)
(path:const_path_p{const_path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(const_path_hash_size #h path))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_path_pre #hash_size mt idx path root
[@ (Comment " Flush the Merkle tree
@param[in] mt The Merkle tree") "c_inline"]
let mt_flush (mt:mt_p): HST.ST unit pf pt = MTNL.mt_flush mt
[@ (Comment " Precondition predicate for mt_flush") "c_inline"]
let mt_flush_pre (mt:const_mt_p): HST.ST bool pf pt = MTNL.mt_flush_pre mt
[@ (Comment " Flush the Merkle tree up to a given index
@param[in] mt The Merkle tree
@param[in] idx The index up to which to flush the tree") "c_inline"]
let mt_flush_to (mt:mt_p) (idx:offset_t): HST.ST unit pf pt = MTNL.mt_flush_to mt idx
[@ (Comment " Precondition predicate for mt_flush_to")]
let mt_flush_to_pre (mt:const_mt_p) (idx:offset_t): HST.ST bool pf pt = MTNL.mt_flush_to_pre mt idx
[@ (Comment " Retract the Merkle tree down to a given index
@param[in] mt The Merkle tree
@param[in] idx The index to retract the tree to
Note: The element and idx will remain in the tree.") "c_inline"]
let mt_retract_to (mt:mt_p) (idx:offset_t): HST.ST unit pf pt = MTNL.mt_retract_to mt idx
[@ (Comment " Precondition predicate for mt_retract_to") "c_inline"]
let mt_retract_to_pre (mt:const_mt_p) (idx:offset_t): HST.ST bool pf pt = MTNL.mt_retract_to_pre mt idx
[@ (Comment " Client-side verification
@param[in] mt The Merkle tree
@param[in] tgt The index of the target hash
@param[in] max The maximum index + 1 of the tree when the path was generated
@param[in] path The Merkle path to verify
@param[in] root
return true if the verification succeeded, false otherwise
Note: max - tgt must be less than 2^32.") "c_inline"]
let mt_verify
(#h:HS.mem)
(#hash_size:Ghost.erased hash_size_t)
(#hash_spec:MTS.hash_fun_t #(U32.v hash_size))
(mt:const_mt_p)
(tgt:UInt64.t)
(max:UInt64.t)
(mtr:HH.rid)
(path:const_path_p{let phs = const_path_hash_size #h path in phs = const_tree_hash_size #h mt /\ phs = Ghost.reveal hash_size})
(root:hash #(const_path_hash_size #h path))
: HST.ST bool pf pt
= let dmt = B.index (CB.cast mt) 0ul in
let hsz = MTNL.MT?.hash_size dmt in
MTNL.mt_verify #hsz #hash_spec mt tgt max mtr path root
[@ (Comment " Precondition predicate for mt_verify") "c_inline"]
let mt_verify_pre
(#h:HS.mem)
(mt:const_mt_p)
(tgt:UInt64.t)
(max:UInt64.t)
(mtr:HH.rid)
(path:const_path_p{const_path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(const_path_hash_size #h path))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_verify_pre #hash_size mt tgt max mtr path root
[@ (Comment " Serialization size
@param[in] mt The Merkle tree
return the number of bytes required to serialize the tree") "c_inline"]
let mt_serialize_size (mt:const_mt_p): HST.ST UInt64.t pf pt = MTNLS.mt_serialize_size mt
[@ (Comment " Merkle tree serialization
@param[in] mt The Merkle tree
@param[out] buf The buffer to serialize the tree into
@param[in] len Length of buf
return the number of bytes written
Note: buf must be a buffer of size mt_serialize_size(mt) or larger, but | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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.const_mt_p -> buf: MerkleTree.Low.Serialization.uint8_p -> len: FStar.UInt64.t
-> FStar.HyperStack.ST.ST FStar.UInt64.t | FStar.HyperStack.ST.ST | [] | [] | [
"MerkleTree.const_mt_p",
"MerkleTree.Low.Serialization.uint8_p",
"FStar.UInt64.t",
"MerkleTree.Low.Serialization.mt_serialize",
"MerkleTree.Low.Serialization.uint64_t",
"MerkleTree.pf",
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.pt"
] | [] | false | true | false | false | false | let mt_serialize (mt: const_mt_p) (buf: MTNLS.uint8_p) (len: UInt64.t) : HST.ST UInt64.t pf pt =
| MTNLS.mt_serialize mt buf len | false |
MerkleTree.fsti | MerkleTree.mt_retract_to_pre | val mt_retract_to_pre (mt: const_mt_p) (idx: offset_t) : HST.ST bool pf pt | val mt_retract_to_pre (mt: const_mt_p) (idx: offset_t) : HST.ST bool pf pt | let mt_retract_to_pre (mt:const_mt_p) (idx:offset_t): HST.ST bool pf pt = MTNL.mt_retract_to_pre mt idx | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 103,
"end_line": 239,
"start_col": 0,
"start_line": 239
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r
[@ (Comment " Destructor for hashes") "c_inline"]
let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h
[@ (Comment " Constructor for paths") "c_inline"]
let mt_init_path (hash_size:hash_size_t) (mtr:HH.rid) (r:HST.erid): HST.ST path_p pf pt = MTNL.init_path hash_size mtr r
[@ (Comment " Destructor for paths") "c_inline"]
let mt_free_path (path:path_p): HST.ST unit pf pt = MTNL.free_path path
[@ (Comment " Length of a path
@param[in] p Path
return The length of the path") "c_inline"]
let mt_get_path_length (mtr:HH.rid) (path:const_path_p): HST.ST U32.t pf pt = MTNL.mt_get_path_length mtr path
[@ (Comment " Insert hash into path
@param[in] p Path
@param[in] hash Hash to insert") "c_inline"]
let mt_path_insert
(#h:HS.mem)
(#mtr:HH.rid)
(path:path_p)
(hash:hash #(MTNL.Path?.hash_size (B.get h path 0)))
: HST.ST unit pf pt
= let hash_size = MTNL.Path?.hash_size (B.index path 0ul) in
MTNL.mt_path_insert #hash_size mtr path hash
inline_for_extraction
let path_hash_size (#h:HS.mem) (path:path_p) = MTNL.Path?.hash_size (B.get h path 0)
inline_for_extraction
let const_path_hash_size (#h:HS.mem) (path:const_path_p) = path_hash_size #h (CB.cast path)
inline_for_extraction
let tree_hash_size (#h:HS.mem) (mt:mt_p) = MTNL.MT?.hash_size (B.get h mt 0)
inline_for_extraction
let const_tree_hash_size (#h:HS.mem) (mt:const_mt_p) = tree_hash_size #h (CB.cast mt)
[@ (Comment " Get step on a path
@param[in] p Path
@param[in] i Path step index
return The hash at step i of p") "c_inline"]
let mt_get_path_step
(#h:HS.mem)
(#mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST (hash #(const_path_hash_size #h path)) pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step #hash_size mtr path i
[@ (Comment " Precondition predicate for mt_get_path_step") "c_inline"]
let mt_get_path_step_pre
(#h:HS.mem)
(mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST bool pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step_pre #hash_size mtr path i
[@ (Comment " Construction with custom hash functions
@param[in] hash_size Hash size (in bytes)
@param[in] i The initial hash
return The new Merkle tree") "c_inline"]
let mt_create_custom
(hash_size:hash_size_t)
(hash_spec:Ghost.erased (MTS.hash_fun_t #(U32.v hash_size)))
(r:HST.erid)
(i:hash #hash_size)
(hash_fun:MTNLHF.hash_fun_t #hash_size #hash_spec)
: HST.ST mt_p pf pt
= MTNL.mt_create_custom hash_size hash_spec r i hash_fun
[@ (Comment " Destruction
@param[in] mt The Merkle tree") "c_inline"]
let mt_free (mt:mt_p): HST.ST unit pf pt = MTNL.mt_free mt
[@ (Comment " Insertion
@param[in] mt The Merkle tree
@param[in] v The tree does not take ownership of the hash, it makes a copy of its content.
Note: The content of the hash will be overwritten with an arbitrary value.") "c_inline"]
let mt_insert
(#h:HS.mem)
(mt:mt_p)
(v:hash #(tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index mt 0ul) in
MTNL.mt_insert hash_size mt v
[@ (Comment " Precondition predicate for mt_insert") "c_inline"]
let mt_insert_pre
(#h:HS.mem)
(mt:const_mt_p)
(v:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_insert_pre #hash_size mt v
[@ (Comment " Getting the Merkle root
@param[in] mt The Merkle tree
@param[out] root The Merkle root") "c_inline"]
let mt_get_root
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root #hash_size mt root
[@ (Comment " Precondition predicate for mt_get_root") "c_inline"]
let mt_get_root_pre
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root_pre #hash_size mt root
[@ (Comment " Getting a Merkle path
@param[in] mt The Merkle tree
@param[in] idx The index of the target hash
@param[out] path A resulting Merkle path that contains the leaf hash.
@param[out] root The Merkle root
return The number of elements in the tree
Notes:
- The resulting path contains pointers to hashes in the tree, not copies of
the hash values.
- idx must be within the currently held indices in the tree (past the
last flush index).") "c_inline"]
let mt_get_path
(#h:HS.mem)
(mt:const_mt_p)
(idx:offset_t)
(path:path_p{path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(path_hash_size #h path))
: HST.ST index_t pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_path #hash_size mt idx path root
[@ (Comment " Precondition predicate for mt_get_path") "c_inline"]
let mt_get_path_pre
(#h:HS.mem)
(mt:const_mt_p)
(idx:offset_t)
(path:const_path_p{const_path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(const_path_hash_size #h path))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_path_pre #hash_size mt idx path root
[@ (Comment " Flush the Merkle tree
@param[in] mt The Merkle tree") "c_inline"]
let mt_flush (mt:mt_p): HST.ST unit pf pt = MTNL.mt_flush mt
[@ (Comment " Precondition predicate for mt_flush") "c_inline"]
let mt_flush_pre (mt:const_mt_p): HST.ST bool pf pt = MTNL.mt_flush_pre mt
[@ (Comment " Flush the Merkle tree up to a given index
@param[in] mt The Merkle tree
@param[in] idx The index up to which to flush the tree") "c_inline"]
let mt_flush_to (mt:mt_p) (idx:offset_t): HST.ST unit pf pt = MTNL.mt_flush_to mt idx
[@ (Comment " Precondition predicate for mt_flush_to")]
let mt_flush_to_pre (mt:const_mt_p) (idx:offset_t): HST.ST bool pf pt = MTNL.mt_flush_to_pre mt idx
[@ (Comment " Retract the Merkle tree down to a given index
@param[in] mt The Merkle tree
@param[in] idx The index to retract the tree to
Note: The element and idx will remain in the tree.") "c_inline"]
let mt_retract_to (mt:mt_p) (idx:offset_t): HST.ST unit pf pt = MTNL.mt_retract_to mt idx | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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.const_mt_p -> idx: MerkleTree.offset_t -> FStar.HyperStack.ST.ST Prims.bool | FStar.HyperStack.ST.ST | [] | [] | [
"MerkleTree.const_mt_p",
"MerkleTree.offset_t",
"MerkleTree.Low.mt_retract_to_pre",
"Prims.bool",
"MerkleTree.pf",
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.pt"
] | [] | false | true | false | false | false | let mt_retract_to_pre (mt: const_mt_p) (idx: offset_t) : HST.ST bool pf pt =
| MTNL.mt_retract_to_pre mt idx | false |
Hacl.Poly1305.Field32xN.Lemmas0.fst | Hacl.Poly1305.Field32xN.Lemmas0.mul_felem5_lemma_4 | val mul_felem5_lemma_4:
f1:tup64_5{tup64_fits5 f1 (3, 3, 3, 3, 3)}
-> r:tup64_5{tup64_fits5 r (2, 2, 2, 2, 2)} ->
Lemma
(let (f10, f11, f12, f13, f14) = f1 in
let (r0, r1, r2, r3, r4) = r in
(as_nat5 f1 * as_nat5 r) % prime ==
(v f10 * as_nat5 r +
v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) +
v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) +
v f13 * as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) +
v f14 * as_nat5 (r1 *! u64 5, r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0)) % prime) | val mul_felem5_lemma_4:
f1:tup64_5{tup64_fits5 f1 (3, 3, 3, 3, 3)}
-> r:tup64_5{tup64_fits5 r (2, 2, 2, 2, 2)} ->
Lemma
(let (f10, f11, f12, f13, f14) = f1 in
let (r0, r1, r2, r3, r4) = r in
(as_nat5 f1 * as_nat5 r) % prime ==
(v f10 * as_nat5 r +
v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) +
v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) +
v f13 * as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) +
v f14 * as_nat5 (r1 *! u64 5, r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0)) % prime) | let mul_felem5_lemma_4 f1 r =
let (f10, f11, f12, f13, f14) = f1 in
let (r0, r1, r2, r3, r4) = r in
let tmp =
v f10 * as_nat5 r + v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) +
v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) + v f13 * as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) in
calc (==) {
(as_nat5 f1 * as_nat5 r) % prime;
(==) { mul_felem5_lemma_3 f1 r }
(tmp + v f14 * pow104 * as_nat5 r) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp (v f14 * pow104 * as_nat5 r) prime }
(tmp + (v f14 * pow104 * as_nat5 r) % prime) % prime;
(==) {
FStar.Math.Lemmas.paren_mul_right (v f14) pow104 (as_nat5 r);
FStar.Math.Lemmas.lemma_mod_mul_distr_r (v f14) (pow104 * as_nat5 r) prime }
(tmp + v f14 * (pow104 * as_nat5 r % prime) % prime) % prime;
(==) { lemma_fmul5_pow104 r }
(tmp + v f14 * (as_nat5 (r1 *! u64 5, r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0) % prime) % prime) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (v f14) (as_nat5 (r1 *! u64 5, r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0)) prime }
(tmp + v f14 * as_nat5 (r1 *! u64 5, r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0) % prime) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp (v f14 * as_nat5 (r1 *! u64 5, r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0)) prime }
(tmp + v f14 * as_nat5 (r1 *! u64 5, r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0)) % prime;
};
assert ((as_nat5 f1 * as_nat5 r) % prime == (tmp + v f14 * as_nat5 (r1 *! u64 5, r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0)) % prime) | {
"file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas0.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 135,
"end_line": 632,
"start_col": 0,
"start_line": 608
} | module Hacl.Poly1305.Field32xN.Lemmas0
open Lib.IntTypes
open Lib.IntVector
open Lib.Sequence
open FStar.Mul
open FStar.Calc
open Hacl.Spec.Poly1305.Vec
include Hacl.Spec.Poly1305.Field32xN
#reset-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0"
val lemma_prime: unit -> Lemma (pow2 130 % prime = 5)
let lemma_prime () =
assert_norm (pow2 130 % prime = 5 % prime);
assert_norm (5 < prime);
FStar.Math.Lemmas.modulo_lemma 5 prime
val lemma_mult_le: a:nat -> b:nat -> c:nat -> d:nat -> Lemma
(requires a <= b /\ c <= d)
(ensures a * c <= b * d)
let lemma_mult_le a b c d = ()
val lemma_mul5_distr_l: a:nat -> b:nat -> c:nat -> d:nat -> e:nat -> f:nat -> Lemma
(a * (b + c + d + e + f) == a * b + a * c + a * d + a * e + a * f)
let lemma_mul5_distr_l a b c d e f = ()
val lemma_mul5_distr_r: a:nat -> b:nat -> c:nat -> d:nat -> e:nat -> f:nat -> Lemma
((a + b + c + d + e) * f == a * f + b * f + c * f + d * f + e * f)
let lemma_mul5_distr_r a b c d e f = ()
val smul_mod_lemma:
#m1:scale32
-> #m2:scale32
-> a:nat{a <= m1 * max26}
-> b:nat{b <= m2 * max26} ->
Lemma (a * b % pow2 64 == a * b)
let smul_mod_lemma #m1 #m2 a b =
lemma_mult_le a (m1 * max26) b (m2 * max26);
assert (a * b <= m1 * m2 * max26 * max26);
FStar.Math.Lemmas.modulo_lemma (a * b) (pow2 64)
val smul_add_mod_lemma:
#m1:scale32
-> #m2:scale32
-> #m3:scale64{m3 + m1 * m2 <= 4096}
-> a:nat{a <= m1 * max26}
-> b:nat{b <= m2 * max26}
-> c:nat{c <= m3 * max26 * max26} ->
Lemma ((c + a * b % pow2 64) % pow2 64 == c + a * b)
let smul_add_mod_lemma #m1 #m2 #m3 a b c =
assert_norm ((m3 + m1 * m2) * max26 * max26 < pow2 64);
lemma_mult_le a (m1 * max26) b (m2 * max26);
assert (c + a * b <= m3 * max26 * max26 + m1 * m2 * max26 * max26);
FStar.Math.Lemmas.modulo_lemma (c + a * b) (pow2 64)
val add5_lemma1: ma:scale64 -> mb:scale64 -> a:uint64 -> b:uint64 -> Lemma
(requires v a <= ma * max26 /\ v b <= mb * max26 /\ ma + mb <= 64)
(ensures v (a +. b) == v a + v b /\ v (a +. b) <= (ma + mb) * max26)
let add5_lemma1 ma mb a b =
assert (v a + v b <= (ma + mb) * max26);
Math.Lemmas.lemma_mult_le_right max26 (ma + mb) 64;
assert (v a + v b <= 64 * max26);
assert_norm (64 * max26 < pow2 32);
Math.Lemmas.small_mod (v a + v b) (pow2 32)
#set-options "--ifuel 1"
val fadd5_eval_lemma_i:
#w:lanes
-> f1:felem5 w{felem_fits5 f1 (2,2,2,2,2)}
-> f2:felem5 w{felem_fits5 f2 (1,1,1,1,1)}
-> i:nat{i < w} ->
Lemma ((feval5 (fadd5 f1 f2)).[i] == pfadd (feval5 f1).[i] (feval5 f2).[i])
let fadd5_eval_lemma_i #w f1 f2 i =
let o = fadd5 f1 f2 in
let (f10, f11, f12, f13, f14) = as_tup64_i f1 i in
let (f20, f21, f22, f23, f24) = as_tup64_i f2 i in
let (o0, o1, o2, o3, o4) = as_tup64_i o i in
add5_lemma1 2 1 f10 f20;
add5_lemma1 2 1 f11 f21;
add5_lemma1 2 1 f12 f22;
add5_lemma1 2 1 f13 f23;
add5_lemma1 2 1 f14 f24;
assert (as_nat5 (o0, o1, o2, o3, o4) ==
as_nat5 (f10, f11, f12, f13, f14) + as_nat5 (f20, f21, f22, f23, f24));
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (f10, f11, f12, f13, f14)) (as_nat5 (f20, f21, f22, f23, f24)) prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
(as_nat5 (f10, f11, f12, f13, f14) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime
val smul_felem5_fits_lemma_i:
#w:lanes
-> #m1:scale32
-> #m2:scale32
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:uint64xN w{felem_fits1 f2 m2}
-> i:nat{i < w} ->
Lemma ((uint64xN_v (vec_mul_mod f2 u1)).[i] <= m1 * m2 * max26 * max26)
let smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 i =
let o = vec_mul_mod f2 u1 in
smul_mod_lemma #m1 #m2 (uint64xN_v u1).[i] (uint64xN_v f2).[i];
assert ((uint64xN_v o).[i] == (uint64xN_v u1).[i] * (uint64xN_v f2).[i]);
lemma_mult_le (uint64xN_v u1).[i] (m1 * max26) (uint64xN_v f2).[i] (m2 * max26)
val smul_felem5_eval_lemma_i:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2}
-> i:nat{i < w} ->
Lemma ((fas_nat5 (smul_felem5 #w u1 f2)).[i] == (uint64xN_v u1).[i] * (fas_nat5 f2).[i])
let smul_felem5_eval_lemma_i #w #m1 #m2 u1 f2 i =
let o = smul_felem5 #w u1 f2 in
let (m20, m21, m22, m23, m24) = m2 in
let vu1 = (uint64xN_v u1).[i] in
let (tf20, tf21, tf22, tf23, tf24) = as_tup64_i f2 i in
let (to0, to1, to2, to3, to4) = as_tup64_i o i in
smul_mod_lemma #m1 #m20 vu1 (v tf20);
smul_mod_lemma #m1 #m21 vu1 (v tf21);
smul_mod_lemma #m1 #m22 vu1 (v tf22);
smul_mod_lemma #m1 #m23 vu1 (v tf23);
smul_mod_lemma #m1 #m24 vu1 (v tf24);
assert ((fas_nat5 o).[i] == vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 +
vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104);
calc (==) {
vu1 * (fas_nat5 f2).[i];
(==) { }
vu1 * (v tf20 + v tf21 * pow26 + v tf22 * pow52 + v tf23 * pow78 + v tf24 * pow104);
(==) { lemma_mul5_distr_l vu1 (v tf20) (v tf21 * pow26) (v tf22 * pow52) (v tf23 * pow78) (v tf24 * pow104)}
vu1 * v tf20 + vu1 * (v tf21 * pow26) + vu1 * (v tf22 * pow52) + vu1 * (v tf23 * pow78) + vu1 * (v tf24 * pow104);
(==) {
FStar.Math.Lemmas.paren_mul_right vu1 (v tf21) pow26;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf22) pow52;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf23) pow78;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf24) pow104}
vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 + vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104;
};
assert (vu1 * (fas_nat5 f2).[i] == (fas_nat5 o).[i])
val smul_felem5_fits_lemma1:
#w:lanes
-> #m1:scale32
-> #m2:scale32
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:uint64xN w{felem_fits1 f2 m2} ->
Lemma (felem_wide_fits1 (vec_mul_mod f2 u1) (m1 * m2))
let smul_felem5_fits_lemma1 #w #m1 #m2 u1 f2 =
match w with
| 1 ->
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 0
| 2 ->
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 0;
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 1
| 4 ->
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 0;
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 1;
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 2;
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 3
val smul_felem5_fits_lemma:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2} ->
Lemma (felem_wide_fits5 (smul_felem5 #w u1 f2) (m1 *^ m2))
let smul_felem5_fits_lemma #w #m1 #m2 u1 f2 =
let (f20, f21, f22, f23, f24) = f2 in
let (m20, m21, m22, m23, m24) = m2 in
smul_felem5_fits_lemma1 #w #m1 #m20 u1 f20;
smul_felem5_fits_lemma1 #w #m1 #m21 u1 f21;
smul_felem5_fits_lemma1 #w #m1 #m22 u1 f22;
smul_felem5_fits_lemma1 #w #m1 #m23 u1 f23;
smul_felem5_fits_lemma1 #w #m1 #m24 u1 f24
val smul_felem5_eval_lemma:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2} ->
Lemma (fas_nat5 (smul_felem5 #w u1 f2) ==
map2 #nat #nat #nat (fun a b -> a * b) (uint64xN_v u1) (fas_nat5 f2))
let smul_felem5_eval_lemma #w #m1 #m2 u1 f2 =
FStar.Classical.forall_intro (smul_felem5_eval_lemma_i #w #m1 #m2 u1 f2);
eq_intro (fas_nat5 (smul_felem5 #w u1 f2))
(map2 #nat #nat #nat (fun a b -> a * b) (uint64xN_v u1) (fas_nat5 f2))
val smul_add_felem5_fits_lemma_i:
#w:lanes
-> #m1:scale32
-> #m2:scale32
-> #m3:scale64{m3 + m1 * m2 <= 4096}
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:uint64xN w{felem_fits1 f2 m2}
-> acc1:uint64xN w{felem_wide_fits1 acc1 m3}
-> i:nat{i < w} ->
Lemma ((uint64xN_v (vec_add_mod acc1 (vec_mul_mod f2 u1))).[i] <= (m3 + m1 * m2) * max26 * max26)
#push-options "--z3rlimit 200"
let smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 i =
let o = vec_add_mod acc1 (vec_mul_mod f2 u1) in
smul_add_mod_lemma #m1 #m2 #m3 (uint64xN_v u1).[i] (uint64xN_v f2).[i] (uint64xN_v acc1).[i];
assert ((uint64xN_v o).[i] == (uint64xN_v acc1).[i] + (uint64xN_v u1).[i] * (uint64xN_v f2).[i]);
lemma_mult_le (uint64xN_v u1).[i] (m1 * max26) (uint64xN_v f2).[i] (m2 * max26);
assert ((uint64xN_v o).[i] <= m3 * max26 * max26 + m1 * m2 * max26 * max26)
#pop-options
val smul_add_felem5_eval_lemma_i:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> #m3:scale64_5{m3 +* m1 *^ m2 <=* s64x5 4096}
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2}
-> acc1:felem_wide5 w{felem_wide_fits5 acc1 m3}
-> i:nat{i < w} ->
Lemma ((fas_nat5 (smul_add_felem5 #w u1 f2 acc1)).[i] ==
(fas_nat5 acc1).[i] + (uint64xN_v u1).[i] * (fas_nat5 f2).[i])
let smul_add_felem5_eval_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 i =
let o = smul_add_felem5 #w u1 f2 acc1 in
let (m20, m21, m22, m23, m24) = m2 in
let (m30, m31, m32, m33, m34) = m3 in
let vu1 = (uint64xN_v u1).[i] in
let (tf20, tf21, tf22, tf23, tf24) = as_tup64_i f2 i in
let (ta0, ta1, ta2, ta3, ta4) = as_tup64_i acc1 i in
let (to0, to1, to2, to3, to4) = as_tup64_i o i in
smul_add_mod_lemma #m1 #m20 #m30 vu1 (v tf20) (v ta0);
smul_add_mod_lemma #m1 #m21 #m31 vu1 (v tf21) (v ta1);
smul_add_mod_lemma #m1 #m22 #m32 vu1 (v tf22) (v ta2);
smul_add_mod_lemma #m1 #m23 #m33 vu1 (v tf23) (v ta3);
smul_add_mod_lemma #m1 #m24 #m34 vu1 (v tf24) (v ta4);
calc (==) {
(fas_nat5 o).[i];
(==) { }
v ta0 + vu1 * v tf20 + (v ta1 + vu1 * v tf21) * pow26 + (v ta2 + vu1 * v tf22) * pow52 +
(v ta3 + vu1 * v tf23) * pow78 + (v ta4 + vu1 * v tf24) * pow104;
(==) {
FStar.Math.Lemmas.distributivity_add_left (v ta1) (vu1 * v tf21) pow26;
FStar.Math.Lemmas.distributivity_add_left (v ta2) (vu1 * v tf22) pow52;
FStar.Math.Lemmas.distributivity_add_left (v ta3) (vu1 * v tf23) pow78;
FStar.Math.Lemmas.distributivity_add_left (v ta1) (vu1 * v tf24) pow104 }
v ta0 + v ta1 * pow26 + v ta2 * pow52 + v ta3 * pow78 + v ta4 * pow104 +
vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 + vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104;
(==) { }
(fas_nat5 acc1).[i] + vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 + vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104;
};
assert ((fas_nat5 o).[i] == (fas_nat5 acc1).[i] +
vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 + vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104);
calc (==) {
vu1 * (fas_nat5 f2).[i];
(==) { }
vu1 * (v tf20 + v tf21 * pow26 + v tf22 * pow52 + v tf23 * pow78 + v tf24 * pow104);
(==) { lemma_mul5_distr_l vu1 (v tf20) (v tf21 * pow26) (v tf22 * pow52) (v tf23 * pow78) (v tf24 * pow104)}
vu1 * v tf20 + vu1 * (v tf21 * pow26) + vu1 * (v tf22 * pow52) + vu1 * (v tf23 * pow78) + vu1 * (v tf24 * pow104);
(==) {
FStar.Math.Lemmas.paren_mul_right vu1 (v tf21) pow26;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf22) pow52;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf23) pow78;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf24) pow104}
vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 + vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104;
};
assert ((fas_nat5 o).[i] == (fas_nat5 acc1).[i] + vu1 * (fas_nat5 f2).[i])
val smul_add_felem5_fits_lemma1:
#w:lanes
-> #m1:scale32
-> #m2:scale32
-> #m3:scale64{m3 + m1 * m2 <= 4096}
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:uint64xN w{felem_fits1 f2 m2}
-> acc1:uint64xN w{felem_wide_fits1 acc1 m3} ->
Lemma (felem_wide_fits1 (vec_add_mod acc1 (vec_mul_mod f2 u1)) (m3 + m1 * m2))
let smul_add_felem5_fits_lemma1 #w #m1 #m2 #m3 u1 f2 acc1 =
match w with
| 1 ->
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 0
| 2 ->
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 0;
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 1
| 4 ->
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 0;
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 1;
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 2;
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 3
val smul_add_felem5_fits_lemma:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> #m3:scale64_5{m3 +* m1 *^ m2 <=* s64x5 4096}
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2}
-> acc1:felem_wide5 w{felem_wide_fits5 acc1 m3} ->
Lemma (felem_wide_fits5 (smul_add_felem5 #w u1 f2 acc1) (m3 +* m1 *^ m2))
let smul_add_felem5_fits_lemma #w #m1 #m2 #m3 u1 f2 acc1 =
let (f20, f21, f22, f23, f24) = f2 in
let (m20, m21, m22, m23, m24) = m2 in
let (a0, a1, a2, a3, a4) = acc1 in
let (m30, m31, m32, m33, m34) = m3 in
smul_add_felem5_fits_lemma1 #w #m1 #m20 #m30 u1 f20 a0;
smul_add_felem5_fits_lemma1 #w #m1 #m21 #m31 u1 f21 a1;
smul_add_felem5_fits_lemma1 #w #m1 #m22 #m32 u1 f22 a2;
smul_add_felem5_fits_lemma1 #w #m1 #m23 #m33 u1 f23 a3;
smul_add_felem5_fits_lemma1 #w #m1 #m24 #m34 u1 f24 a4
val smul_add_felem5_eval_lemma:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> #m3:scale64_5{m3 +* m1 *^ m2 <=* s64x5 4096}
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2}
-> acc1:felem_wide5 w{felem_wide_fits5 acc1 m3} ->
Lemma (fas_nat5 (smul_add_felem5 #w u1 f2 acc1) ==
map2 #nat #nat #nat (fun a b -> a + b) (fas_nat5 acc1)
(map2 #nat #nat #nat (fun a b -> a * b) (uint64xN_v u1) (fas_nat5 f2)))
let smul_add_felem5_eval_lemma #w #m1 #m2 #m3 u1 f2 acc1 =
let tmp =
map2 #nat #nat #nat (fun a b -> a + b) (fas_nat5 acc1)
(map2 #nat #nat #nat (fun a b -> a * b) (uint64xN_v u1) (fas_nat5 f2)) in
FStar.Classical.forall_intro (smul_add_felem5_eval_lemma_i #w #m1 #m2 #m3 u1 f2 acc1);
eq_intro (fas_nat5 (smul_add_felem5 #w u1 f2 acc1)) tmp
val lemma_fmul5_pow26: r:tup64_5 -> Lemma
(requires (let (r0, r1, r2, r3, r4) = r in v r4 * 5 <= 10 * pow26))
(ensures (let (r0, r1, r2, r3, r4) = r in
(pow26 * as_nat5 r) % prime == as_nat5 (r4 *! u64 5, r0, r1, r2, r3) % prime))
let lemma_fmul5_pow26 r =
let (r0, r1, r2, r3, r4) = r in
calc (==) {
(pow26 * as_nat5 r) % prime;
(==) { }
(pow26 * (v r0 + v r1 * pow26 + v r2 * pow52 + v r3 * pow78 + v r4 * pow104)) % prime;
(==) { lemma_mul5_distr_l pow26 (v r0) (v r1 * pow26) (v r2 * pow52) (v r3 * pow78) (v r4 * pow104) }
(v r0 * pow26 + pow26 * v r1 * pow26 + pow26 * v r2 * pow52 + pow26 * v r3 * pow78 + pow26 * v r4 * pow104) % prime;
(==) { }
(v r0 * pow26 + v r1 * pow26 * pow26 + v r2 * pow26 * pow52 + v r3 * pow26 * pow78 + v r4 * pow26 * pow104) % prime;
(==) {
assert_norm (pow26 * pow26 = pow52);
assert_norm (pow26 * pow52 = pow78);
assert_norm (pow26 * pow78 = pow104);
assert_norm (pow26 * pow104 = pow2 130) }
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + v r4 * pow2 130) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104) (v r4 * pow2 130) prime }
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + (v r4 * pow2 130) % prime) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (v r4) (pow2 130) prime }
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + (v r4 * (pow2 130 % prime)) % prime) % prime;
(==) { lemma_prime () }
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + (v r4 * 5) % prime) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104) (v r4 * 5) prime }
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + v r4 * 5) % prime;
};
assert ((pow26 * as_nat5 r) % prime ==
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + v r4 * 5) % prime)
val lemma_fmul5_pow52: r:tup64_5 -> Lemma
(requires (let (r0, r1, r2, r3, r4) = r in
v r4 * 5 <= 10 * pow26 /\ v r3 * 5 <= 10 * pow26))
(ensures (let (r0, r1, r2, r3, r4) = r in
(pow52 * as_nat5 r) % prime == as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) % prime))
let lemma_fmul5_pow52 r =
let (r0, r1, r2, r3, r4) = r in
calc (==) {
(pow52 * as_nat5 r) % prime;
(==) { assert_norm (pow52 == pow26 * pow26) }
(pow26 * pow26 * as_nat5 r) % prime;
(==) {
FStar.Math.Lemmas.paren_mul_right pow26 pow26 (as_nat5 r);
FStar.Math.Lemmas.lemma_mod_mul_distr_r pow26 (pow26 * as_nat5 r) prime }
(pow26 * (pow26 * as_nat5 r % prime)) % prime;
(==) { lemma_fmul5_pow26 r }
(pow26 * (as_nat5 (r4 *! u64 5, r0, r1, r2, r3) % prime)) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r pow26 (as_nat5 (r4 *! u64 5, r0, r1, r2, r3)) prime }
(pow26 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3)) % prime;
(==) { lemma_fmul5_pow26 (r4 *! u64 5, r0, r1, r2, r3) }
as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) % prime;
};
assert ((pow52 * as_nat5 r) % prime == as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) % prime)
val lemma_fmul5_pow78: r:tup64_5 -> Lemma
(requires (let (r0, r1, r2, r3, r4) = r in
v r4 * 5 <= 10 * pow26 /\ v r3 * 5 <= 10 * pow26 /\ v r2 * 5 <= 10 * pow26))
(ensures (let (r0, r1, r2, r3, r4) = r in
(pow78 * as_nat5 r) % prime == as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) % prime))
let lemma_fmul5_pow78 r =
let (r0, r1, r2, r3, r4) = r in
calc (==) {
(pow78 * as_nat5 r) % prime;
(==) { assert_norm (pow78 == pow26 * pow52) }
(pow26 * pow52 * as_nat5 r) % prime;
(==) {
FStar.Math.Lemmas.paren_mul_right pow26 pow52 (as_nat5 r);
FStar.Math.Lemmas.lemma_mod_mul_distr_r pow26 (pow52 * as_nat5 r) prime }
(pow26 * (pow52 * as_nat5 r % prime)) % prime;
(==) { lemma_fmul5_pow52 r }
(pow26 * (as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) % prime)) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r pow26 (as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2)) prime }
(pow26 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2)) % prime;
(==) { lemma_fmul5_pow26 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) }
as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) % prime;
};
assert ((pow78 * as_nat5 r) % prime == as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) % prime)
val lemma_fmul5_pow104: r:tup64_5 -> Lemma
(requires (let (r0, r1, r2, r3, r4) = r in
v r4 * 5 <= 10 * pow26 /\ v r3 * 5 <= 10 * pow26 /\
v r2 * 5 <= 10 * pow26 /\ v r1 * 5 <= 10 * pow26))
(ensures (let (r0, r1, r2, r3, r4) = r in
(pow104 * as_nat5 r) % prime == as_nat5 (r1 *! u64 5, r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0) % prime))
let lemma_fmul5_pow104 r =
let (r0, r1, r2, r3, r4) = r in
calc (==) {
(pow104 * as_nat5 r) % prime;
(==) { assert_norm (pow104 == pow26 * pow78) }
(pow26 * pow78 * as_nat5 r) % prime;
(==) {
FStar.Math.Lemmas.paren_mul_right pow26 pow78 (as_nat5 r);
FStar.Math.Lemmas.lemma_mod_mul_distr_r pow26 (pow78 * as_nat5 r) prime }
(pow26 * (pow78 * as_nat5 r % prime)) % prime;
(==) { lemma_fmul5_pow78 r }
(pow26 * (as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) % prime)) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r pow26 (as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1)) prime }
(pow26 * as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1)) % prime;
(==) { lemma_fmul5_pow26 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) }
as_nat5 (r1 *! u64 5, r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0) % prime;
};
assert ((pow104 * as_nat5 r) % prime == as_nat5 (r1 *! u64 5, r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0) % prime)
val mul_felem5_lemma_1:
f1:tup64_5{tup64_fits5 f1 (3, 3, 3, 3, 3)}
-> r:tup64_5{tup64_fits5 r (2, 2, 2, 2, 2)} ->
Lemma
(let (f10, f11, f12, f13, f14) = f1 in
let (r0, r1, r2, r3, r4) = r in
(as_nat5 f1 * as_nat5 r) % prime ==
(v f10 * as_nat5 r +
v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) +
v f12 * pow52 * as_nat5 r + v f13 * pow78 * as_nat5 r + v f14 * pow104 * as_nat5 r) % prime)
let mul_felem5_lemma_1 f1 r =
let (f10, f11, f12, f13, f14) = f1 in
let (r0, r1, r2, r3, r4) = r in
let tmp = v f10 * as_nat5 r + v f12 * pow52 * as_nat5 r + v f13 * pow78 * as_nat5 r + v f14 * pow104 * as_nat5 r in
calc (==) {
(as_nat5 f1 * as_nat5 r) % prime;
(==) { }
(v f10 + v f11 * pow26 + v f12 * pow52 + v f13 * pow78 + v f14 * pow104) * as_nat5 r % prime;
(==) { lemma_mul5_distr_r (v f10) (v f11 * pow26) (v f12 * pow52) (v f13 * pow78) (v f14 * pow104) (as_nat5 r) }
(v f10 * as_nat5 r + v f11 * pow26 * as_nat5 r + v f12 * pow52 * as_nat5 r + v f13 * pow78 * as_nat5 r + v f14 * pow104 * as_nat5 r) % prime;
(==) {
FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp (v f11 * pow26 * as_nat5 r) prime }
(tmp + (v f11 * pow26 * as_nat5 r) % prime) % prime;
(==) {
FStar.Math.Lemmas.paren_mul_right (v f11) pow26 (as_nat5 r);
FStar.Math.Lemmas.lemma_mod_mul_distr_r (v f11) (pow26 * as_nat5 r) prime }
(tmp + v f11 * (pow26 * as_nat5 r % prime) % prime) % prime;
(==) { lemma_fmul5_pow26 r }
(tmp + v f11 * (as_nat5 (r4 *! u64 5, r0, r1, r2, r3) % prime) % prime) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (v f11) (as_nat5 (r4 *! u64 5, r0, r1, r2, r3)) prime }
(tmp + v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) % prime) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp (v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3)) prime }
(tmp + v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3)) % prime;
};
assert ((as_nat5 f1 * as_nat5 r) % prime == (tmp + v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3)) % prime)
val mul_felem5_lemma_2:
f1:tup64_5{tup64_fits5 f1 (3, 3, 3, 3, 3)}
-> r:tup64_5{tup64_fits5 r (2, 2, 2, 2, 2)} ->
Lemma
(let (f10, f11, f12, f13, f14) = f1 in
let (r0, r1, r2, r3, r4) = r in
(as_nat5 f1 * as_nat5 r) % prime ==
(v f10 * as_nat5 r +
v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) +
v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) +
v f13 * pow78 * as_nat5 r + v f14 * pow104 * as_nat5 r) % prime)
let mul_felem5_lemma_2 f1 r =
let (f10, f11, f12, f13, f14) = f1 in
let (r0, r1, r2, r3, r4) = r in
let tmp =
v f10 * as_nat5 r + v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) +
v f13 * pow78 * as_nat5 r + v f14 * pow104 * as_nat5 r in
calc (==) {
(as_nat5 f1 * as_nat5 r) % prime;
(==) { mul_felem5_lemma_1 f1 r }
(tmp + v f12 * pow52 * as_nat5 r) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp (v f12 * pow52 * as_nat5 r) prime }
(tmp + (v f12 * pow52 * as_nat5 r) % prime) % prime;
(==) {
FStar.Math.Lemmas.paren_mul_right (v f12) pow52 (as_nat5 r);
FStar.Math.Lemmas.lemma_mod_mul_distr_r (v f12) (pow52 * as_nat5 r) prime }
(tmp + v f12 * (pow52 * as_nat5 r % prime) % prime) % prime;
(==) { lemma_fmul5_pow52 r }
(tmp + v f12 * (as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) % prime) % prime) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (v f12) (as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2)) prime }
(tmp + v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) % prime) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp (v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2)) prime }
(tmp + v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2)) % prime;
};
assert ((as_nat5 f1 * as_nat5 r) % prime == (tmp + v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2)) % prime)
val mul_felem5_lemma_3:
f1:tup64_5{tup64_fits5 f1 (3, 3, 3, 3, 3)}
-> r:tup64_5{tup64_fits5 r (2, 2, 2, 2, 2)} ->
Lemma
(let (f10, f11, f12, f13, f14) = f1 in
let (r0, r1, r2, r3, r4) = r in
(as_nat5 f1 * as_nat5 r) % prime ==
(v f10 * as_nat5 r +
v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) +
v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) +
v f13 * as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) +
v f14 * pow104 * as_nat5 r) % prime)
let mul_felem5_lemma_3 f1 r =
let (f10, f11, f12, f13, f14) = f1 in
let (r0, r1, r2, r3, r4) = r in
let tmp =
v f10 * as_nat5 r + v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) +
v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) + v f14 * pow104 * as_nat5 r in
calc (==) {
(as_nat5 f1 * as_nat5 r) % prime;
(==) { mul_felem5_lemma_2 f1 r }
(tmp + v f13 * pow78 * as_nat5 r) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp (v f13 * pow78 * as_nat5 r) prime }
(tmp + (v f13 * pow78 * as_nat5 r) % prime) % prime;
(==) {
FStar.Math.Lemmas.paren_mul_right (v f13) pow78 (as_nat5 r);
FStar.Math.Lemmas.lemma_mod_mul_distr_r (v f13) (pow78 * as_nat5 r) prime }
(tmp + v f13 * (pow78 * as_nat5 r % prime) % prime) % prime;
(==) { lemma_fmul5_pow78 r }
(tmp + v f13 * (as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) % prime) % prime) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (v f13) (as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1)) prime }
(tmp + v f13 * as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) % prime) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp (v f13 * as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1)) prime }
(tmp + v f13 * as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1)) % prime;
};
assert ((as_nat5 f1 * as_nat5 r) % prime == (tmp + v f13 * as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1)) % prime)
val mul_felem5_lemma_4:
f1:tup64_5{tup64_fits5 f1 (3, 3, 3, 3, 3)}
-> r:tup64_5{tup64_fits5 r (2, 2, 2, 2, 2)} ->
Lemma
(let (f10, f11, f12, f13, f14) = f1 in
let (r0, r1, r2, r3, r4) = r in
(as_nat5 f1 * as_nat5 r) % prime ==
(v f10 * as_nat5 r +
v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) +
v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) +
v f13 * as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1) +
v f14 * as_nat5 (r1 *! u64 5, r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0)) % prime) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Poly1305.Vec.fst.checked",
"Hacl.Spec.Poly1305.Field32xN.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Poly1305.Field32xN.Lemmas0.fst"
} | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Poly1305.Field32xN",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Poly1305.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Poly1305.Field32xN",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Poly1305.Field32xN",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
f1:
Hacl.Spec.Poly1305.Field32xN.tup64_5
{Hacl.Spec.Poly1305.Field32xN.tup64_fits5 f1 (3, 3, 3, 3, 3)} ->
r:
Hacl.Spec.Poly1305.Field32xN.tup64_5
{Hacl.Spec.Poly1305.Field32xN.tup64_fits5 r (2, 2, 2, 2, 2)}
-> FStar.Pervasives.Lemma
(ensures
(let _ = f1 in
(let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ f10 f11 f12 f13 f14 = _ in
let _ = r in
(let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ r0 r1 r2 r3 r4 = _ in
Hacl.Spec.Poly1305.Field32xN.as_nat5 f1 * Hacl.Spec.Poly1305.Field32xN.as_nat5 r %
Hacl.Spec.Poly1305.Vec.prime ==
(Lib.IntTypes.v f10 * Hacl.Spec.Poly1305.Field32xN.as_nat5 r +
Lib.IntTypes.v f11 *
Hacl.Spec.Poly1305.Field32xN.as_nat5 (r4 *! Lib.IntTypes.u64 5, r0, r1, r2, r3) +
Lib.IntTypes.v f12 *
Hacl.Spec.Poly1305.Field32xN.as_nat5 (r3 *! Lib.IntTypes.u64 5,
r4 *! Lib.IntTypes.u64 5,
r0,
r1,
r2) +
Lib.IntTypes.v f13 *
Hacl.Spec.Poly1305.Field32xN.as_nat5 (r2 *! Lib.IntTypes.u64 5,
r3 *! Lib.IntTypes.u64 5,
r4 *! Lib.IntTypes.u64 5,
r0,
r1) +
Lib.IntTypes.v f14 *
Hacl.Spec.Poly1305.Field32xN.as_nat5 (r1 *! Lib.IntTypes.u64 5,
r2 *! Lib.IntTypes.u64 5,
r3 *! Lib.IntTypes.u64 5,
r4 *! Lib.IntTypes.u64 5,
r0)) %
Hacl.Spec.Poly1305.Vec.prime)
<:
Type0)
<:
Type0)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Hacl.Spec.Poly1305.Field32xN.tup64_5",
"Hacl.Spec.Poly1305.Field32xN.tup64_fits5",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Lib.IntTypes.uint64",
"Prims._assert",
"Prims.eq2",
"Prims.int",
"Prims.op_Modulus",
"FStar.Mul.op_Star",
"Hacl.Spec.Poly1305.Field32xN.as_nat5",
"Hacl.Spec.Poly1305.Vec.prime",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.u64",
"Prims.unit",
"FStar.Calc.calc_finish",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"FStar.Calc.calc_step",
"Hacl.Spec.Poly1305.Field32xN.pow104",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Hacl.Poly1305.Field32xN.Lemmas0.mul_felem5_lemma_3",
"Prims.squash",
"FStar.Math.Lemmas.lemma_mod_plus_distr_r",
"FStar.Math.Lemmas.lemma_mod_mul_distr_r",
"FStar.Math.Lemmas.paren_mul_right",
"Hacl.Poly1305.Field32xN.Lemmas0.lemma_fmul5_pow104"
] | [] | false | false | true | false | false | let mul_felem5_lemma_4 f1 r =
| let f10, f11, f12, f13, f14 = f1 in
let r0, r1, r2, r3, r4 = r in
let tmp =
v f10 * as_nat5 r + v f11 * as_nat5 (r4 *! u64 5, r0, r1, r2, r3) +
v f12 * as_nat5 (r3 *! u64 5, r4 *! u64 5, r0, r1, r2) +
v f13 * as_nat5 (r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0, r1)
in
calc ( == ) {
(as_nat5 f1 * as_nat5 r) % prime;
( == ) { mul_felem5_lemma_3 f1 r }
(tmp + (v f14 * pow104) * as_nat5 r) % prime;
( == ) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp ((v f14 * pow104) * as_nat5 r) prime }
(tmp + ((v f14 * pow104) * as_nat5 r) % prime) % prime;
( == ) { (FStar.Math.Lemmas.paren_mul_right (v f14) pow104 (as_nat5 r);
FStar.Math.Lemmas.lemma_mod_mul_distr_r (v f14) (pow104 * as_nat5 r) prime) }
(tmp + v f14 * (pow104 * as_nat5 r % prime) % prime) % prime;
( == ) { lemma_fmul5_pow104 r }
(tmp + v f14 * (as_nat5 (r1 *! u64 5, r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0) % prime) % prime) %
prime;
( == ) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (v f14)
(as_nat5 (r1 *! u64 5, r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0))
prime }
(tmp + v f14 * as_nat5 (r1 *! u64 5, r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0) % prime) % prime;
( == ) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp
(v f14 * as_nat5 (r1 *! u64 5, r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0))
prime }
(tmp + v f14 * as_nat5 (r1 *! u64 5, r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0)) % prime;
};
assert ((as_nat5 f1 * as_nat5 r) % prime ==
(tmp + v f14 * as_nat5 (r1 *! u64 5, r2 *! u64 5, r3 *! u64 5, r4 *! u64 5, r0)) % prime) | false |
MerkleTree.fsti | MerkleTree.mt_get_path | val mt_get_path
(#h: HS.mem)
(mt: const_mt_p)
(idx: offset_t)
(path: path_p{path_hash_size #h path = const_tree_hash_size #h mt})
(root: hash #(path_hash_size #h path))
: HST.ST index_t pf pt | val mt_get_path
(#h: HS.mem)
(mt: const_mt_p)
(idx: offset_t)
(path: path_p{path_hash_size #h path = const_tree_hash_size #h mt})
(root: hash #(path_hash_size #h path))
: HST.ST index_t pf pt | let mt_get_path
(#h:HS.mem)
(mt:const_mt_p)
(idx:offset_t)
(path:path_p{path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(path_hash_size #h path))
: HST.ST index_t pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_path #hash_size mt idx path root | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 46,
"end_line": 197,
"start_col": 0,
"start_line": 189
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r
[@ (Comment " Destructor for hashes") "c_inline"]
let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h
[@ (Comment " Constructor for paths") "c_inline"]
let mt_init_path (hash_size:hash_size_t) (mtr:HH.rid) (r:HST.erid): HST.ST path_p pf pt = MTNL.init_path hash_size mtr r
[@ (Comment " Destructor for paths") "c_inline"]
let mt_free_path (path:path_p): HST.ST unit pf pt = MTNL.free_path path
[@ (Comment " Length of a path
@param[in] p Path
return The length of the path") "c_inline"]
let mt_get_path_length (mtr:HH.rid) (path:const_path_p): HST.ST U32.t pf pt = MTNL.mt_get_path_length mtr path
[@ (Comment " Insert hash into path
@param[in] p Path
@param[in] hash Hash to insert") "c_inline"]
let mt_path_insert
(#h:HS.mem)
(#mtr:HH.rid)
(path:path_p)
(hash:hash #(MTNL.Path?.hash_size (B.get h path 0)))
: HST.ST unit pf pt
= let hash_size = MTNL.Path?.hash_size (B.index path 0ul) in
MTNL.mt_path_insert #hash_size mtr path hash
inline_for_extraction
let path_hash_size (#h:HS.mem) (path:path_p) = MTNL.Path?.hash_size (B.get h path 0)
inline_for_extraction
let const_path_hash_size (#h:HS.mem) (path:const_path_p) = path_hash_size #h (CB.cast path)
inline_for_extraction
let tree_hash_size (#h:HS.mem) (mt:mt_p) = MTNL.MT?.hash_size (B.get h mt 0)
inline_for_extraction
let const_tree_hash_size (#h:HS.mem) (mt:const_mt_p) = tree_hash_size #h (CB.cast mt)
[@ (Comment " Get step on a path
@param[in] p Path
@param[in] i Path step index
return The hash at step i of p") "c_inline"]
let mt_get_path_step
(#h:HS.mem)
(#mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST (hash #(const_path_hash_size #h path)) pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step #hash_size mtr path i
[@ (Comment " Precondition predicate for mt_get_path_step") "c_inline"]
let mt_get_path_step_pre
(#h:HS.mem)
(mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST bool pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step_pre #hash_size mtr path i
[@ (Comment " Construction with custom hash functions
@param[in] hash_size Hash size (in bytes)
@param[in] i The initial hash
return The new Merkle tree") "c_inline"]
let mt_create_custom
(hash_size:hash_size_t)
(hash_spec:Ghost.erased (MTS.hash_fun_t #(U32.v hash_size)))
(r:HST.erid)
(i:hash #hash_size)
(hash_fun:MTNLHF.hash_fun_t #hash_size #hash_spec)
: HST.ST mt_p pf pt
= MTNL.mt_create_custom hash_size hash_spec r i hash_fun
[@ (Comment " Destruction
@param[in] mt The Merkle tree") "c_inline"]
let mt_free (mt:mt_p): HST.ST unit pf pt = MTNL.mt_free mt
[@ (Comment " Insertion
@param[in] mt The Merkle tree
@param[in] v The tree does not take ownership of the hash, it makes a copy of its content.
Note: The content of the hash will be overwritten with an arbitrary value.") "c_inline"]
let mt_insert
(#h:HS.mem)
(mt:mt_p)
(v:hash #(tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index mt 0ul) in
MTNL.mt_insert hash_size mt v
[@ (Comment " Precondition predicate for mt_insert") "c_inline"]
let mt_insert_pre
(#h:HS.mem)
(mt:const_mt_p)
(v:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_insert_pre #hash_size mt v
[@ (Comment " Getting the Merkle root
@param[in] mt The Merkle tree
@param[out] root The Merkle root") "c_inline"]
let mt_get_root
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root #hash_size mt root
[@ (Comment " Precondition predicate for mt_get_root") "c_inline"]
let mt_get_root_pre
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root_pre #hash_size mt root
[@ (Comment " Getting a Merkle path
@param[in] mt The Merkle tree
@param[in] idx The index of the target hash
@param[out] path A resulting Merkle path that contains the leaf hash.
@param[out] root The Merkle root
return The number of elements in the tree
Notes:
- The resulting path contains pointers to hashes in the tree, not copies of
the hash values.
- idx must be within the currently held indices in the tree (past the | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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.const_mt_p ->
idx: MerkleTree.offset_t ->
path: MerkleTree.path_p{MerkleTree.path_hash_size path = MerkleTree.const_tree_hash_size mt} ->
root: MerkleTree.hash
-> FStar.HyperStack.ST.ST MerkleTree.index_t | FStar.HyperStack.ST.ST | [] | [] | [
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.const_mt_p",
"MerkleTree.offset_t",
"MerkleTree.path_p",
"Prims.b2t",
"Prims.op_Equality",
"MerkleTree.Low.Datastructures.hash_size_t",
"MerkleTree.path_hash_size",
"MerkleTree.const_tree_hash_size",
"MerkleTree.hash",
"MerkleTree.Low.mt_get_path",
"FStar.Ghost.hide",
"MerkleTree.Low.index_t",
"MerkleTree.Low.__proj__MT__item__hash_size",
"MerkleTree.Low.merkle_tree",
"LowStar.Monotonic.Buffer.index",
"LowStar.ConstBuffer.qbuf_pre",
"LowStar.ConstBuffer.as_qbuf",
"LowStar.ConstBuffer.cast",
"FStar.UInt32.__uint_to_t",
"MerkleTree.index_t",
"MerkleTree.pf",
"MerkleTree.pt"
] | [] | false | true | false | false | false | let mt_get_path
(#h: HS.mem)
(mt: const_mt_p)
(idx: offset_t)
(path: path_p{path_hash_size #h path = const_tree_hash_size #h mt})
(root: hash #(path_hash_size #h path))
: HST.ST index_t pf pt =
| let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_path #hash_size mt idx path root | false |
MerkleTree.fsti | MerkleTree.mt_retract_to | val mt_retract_to (mt: mt_p) (idx: offset_t) : HST.ST unit pf pt | val mt_retract_to (mt: mt_p) (idx: offset_t) : HST.ST unit pf pt | let mt_retract_to (mt:mt_p) (idx:offset_t): HST.ST unit pf pt = MTNL.mt_retract_to mt idx | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 89,
"end_line": 236,
"start_col": 0,
"start_line": 236
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r
[@ (Comment " Destructor for hashes") "c_inline"]
let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h
[@ (Comment " Constructor for paths") "c_inline"]
let mt_init_path (hash_size:hash_size_t) (mtr:HH.rid) (r:HST.erid): HST.ST path_p pf pt = MTNL.init_path hash_size mtr r
[@ (Comment " Destructor for paths") "c_inline"]
let mt_free_path (path:path_p): HST.ST unit pf pt = MTNL.free_path path
[@ (Comment " Length of a path
@param[in] p Path
return The length of the path") "c_inline"]
let mt_get_path_length (mtr:HH.rid) (path:const_path_p): HST.ST U32.t pf pt = MTNL.mt_get_path_length mtr path
[@ (Comment " Insert hash into path
@param[in] p Path
@param[in] hash Hash to insert") "c_inline"]
let mt_path_insert
(#h:HS.mem)
(#mtr:HH.rid)
(path:path_p)
(hash:hash #(MTNL.Path?.hash_size (B.get h path 0)))
: HST.ST unit pf pt
= let hash_size = MTNL.Path?.hash_size (B.index path 0ul) in
MTNL.mt_path_insert #hash_size mtr path hash
inline_for_extraction
let path_hash_size (#h:HS.mem) (path:path_p) = MTNL.Path?.hash_size (B.get h path 0)
inline_for_extraction
let const_path_hash_size (#h:HS.mem) (path:const_path_p) = path_hash_size #h (CB.cast path)
inline_for_extraction
let tree_hash_size (#h:HS.mem) (mt:mt_p) = MTNL.MT?.hash_size (B.get h mt 0)
inline_for_extraction
let const_tree_hash_size (#h:HS.mem) (mt:const_mt_p) = tree_hash_size #h (CB.cast mt)
[@ (Comment " Get step on a path
@param[in] p Path
@param[in] i Path step index
return The hash at step i of p") "c_inline"]
let mt_get_path_step
(#h:HS.mem)
(#mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST (hash #(const_path_hash_size #h path)) pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step #hash_size mtr path i
[@ (Comment " Precondition predicate for mt_get_path_step") "c_inline"]
let mt_get_path_step_pre
(#h:HS.mem)
(mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST bool pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step_pre #hash_size mtr path i
[@ (Comment " Construction with custom hash functions
@param[in] hash_size Hash size (in bytes)
@param[in] i The initial hash
return The new Merkle tree") "c_inline"]
let mt_create_custom
(hash_size:hash_size_t)
(hash_spec:Ghost.erased (MTS.hash_fun_t #(U32.v hash_size)))
(r:HST.erid)
(i:hash #hash_size)
(hash_fun:MTNLHF.hash_fun_t #hash_size #hash_spec)
: HST.ST mt_p pf pt
= MTNL.mt_create_custom hash_size hash_spec r i hash_fun
[@ (Comment " Destruction
@param[in] mt The Merkle tree") "c_inline"]
let mt_free (mt:mt_p): HST.ST unit pf pt = MTNL.mt_free mt
[@ (Comment " Insertion
@param[in] mt The Merkle tree
@param[in] v The tree does not take ownership of the hash, it makes a copy of its content.
Note: The content of the hash will be overwritten with an arbitrary value.") "c_inline"]
let mt_insert
(#h:HS.mem)
(mt:mt_p)
(v:hash #(tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index mt 0ul) in
MTNL.mt_insert hash_size mt v
[@ (Comment " Precondition predicate for mt_insert") "c_inline"]
let mt_insert_pre
(#h:HS.mem)
(mt:const_mt_p)
(v:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_insert_pre #hash_size mt v
[@ (Comment " Getting the Merkle root
@param[in] mt The Merkle tree
@param[out] root The Merkle root") "c_inline"]
let mt_get_root
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root #hash_size mt root
[@ (Comment " Precondition predicate for mt_get_root") "c_inline"]
let mt_get_root_pre
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root_pre #hash_size mt root
[@ (Comment " Getting a Merkle path
@param[in] mt The Merkle tree
@param[in] idx The index of the target hash
@param[out] path A resulting Merkle path that contains the leaf hash.
@param[out] root The Merkle root
return The number of elements in the tree
Notes:
- The resulting path contains pointers to hashes in the tree, not copies of
the hash values.
- idx must be within the currently held indices in the tree (past the
last flush index).") "c_inline"]
let mt_get_path
(#h:HS.mem)
(mt:const_mt_p)
(idx:offset_t)
(path:path_p{path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(path_hash_size #h path))
: HST.ST index_t pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_path #hash_size mt idx path root
[@ (Comment " Precondition predicate for mt_get_path") "c_inline"]
let mt_get_path_pre
(#h:HS.mem)
(mt:const_mt_p)
(idx:offset_t)
(path:const_path_p{const_path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(const_path_hash_size #h path))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_path_pre #hash_size mt idx path root
[@ (Comment " Flush the Merkle tree
@param[in] mt The Merkle tree") "c_inline"]
let mt_flush (mt:mt_p): HST.ST unit pf pt = MTNL.mt_flush mt
[@ (Comment " Precondition predicate for mt_flush") "c_inline"]
let mt_flush_pre (mt:const_mt_p): HST.ST bool pf pt = MTNL.mt_flush_pre mt
[@ (Comment " Flush the Merkle tree up to a given index
@param[in] mt The Merkle tree
@param[in] idx The index up to which to flush the tree") "c_inline"]
let mt_flush_to (mt:mt_p) (idx:offset_t): HST.ST unit pf pt = MTNL.mt_flush_to mt idx
[@ (Comment " Precondition predicate for mt_flush_to")]
let mt_flush_to_pre (mt:const_mt_p) (idx:offset_t): HST.ST bool pf pt = MTNL.mt_flush_to_pre mt idx
[@ (Comment " Retract the Merkle tree down to a given index
@param[in] mt The Merkle tree
@param[in] idx The index to retract the tree to | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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.mt_p -> idx: MerkleTree.offset_t -> FStar.HyperStack.ST.ST Prims.unit | FStar.HyperStack.ST.ST | [] | [] | [
"MerkleTree.mt_p",
"MerkleTree.offset_t",
"MerkleTree.Low.mt_retract_to",
"Prims.unit",
"MerkleTree.pf",
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.pt"
] | [] | false | true | false | false | false | let mt_retract_to (mt: mt_p) (idx: offset_t) : HST.ST unit pf pt =
| MTNL.mt_retract_to mt idx | false |
Vale.X64.InsSha.fsti | Vale.X64.InsSha.va_quick_SHA256_rnds2 | val va_quick_SHA256_rnds2
(dst src: va_operand_xmm)
(t: counter)
(block: block_w)
(hash_orig: hash256)
: (va_quickCode unit (va_code_SHA256_rnds2 dst src)) | val va_quick_SHA256_rnds2
(dst src: va_operand_xmm)
(t: counter)
(block: block_w)
(hash_orig: hash256)
: (va_quickCode unit (va_code_SHA256_rnds2 dst src)) | let va_quick_SHA256_rnds2 (dst:va_operand_xmm) (src:va_operand_xmm) (t:counter) (block:block_w)
(hash_orig:hash256) : (va_quickCode unit (va_code_SHA256_rnds2 dst src)) =
(va_QProc (va_code_SHA256_rnds2 dst src) ([va_mod_xmm dst]) (va_wp_SHA256_rnds2 dst src t block
hash_orig) (va_wpProof_SHA256_rnds2 dst src t block hash_orig)) | {
"file_name": "obj/Vale.X64.InsSha.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 67,
"end_line": 59,
"start_col": 0,
"start_line": 56
} | module Vale.X64.InsSha
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Spec.SHA2
open Spec.Hash.Definitions
open Vale.SHA.SHA_helpers
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.QuickCode
open Vale.X64.InsVector
open FStar.UInt32
open FStar.Seq
open Spec.Loops
open Vale.X64.CPU_Features_s
//-- SHA256_rnds2
val va_code_SHA256_rnds2 : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code
val va_codegen_success_SHA256_rnds2 : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool
val va_lemma_SHA256_rnds2 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> t:counter -> block:block_w -> hash_orig:hash256
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_SHA256_rnds2 dst src) va_s0 /\ va_is_dst_xmm dst va_s0
/\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\ t + 1 < size_k_w_256 /\
(va_get_xmm 0 va_s0).lo0 == add_wrap (word_to_nat32 (index k t)) (ws_opaque block t) /\
(va_get_xmm 0 va_s0).lo1 == add_wrap (word_to_nat32 (index k (t + 1))) (ws_opaque block (t +
1)) /\ make_hash (va_eval_xmm va_s0 src) (va_eval_xmm va_s0 dst) == repeat_range 0 t
(shuffle_core_opaque block) hash_orig))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
make_hash (va_eval_xmm va_sM dst) (va_eval_xmm va_s0 src) == repeat_range 0 (t + 2)
(shuffle_core_opaque block) hash_orig /\ va_state_eq va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0))))
[@ va_qattr]
let va_wp_SHA256_rnds2 (dst:va_operand_xmm) (src:va_operand_xmm) (t:counter) (block:block_w)
(hash_orig:hash256) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\ t + 1 <
size_k_w_256 /\ (va_get_xmm 0 va_s0).lo0 == add_wrap (word_to_nat32 (index k t)) (ws_opaque
block t) /\ (va_get_xmm 0 va_s0).lo1 == add_wrap (word_to_nat32 (index k (t + 1))) (ws_opaque
block (t + 1)) /\ make_hash (va_eval_xmm va_s0 src) (va_eval_xmm va_s0 dst) == repeat_range 0 t
(shuffle_core_opaque block) hash_orig /\ (forall (va_x_dst:va_value_xmm) . let va_sM =
va_upd_operand_xmm dst va_x_dst va_s0 in va_get_ok va_sM /\ make_hash (va_eval_xmm va_sM dst)
(va_eval_xmm va_s0 src) == repeat_range 0 (t + 2) (shuffle_core_opaque block) hash_orig ==>
va_k va_sM (())))
val va_wpProof_SHA256_rnds2 : dst:va_operand_xmm -> src:va_operand_xmm -> t:counter ->
block:block_w -> hash_orig:hash256 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_SHA256_rnds2 dst src t block hash_orig va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_SHA256_rnds2 dst src) ([va_mod_xmm
dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.InsVector.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.SHA.SHA_helpers.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.fsti.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.InsSha.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Loops",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"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 |
dst: Vale.X64.Decls.va_operand_xmm ->
src: Vale.X64.Decls.va_operand_xmm ->
t: Vale.SHA.SHA_helpers.counter ->
block: Vale.SHA.SHA_helpers.block_w ->
hash_orig: Vale.SHA.SHA_helpers.hash256
-> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.X64.InsSha.va_code_SHA256_rnds2 dst src) | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Decls.va_operand_xmm",
"Vale.SHA.SHA_helpers.counter",
"Vale.SHA.SHA_helpers.block_w",
"Vale.SHA.SHA_helpers.hash256",
"Vale.X64.QuickCode.va_QProc",
"Prims.unit",
"Vale.X64.InsSha.va_code_SHA256_rnds2",
"Prims.Cons",
"Vale.X64.QuickCode.mod_t",
"Vale.X64.QuickCode.va_mod_xmm",
"Prims.Nil",
"Vale.X64.InsSha.va_wp_SHA256_rnds2",
"Vale.X64.InsSha.va_wpProof_SHA256_rnds2",
"Vale.X64.QuickCode.va_quickCode"
] | [] | false | false | false | false | false | let va_quick_SHA256_rnds2
(dst src: va_operand_xmm)
(t: counter)
(block: block_w)
(hash_orig: hash256)
: (va_quickCode unit (va_code_SHA256_rnds2 dst src)) =
| (va_QProc (va_code_SHA256_rnds2 dst src)
([va_mod_xmm dst])
(va_wp_SHA256_rnds2 dst src t block hash_orig)
(va_wpProof_SHA256_rnds2 dst src t block hash_orig)) | false |
Vale.X64.InsSha.fsti | Vale.X64.InsSha.va_quick_SHA256_msg2 | val va_quick_SHA256_msg2 (dst src: va_operand_xmm) (t: counter) (block: block_w)
: (va_quickCode unit (va_code_SHA256_msg2 dst src)) | val va_quick_SHA256_msg2 (dst src: va_operand_xmm) (t: counter) (block: block_w)
: (va_quickCode unit (va_code_SHA256_msg2 dst src)) | let va_quick_SHA256_msg2 (dst:va_operand_xmm) (src:va_operand_xmm) (t:counter) (block:block_w) :
(va_quickCode unit (va_code_SHA256_msg2 dst src)) =
(va_QProc (va_code_SHA256_msg2 dst src) ([va_mod_xmm dst]) (va_wp_SHA256_msg2 dst src t block)
(va_wpProof_SHA256_msg2 dst src t block)) | {
"file_name": "obj/Vale.X64.InsSha.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 45,
"end_line": 135,
"start_col": 0,
"start_line": 132
} | module Vale.X64.InsSha
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Spec.SHA2
open Spec.Hash.Definitions
open Vale.SHA.SHA_helpers
open Vale.X64.Machine_s
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.QuickCode
open Vale.X64.InsVector
open FStar.UInt32
open FStar.Seq
open Spec.Loops
open Vale.X64.CPU_Features_s
//-- SHA256_rnds2
val va_code_SHA256_rnds2 : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code
val va_codegen_success_SHA256_rnds2 : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool
val va_lemma_SHA256_rnds2 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> t:counter -> block:block_w -> hash_orig:hash256
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_SHA256_rnds2 dst src) va_s0 /\ va_is_dst_xmm dst va_s0
/\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\ t + 1 < size_k_w_256 /\
(va_get_xmm 0 va_s0).lo0 == add_wrap (word_to_nat32 (index k t)) (ws_opaque block t) /\
(va_get_xmm 0 va_s0).lo1 == add_wrap (word_to_nat32 (index k (t + 1))) (ws_opaque block (t +
1)) /\ make_hash (va_eval_xmm va_s0 src) (va_eval_xmm va_s0 dst) == repeat_range 0 t
(shuffle_core_opaque block) hash_orig))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
make_hash (va_eval_xmm va_sM dst) (va_eval_xmm va_s0 src) == repeat_range 0 (t + 2)
(shuffle_core_opaque block) hash_orig /\ va_state_eq va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0))))
[@ va_qattr]
let va_wp_SHA256_rnds2 (dst:va_operand_xmm) (src:va_operand_xmm) (t:counter) (block:block_w)
(hash_orig:hash256) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\ t + 1 <
size_k_w_256 /\ (va_get_xmm 0 va_s0).lo0 == add_wrap (word_to_nat32 (index k t)) (ws_opaque
block t) /\ (va_get_xmm 0 va_s0).lo1 == add_wrap (word_to_nat32 (index k (t + 1))) (ws_opaque
block (t + 1)) /\ make_hash (va_eval_xmm va_s0 src) (va_eval_xmm va_s0 dst) == repeat_range 0 t
(shuffle_core_opaque block) hash_orig /\ (forall (va_x_dst:va_value_xmm) . let va_sM =
va_upd_operand_xmm dst va_x_dst va_s0 in va_get_ok va_sM /\ make_hash (va_eval_xmm va_sM dst)
(va_eval_xmm va_s0 src) == repeat_range 0 (t + 2) (shuffle_core_opaque block) hash_orig ==>
va_k va_sM (())))
val va_wpProof_SHA256_rnds2 : dst:va_operand_xmm -> src:va_operand_xmm -> t:counter ->
block:block_w -> hash_orig:hash256 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_SHA256_rnds2 dst src t block hash_orig va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_SHA256_rnds2 dst src) ([va_mod_xmm
dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_SHA256_rnds2 (dst:va_operand_xmm) (src:va_operand_xmm) (t:counter) (block:block_w)
(hash_orig:hash256) : (va_quickCode unit (va_code_SHA256_rnds2 dst src)) =
(va_QProc (va_code_SHA256_rnds2 dst src) ([va_mod_xmm dst]) (va_wp_SHA256_rnds2 dst src t block
hash_orig) (va_wpProof_SHA256_rnds2 dst src t block hash_orig))
//--
//-- SHA256_msg1
val va_code_SHA256_msg1 : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code
val va_codegen_success_SHA256_msg1 : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool
val va_lemma_SHA256_msg1 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> t:counter -> block:block_w
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_SHA256_msg1 dst src) va_s0 /\ va_is_dst_xmm dst va_s0
/\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\ ((16 <= t && t < size_k_w_256))
/\ va_eval_xmm va_s0 dst == ws_quad32 (t - 16) block /\ (va_eval_xmm va_s0 src).lo0 ==
ws_opaque block (t - 12)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == ws_partial t block /\ va_state_eq va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0))))
[@ va_qattr]
let va_wp_SHA256_msg1 (dst:va_operand_xmm) (src:va_operand_xmm) (t:counter) (block:block_w)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\ ((16 <=
t && t < size_k_w_256)) /\ va_eval_xmm va_s0 dst == ws_quad32 (t - 16) block /\ (va_eval_xmm
va_s0 src).lo0 == ws_opaque block (t - 12) /\ (forall (va_x_dst:va_value_xmm) . let va_sM =
va_upd_operand_xmm dst va_x_dst va_s0 in va_get_ok va_sM /\ va_eval_xmm va_sM dst == ws_partial
t block ==> va_k va_sM (())))
val va_wpProof_SHA256_msg1 : dst:va_operand_xmm -> src:va_operand_xmm -> t:counter -> block:block_w
-> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_SHA256_msg1 dst src t block va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_SHA256_msg1 dst src) ([va_mod_xmm
dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_SHA256_msg1 (dst:va_operand_xmm) (src:va_operand_xmm) (t:counter) (block:block_w) :
(va_quickCode unit (va_code_SHA256_msg1 dst src)) =
(va_QProc (va_code_SHA256_msg1 dst src) ([va_mod_xmm dst]) (va_wp_SHA256_msg1 dst src t block)
(va_wpProof_SHA256_msg1 dst src t block))
//--
//-- SHA256_msg2
val va_code_SHA256_msg2 : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_code
val va_codegen_success_SHA256_msg2 : dst:va_operand_xmm -> src:va_operand_xmm -> Tot va_pbool
val va_lemma_SHA256_msg2 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_xmm ->
src:va_operand_xmm -> t:counter -> block:block_w
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_SHA256_msg2 dst src) va_s0 /\ va_is_dst_xmm dst va_s0
/\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\ ((16 <= t && t < size_k_w_256 -
3)) /\ (let step1 = ws_partial t block in let t_minus_7 = ws_quad32 (t - 7) block in
va_eval_xmm va_s0 dst == add_wrap_quad32 step1 t_minus_7) /\ (va_eval_xmm va_s0 src).hi2 ==
ws_opaque block (t - 2) /\ (va_eval_xmm va_s0 src).hi3 == ws_opaque block (t - 1)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_eval_xmm va_sM dst == ws_quad32 t block /\ va_state_eq va_sM (va_update_ok va_sM
(va_update_operand_xmm dst va_sM va_s0))))
[@ va_qattr]
let va_wp_SHA256_msg2 (dst:va_operand_xmm) (src:va_operand_xmm) (t:counter) (block:block_w)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_is_dst_xmm dst va_s0 /\ va_is_src_xmm src va_s0 /\ va_get_ok va_s0 /\ sha_enabled /\ ((16 <=
t && t < size_k_w_256 - 3)) /\ (let step1 = ws_partial t block in let t_minus_7 = ws_quad32 (t
- 7) block in va_eval_xmm va_s0 dst == add_wrap_quad32 step1 t_minus_7) /\ (va_eval_xmm va_s0
src).hi2 == ws_opaque block (t - 2) /\ (va_eval_xmm va_s0 src).hi3 == ws_opaque block (t - 1)
/\ (forall (va_x_dst:va_value_xmm) . let va_sM = va_upd_operand_xmm dst va_x_dst va_s0 in
va_get_ok va_sM /\ va_eval_xmm va_sM dst == ws_quad32 t block ==> va_k va_sM (())))
val va_wpProof_SHA256_msg2 : dst:va_operand_xmm -> src:va_operand_xmm -> t:counter -> block:block_w
-> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_SHA256_msg2 dst src t block va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_SHA256_msg2 dst src) ([va_mod_xmm
dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.InsVector.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.SHA.SHA_helpers.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.fsti.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.InsSha.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Loops",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.UInt32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"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 |
dst: Vale.X64.Decls.va_operand_xmm ->
src: Vale.X64.Decls.va_operand_xmm ->
t: Vale.SHA.SHA_helpers.counter ->
block: Vale.SHA.SHA_helpers.block_w
-> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.X64.InsSha.va_code_SHA256_msg2 dst src) | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Decls.va_operand_xmm",
"Vale.SHA.SHA_helpers.counter",
"Vale.SHA.SHA_helpers.block_w",
"Vale.X64.QuickCode.va_QProc",
"Prims.unit",
"Vale.X64.InsSha.va_code_SHA256_msg2",
"Prims.Cons",
"Vale.X64.QuickCode.mod_t",
"Vale.X64.QuickCode.va_mod_xmm",
"Prims.Nil",
"Vale.X64.InsSha.va_wp_SHA256_msg2",
"Vale.X64.InsSha.va_wpProof_SHA256_msg2",
"Vale.X64.QuickCode.va_quickCode"
] | [] | false | false | false | false | false | let va_quick_SHA256_msg2 (dst src: va_operand_xmm) (t: counter) (block: block_w)
: (va_quickCode unit (va_code_SHA256_msg2 dst src)) =
| (va_QProc (va_code_SHA256_msg2 dst src)
([va_mod_xmm dst])
(va_wp_SHA256_msg2 dst src t block)
(va_wpProof_SHA256_msg2 dst src t block)) | false |
MerkleTree.fsti | MerkleTree.mt_serialize_path | val mt_serialize_path (path: const_path_p) (buf: MTNLS.uint8_p) (len: UInt64.t)
: HST.ST UInt64.t pf pt | val mt_serialize_path (path: const_path_p) (buf: MTNLS.uint8_p) (len: UInt64.t)
: HST.ST UInt64.t pf pt | let mt_serialize_path
(path:const_path_p)
(buf:MTNLS.uint8_p)
(len:UInt64.t)
: HST.ST UInt64.t pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNLS.mt_serialize_path #hash_size path buf len | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 49,
"end_line": 337,
"start_col": 0,
"start_line": 331
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r
[@ (Comment " Destructor for hashes") "c_inline"]
let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h
[@ (Comment " Constructor for paths") "c_inline"]
let mt_init_path (hash_size:hash_size_t) (mtr:HH.rid) (r:HST.erid): HST.ST path_p pf pt = MTNL.init_path hash_size mtr r
[@ (Comment " Destructor for paths") "c_inline"]
let mt_free_path (path:path_p): HST.ST unit pf pt = MTNL.free_path path
[@ (Comment " Length of a path
@param[in] p Path
return The length of the path") "c_inline"]
let mt_get_path_length (mtr:HH.rid) (path:const_path_p): HST.ST U32.t pf pt = MTNL.mt_get_path_length mtr path
[@ (Comment " Insert hash into path
@param[in] p Path
@param[in] hash Hash to insert") "c_inline"]
let mt_path_insert
(#h:HS.mem)
(#mtr:HH.rid)
(path:path_p)
(hash:hash #(MTNL.Path?.hash_size (B.get h path 0)))
: HST.ST unit pf pt
= let hash_size = MTNL.Path?.hash_size (B.index path 0ul) in
MTNL.mt_path_insert #hash_size mtr path hash
inline_for_extraction
let path_hash_size (#h:HS.mem) (path:path_p) = MTNL.Path?.hash_size (B.get h path 0)
inline_for_extraction
let const_path_hash_size (#h:HS.mem) (path:const_path_p) = path_hash_size #h (CB.cast path)
inline_for_extraction
let tree_hash_size (#h:HS.mem) (mt:mt_p) = MTNL.MT?.hash_size (B.get h mt 0)
inline_for_extraction
let const_tree_hash_size (#h:HS.mem) (mt:const_mt_p) = tree_hash_size #h (CB.cast mt)
[@ (Comment " Get step on a path
@param[in] p Path
@param[in] i Path step index
return The hash at step i of p") "c_inline"]
let mt_get_path_step
(#h:HS.mem)
(#mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST (hash #(const_path_hash_size #h path)) pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step #hash_size mtr path i
[@ (Comment " Precondition predicate for mt_get_path_step") "c_inline"]
let mt_get_path_step_pre
(#h:HS.mem)
(mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST bool pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step_pre #hash_size mtr path i
[@ (Comment " Construction with custom hash functions
@param[in] hash_size Hash size (in bytes)
@param[in] i The initial hash
return The new Merkle tree") "c_inline"]
let mt_create_custom
(hash_size:hash_size_t)
(hash_spec:Ghost.erased (MTS.hash_fun_t #(U32.v hash_size)))
(r:HST.erid)
(i:hash #hash_size)
(hash_fun:MTNLHF.hash_fun_t #hash_size #hash_spec)
: HST.ST mt_p pf pt
= MTNL.mt_create_custom hash_size hash_spec r i hash_fun
[@ (Comment " Destruction
@param[in] mt The Merkle tree") "c_inline"]
let mt_free (mt:mt_p): HST.ST unit pf pt = MTNL.mt_free mt
[@ (Comment " Insertion
@param[in] mt The Merkle tree
@param[in] v The tree does not take ownership of the hash, it makes a copy of its content.
Note: The content of the hash will be overwritten with an arbitrary value.") "c_inline"]
let mt_insert
(#h:HS.mem)
(mt:mt_p)
(v:hash #(tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index mt 0ul) in
MTNL.mt_insert hash_size mt v
[@ (Comment " Precondition predicate for mt_insert") "c_inline"]
let mt_insert_pre
(#h:HS.mem)
(mt:const_mt_p)
(v:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_insert_pre #hash_size mt v
[@ (Comment " Getting the Merkle root
@param[in] mt The Merkle tree
@param[out] root The Merkle root") "c_inline"]
let mt_get_root
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root #hash_size mt root
[@ (Comment " Precondition predicate for mt_get_root") "c_inline"]
let mt_get_root_pre
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root_pre #hash_size mt root
[@ (Comment " Getting a Merkle path
@param[in] mt The Merkle tree
@param[in] idx The index of the target hash
@param[out] path A resulting Merkle path that contains the leaf hash.
@param[out] root The Merkle root
return The number of elements in the tree
Notes:
- The resulting path contains pointers to hashes in the tree, not copies of
the hash values.
- idx must be within the currently held indices in the tree (past the
last flush index).") "c_inline"]
let mt_get_path
(#h:HS.mem)
(mt:const_mt_p)
(idx:offset_t)
(path:path_p{path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(path_hash_size #h path))
: HST.ST index_t pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_path #hash_size mt idx path root
[@ (Comment " Precondition predicate for mt_get_path") "c_inline"]
let mt_get_path_pre
(#h:HS.mem)
(mt:const_mt_p)
(idx:offset_t)
(path:const_path_p{const_path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(const_path_hash_size #h path))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_path_pre #hash_size mt idx path root
[@ (Comment " Flush the Merkle tree
@param[in] mt The Merkle tree") "c_inline"]
let mt_flush (mt:mt_p): HST.ST unit pf pt = MTNL.mt_flush mt
[@ (Comment " Precondition predicate for mt_flush") "c_inline"]
let mt_flush_pre (mt:const_mt_p): HST.ST bool pf pt = MTNL.mt_flush_pre mt
[@ (Comment " Flush the Merkle tree up to a given index
@param[in] mt The Merkle tree
@param[in] idx The index up to which to flush the tree") "c_inline"]
let mt_flush_to (mt:mt_p) (idx:offset_t): HST.ST unit pf pt = MTNL.mt_flush_to mt idx
[@ (Comment " Precondition predicate for mt_flush_to")]
let mt_flush_to_pre (mt:const_mt_p) (idx:offset_t): HST.ST bool pf pt = MTNL.mt_flush_to_pre mt idx
[@ (Comment " Retract the Merkle tree down to a given index
@param[in] mt The Merkle tree
@param[in] idx The index to retract the tree to
Note: The element and idx will remain in the tree.") "c_inline"]
let mt_retract_to (mt:mt_p) (idx:offset_t): HST.ST unit pf pt = MTNL.mt_retract_to mt idx
[@ (Comment " Precondition predicate for mt_retract_to") "c_inline"]
let mt_retract_to_pre (mt:const_mt_p) (idx:offset_t): HST.ST bool pf pt = MTNL.mt_retract_to_pre mt idx
[@ (Comment " Client-side verification
@param[in] mt The Merkle tree
@param[in] tgt The index of the target hash
@param[in] max The maximum index + 1 of the tree when the path was generated
@param[in] path The Merkle path to verify
@param[in] root
return true if the verification succeeded, false otherwise
Note: max - tgt must be less than 2^32.") "c_inline"]
let mt_verify
(#h:HS.mem)
(#hash_size:Ghost.erased hash_size_t)
(#hash_spec:MTS.hash_fun_t #(U32.v hash_size))
(mt:const_mt_p)
(tgt:UInt64.t)
(max:UInt64.t)
(mtr:HH.rid)
(path:const_path_p{let phs = const_path_hash_size #h path in phs = const_tree_hash_size #h mt /\ phs = Ghost.reveal hash_size})
(root:hash #(const_path_hash_size #h path))
: HST.ST bool pf pt
= let dmt = B.index (CB.cast mt) 0ul in
let hsz = MTNL.MT?.hash_size dmt in
MTNL.mt_verify #hsz #hash_spec mt tgt max mtr path root
[@ (Comment " Precondition predicate for mt_verify") "c_inline"]
let mt_verify_pre
(#h:HS.mem)
(mt:const_mt_p)
(tgt:UInt64.t)
(max:UInt64.t)
(mtr:HH.rid)
(path:const_path_p{const_path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(const_path_hash_size #h path))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_verify_pre #hash_size mt tgt max mtr path root
[@ (Comment " Serialization size
@param[in] mt The Merkle tree
return the number of bytes required to serialize the tree") "c_inline"]
let mt_serialize_size (mt:const_mt_p): HST.ST UInt64.t pf pt = MTNLS.mt_serialize_size mt
[@ (Comment " Merkle tree serialization
@param[in] mt The Merkle tree
@param[out] buf The buffer to serialize the tree into
@param[in] len Length of buf
return the number of bytes written
Note: buf must be a buffer of size mt_serialize_size(mt) or larger, but
smaller than 2^32 (larger buffers are currently not supported).") "c_inline"]
let mt_serialize (mt:const_mt_p) (buf:MTNLS.uint8_p) (len:UInt64.t): HST.ST UInt64.t pf pt = MTNLS.mt_serialize mt buf len
[@ (Comment " Merkle tree deserialization
@param[in] expected_hash_size Expected hash size to match hash_fun
@param[in] buf The buffer to deserialize the tree from
@param[in] len Length of buf
@param[in] hash_fun Hash function
return pointer to the new tree if successful, NULL otherwise
Note: buf must point to an allocated buffer.") "c_inline"]
let mt_deserialize
(#hsz:Ghost.erased hash_size_t)
(rid:HST.erid)
(buf:MTNLS.const_uint8_p)
(len:UInt64.t{CB.length buf = U64.v len})
(hash_spec:Ghost.erased(MTS.hash_fun_t #(U32.v hsz)))
(hash_fun:MTNLHF.hash_fun_t #hsz #hash_spec)
: HST.ST (B.pointer_or_null merkle_tree) pf pt
= MTNLS.mt_deserialize #hsz rid buf len hash_spec hash_fun
[@ (Comment " Path serialization
@param[in] path The path
@param[out] buf The buffer to serialize the path into
@param[in] len Length of buf | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | path: MerkleTree.const_path_p -> buf: MerkleTree.Low.Serialization.uint8_p -> len: FStar.UInt64.t
-> FStar.HyperStack.ST.ST FStar.UInt64.t | FStar.HyperStack.ST.ST | [] | [] | [
"MerkleTree.const_path_p",
"MerkleTree.Low.Serialization.uint8_p",
"FStar.UInt64.t",
"MerkleTree.Low.Serialization.mt_serialize_path",
"FStar.Ghost.hide",
"MerkleTree.Low.Datastructures.hash_size_t",
"MerkleTree.Low.Serialization.uint64_t",
"MerkleTree.Low.__proj__Path__item__hash_size",
"MerkleTree.Low.path",
"LowStar.Monotonic.Buffer.index",
"MerkleTree.path",
"LowStar.ConstBuffer.qbuf_pre",
"LowStar.ConstBuffer.as_qbuf",
"LowStar.ConstBuffer.cast",
"FStar.UInt32.__uint_to_t",
"MerkleTree.pf",
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.pt"
] | [] | false | true | false | false | false | let mt_serialize_path (path: const_path_p) (buf: MTNLS.uint8_p) (len: UInt64.t)
: HST.ST UInt64.t pf pt =
| let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNLS.mt_serialize_path #hash_size path buf len | false |
MerkleTree.fsti | MerkleTree.mt_verify_pre | val mt_verify_pre
(#h: HS.mem)
(mt: const_mt_p)
(tgt max: UInt64.t)
(mtr: HH.rid)
(path: const_path_p{const_path_hash_size #h path = const_tree_hash_size #h mt})
(root: hash #(const_path_hash_size #h path))
: HST.ST bool pf pt | val mt_verify_pre
(#h: HS.mem)
(mt: const_mt_p)
(tgt max: UInt64.t)
(mtr: HH.rid)
(path: const_path_p{const_path_hash_size #h path = const_tree_hash_size #h mt})
(root: hash #(const_path_hash_size #h path))
: HST.ST bool pf pt | let mt_verify_pre
(#h:HS.mem)
(mt:const_mt_p)
(tgt:UInt64.t)
(max:UInt64.t)
(mtr:HH.rid)
(path:const_path_p{const_path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(const_path_hash_size #h path))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_verify_pre #hash_size mt tgt max mtr path root | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 56,
"end_line": 279,
"start_col": 0,
"start_line": 269
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r
[@ (Comment " Destructor for hashes") "c_inline"]
let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h
[@ (Comment " Constructor for paths") "c_inline"]
let mt_init_path (hash_size:hash_size_t) (mtr:HH.rid) (r:HST.erid): HST.ST path_p pf pt = MTNL.init_path hash_size mtr r
[@ (Comment " Destructor for paths") "c_inline"]
let mt_free_path (path:path_p): HST.ST unit pf pt = MTNL.free_path path
[@ (Comment " Length of a path
@param[in] p Path
return The length of the path") "c_inline"]
let mt_get_path_length (mtr:HH.rid) (path:const_path_p): HST.ST U32.t pf pt = MTNL.mt_get_path_length mtr path
[@ (Comment " Insert hash into path
@param[in] p Path
@param[in] hash Hash to insert") "c_inline"]
let mt_path_insert
(#h:HS.mem)
(#mtr:HH.rid)
(path:path_p)
(hash:hash #(MTNL.Path?.hash_size (B.get h path 0)))
: HST.ST unit pf pt
= let hash_size = MTNL.Path?.hash_size (B.index path 0ul) in
MTNL.mt_path_insert #hash_size mtr path hash
inline_for_extraction
let path_hash_size (#h:HS.mem) (path:path_p) = MTNL.Path?.hash_size (B.get h path 0)
inline_for_extraction
let const_path_hash_size (#h:HS.mem) (path:const_path_p) = path_hash_size #h (CB.cast path)
inline_for_extraction
let tree_hash_size (#h:HS.mem) (mt:mt_p) = MTNL.MT?.hash_size (B.get h mt 0)
inline_for_extraction
let const_tree_hash_size (#h:HS.mem) (mt:const_mt_p) = tree_hash_size #h (CB.cast mt)
[@ (Comment " Get step on a path
@param[in] p Path
@param[in] i Path step index
return The hash at step i of p") "c_inline"]
let mt_get_path_step
(#h:HS.mem)
(#mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST (hash #(const_path_hash_size #h path)) pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step #hash_size mtr path i
[@ (Comment " Precondition predicate for mt_get_path_step") "c_inline"]
let mt_get_path_step_pre
(#h:HS.mem)
(mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST bool pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step_pre #hash_size mtr path i
[@ (Comment " Construction with custom hash functions
@param[in] hash_size Hash size (in bytes)
@param[in] i The initial hash
return The new Merkle tree") "c_inline"]
let mt_create_custom
(hash_size:hash_size_t)
(hash_spec:Ghost.erased (MTS.hash_fun_t #(U32.v hash_size)))
(r:HST.erid)
(i:hash #hash_size)
(hash_fun:MTNLHF.hash_fun_t #hash_size #hash_spec)
: HST.ST mt_p pf pt
= MTNL.mt_create_custom hash_size hash_spec r i hash_fun
[@ (Comment " Destruction
@param[in] mt The Merkle tree") "c_inline"]
let mt_free (mt:mt_p): HST.ST unit pf pt = MTNL.mt_free mt
[@ (Comment " Insertion
@param[in] mt The Merkle tree
@param[in] v The tree does not take ownership of the hash, it makes a copy of its content.
Note: The content of the hash will be overwritten with an arbitrary value.") "c_inline"]
let mt_insert
(#h:HS.mem)
(mt:mt_p)
(v:hash #(tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index mt 0ul) in
MTNL.mt_insert hash_size mt v
[@ (Comment " Precondition predicate for mt_insert") "c_inline"]
let mt_insert_pre
(#h:HS.mem)
(mt:const_mt_p)
(v:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_insert_pre #hash_size mt v
[@ (Comment " Getting the Merkle root
@param[in] mt The Merkle tree
@param[out] root The Merkle root") "c_inline"]
let mt_get_root
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root #hash_size mt root
[@ (Comment " Precondition predicate for mt_get_root") "c_inline"]
let mt_get_root_pre
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root_pre #hash_size mt root
[@ (Comment " Getting a Merkle path
@param[in] mt The Merkle tree
@param[in] idx The index of the target hash
@param[out] path A resulting Merkle path that contains the leaf hash.
@param[out] root The Merkle root
return The number of elements in the tree
Notes:
- The resulting path contains pointers to hashes in the tree, not copies of
the hash values.
- idx must be within the currently held indices in the tree (past the
last flush index).") "c_inline"]
let mt_get_path
(#h:HS.mem)
(mt:const_mt_p)
(idx:offset_t)
(path:path_p{path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(path_hash_size #h path))
: HST.ST index_t pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_path #hash_size mt idx path root
[@ (Comment " Precondition predicate for mt_get_path") "c_inline"]
let mt_get_path_pre
(#h:HS.mem)
(mt:const_mt_p)
(idx:offset_t)
(path:const_path_p{const_path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(const_path_hash_size #h path))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_path_pre #hash_size mt idx path root
[@ (Comment " Flush the Merkle tree
@param[in] mt The Merkle tree") "c_inline"]
let mt_flush (mt:mt_p): HST.ST unit pf pt = MTNL.mt_flush mt
[@ (Comment " Precondition predicate for mt_flush") "c_inline"]
let mt_flush_pre (mt:const_mt_p): HST.ST bool pf pt = MTNL.mt_flush_pre mt
[@ (Comment " Flush the Merkle tree up to a given index
@param[in] mt The Merkle tree
@param[in] idx The index up to which to flush the tree") "c_inline"]
let mt_flush_to (mt:mt_p) (idx:offset_t): HST.ST unit pf pt = MTNL.mt_flush_to mt idx
[@ (Comment " Precondition predicate for mt_flush_to")]
let mt_flush_to_pre (mt:const_mt_p) (idx:offset_t): HST.ST bool pf pt = MTNL.mt_flush_to_pre mt idx
[@ (Comment " Retract the Merkle tree down to a given index
@param[in] mt The Merkle tree
@param[in] idx The index to retract the tree to
Note: The element and idx will remain in the tree.") "c_inline"]
let mt_retract_to (mt:mt_p) (idx:offset_t): HST.ST unit pf pt = MTNL.mt_retract_to mt idx
[@ (Comment " Precondition predicate for mt_retract_to") "c_inline"]
let mt_retract_to_pre (mt:const_mt_p) (idx:offset_t): HST.ST bool pf pt = MTNL.mt_retract_to_pre mt idx
[@ (Comment " Client-side verification
@param[in] mt The Merkle tree
@param[in] tgt The index of the target hash
@param[in] max The maximum index + 1 of the tree when the path was generated
@param[in] path The Merkle path to verify
@param[in] root
return true if the verification succeeded, false otherwise
Note: max - tgt must be less than 2^32.") "c_inline"]
let mt_verify
(#h:HS.mem)
(#hash_size:Ghost.erased hash_size_t)
(#hash_spec:MTS.hash_fun_t #(U32.v hash_size))
(mt:const_mt_p)
(tgt:UInt64.t)
(max:UInt64.t)
(mtr:HH.rid)
(path:const_path_p{let phs = const_path_hash_size #h path in phs = const_tree_hash_size #h mt /\ phs = Ghost.reveal hash_size})
(root:hash #(const_path_hash_size #h path))
: HST.ST bool pf pt
= let dmt = B.index (CB.cast mt) 0ul in
let hsz = MTNL.MT?.hash_size dmt in
MTNL.mt_verify #hsz #hash_spec mt tgt max mtr path root | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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.const_mt_p ->
tgt: FStar.UInt64.t ->
max: FStar.UInt64.t ->
mtr: FStar.Monotonic.HyperHeap.rid ->
path:
MerkleTree.const_path_p
{MerkleTree.const_path_hash_size path = MerkleTree.const_tree_hash_size mt} ->
root: MerkleTree.hash
-> FStar.HyperStack.ST.ST Prims.bool | FStar.HyperStack.ST.ST | [] | [] | [
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.const_mt_p",
"FStar.UInt64.t",
"FStar.Monotonic.HyperHeap.rid",
"MerkleTree.const_path_p",
"Prims.b2t",
"Prims.op_Equality",
"MerkleTree.Low.Datastructures.hash_size_t",
"MerkleTree.const_path_hash_size",
"MerkleTree.const_tree_hash_size",
"MerkleTree.hash",
"MerkleTree.Low.mt_verify_pre",
"FStar.Ghost.hide",
"Prims.bool",
"MerkleTree.Low.__proj__MT__item__hash_size",
"MerkleTree.Low.merkle_tree",
"LowStar.Monotonic.Buffer.index",
"LowStar.ConstBuffer.qbuf_pre",
"LowStar.ConstBuffer.as_qbuf",
"LowStar.ConstBuffer.cast",
"FStar.UInt32.__uint_to_t",
"MerkleTree.pf",
"MerkleTree.pt"
] | [] | false | true | false | false | false | let mt_verify_pre
(#h: HS.mem)
(mt: const_mt_p)
(tgt max: UInt64.t)
(mtr: HH.rid)
(path: const_path_p{const_path_hash_size #h path = const_tree_hash_size #h mt})
(root: hash #(const_path_hash_size #h path))
: HST.ST bool pf pt =
| let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_verify_pre #hash_size mt tgt max mtr path root | false |
FStar.Tactics.CanonCommSwaps.fst | FStar.Tactics.CanonCommSwaps.apply_swap | val apply_swap : xs: Prims.list a -> s: FStar.Tactics.CanonCommSwaps.swap (FStar.List.Tot.Base.length xs + 0)
-> Prims.Pure (Prims.list a) | let apply_swap (#a:Type) = apply_swap_aux #a 0 | {
"file_name": "ulib/FStar.Tactics.CanonCommSwaps.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 46,
"end_line": 31,
"start_col": 0,
"start_line": 31
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.CanonCommSwaps
open FStar.List.Tot
let swap (n:nat) :Type = x:nat{x < n-1}
let rec apply_swap_aux (#a:Type) (n:nat) (xs:list a) (s:swap (length xs + n)) :
Pure (list a) (requires True)
(ensures (fun zs -> length zs == length xs)) (decreases xs) =
match xs with
| [] | [_] -> xs
| x1 :: x2 :: xs' -> if n = (s <: nat)
then x2 :: x1 :: xs'
else x1 :: apply_swap_aux (n+1) (x2 :: xs') s | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Tactics.CanonCommSwaps.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | xs: Prims.list a -> s: FStar.Tactics.CanonCommSwaps.swap (FStar.List.Tot.Base.length xs + 0)
-> Prims.Pure (Prims.list a) | Prims.Pure | [
""
] | [] | [
"FStar.Tactics.CanonCommSwaps.apply_swap_aux",
"Prims.list",
"FStar.Tactics.CanonCommSwaps.swap",
"Prims.op_Addition",
"FStar.List.Tot.Base.length",
"Prims.l_True",
"Prims.eq2",
"Prims.nat"
] | [] | false | false | false | false | false | let apply_swap (#a: Type) =
| apply_swap_aux #a 0 | false |
|
Spec.SHA3.Constants.fst | Spec.SHA3.Constants.rotc_t | val rotc_t : Type0 | let rotc_t = rotval U64 | {
"file_name": "specs/Spec.SHA3.Constants.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 23,
"end_line": 8,
"start_col": 0,
"start_line": 8
} | module Spec.SHA3.Constants
open Lib.IntTypes
open Lib.Sequence
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SHA3.Constants.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA3",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA3",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.rotval",
"Lib.IntTypes.U64"
] | [] | false | false | false | true | true | let rotc_t =
| rotval U64 | false |
|
FStar.Tactics.CanonCommSwaps.fst | FStar.Tactics.CanonCommSwaps.equal_counts | val equal_counts (#a: eqtype) (xs ys: list a) : Type0 | val equal_counts (#a: eqtype) (xs ys: list a) : Type0 | let equal_counts (#a:eqtype) (xs ys:list a) : Type0 =
(forall (e:a).{:pattern (count e xs) \/ (count e ys)} count e xs == count e ys) | {
"file_name": "ulib/FStar.Tactics.CanonCommSwaps.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 81,
"end_line": 41,
"start_col": 0,
"start_line": 40
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.CanonCommSwaps
open FStar.List.Tot
let swap (n:nat) :Type = x:nat{x < n-1}
let rec apply_swap_aux (#a:Type) (n:nat) (xs:list a) (s:swap (length xs + n)) :
Pure (list a) (requires True)
(ensures (fun zs -> length zs == length xs)) (decreases xs) =
match xs with
| [] | [_] -> xs
| x1 :: x2 :: xs' -> if n = (s <: nat)
then x2 :: x1 :: xs'
else x1 :: apply_swap_aux (n+1) (x2 :: xs') s
let apply_swap (#a:Type) = apply_swap_aux #a 0
let rec apply_swaps (#a:Type) (xs:list a) (ss:list (swap (length xs))) :
Pure (list a) (requires True)
(ensures (fun zs -> length zs == length xs)) (decreases ss) =
match ss with
| [] -> xs
| s::ss' -> apply_swaps (apply_swap xs s) ss' | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Tactics.CanonCommSwaps.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | xs: Prims.list a -> ys: Prims.list a -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Prims.eqtype",
"Prims.list",
"Prims.l_Forall",
"Prims.eq2",
"Prims.nat",
"FStar.List.Tot.Base.count"
] | [] | false | false | false | false | true | let equal_counts (#a: eqtype) (xs ys: list a) : Type0 =
| (forall (e: a). {:pattern (count e xs)\/(count e ys)} count e xs == count e ys) | false |
Spec.SHA3.Constants.fst | Spec.SHA3.Constants.piln_t | val piln_t : Type0 | let piln_t = x:size_t{size_v x < 25} | {
"file_name": "specs/Spec.SHA3.Constants.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 36,
"end_line": 19,
"start_col": 0,
"start_line": 19
} | module Spec.SHA3.Constants
open Lib.IntTypes
open Lib.Sequence
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let rotc_t = rotval U64
unfold let rotc_list: list rotc_t =
[1ul; 3ul; 6ul; 10ul; 15ul; 21ul; 28ul; 36ul;
45ul; 55ul; 2ul; 14ul; 27ul; 41ul; 56ul; 8ul;
25ul; 43ul; 62ul; 18ul; 39ul; 61ul; 20ul; 44ul]
let keccak_rotc:lseq rotc_t 24 =
assert_norm (List.Tot.length rotc_list == 24);
of_list rotc_list | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SHA3.Constants.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA3",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA3",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.size_v"
] | [] | false | false | false | true | true | let piln_t =
| x: size_t{size_v x < 25} | false |
|
FStar.Tactics.CanonCommSwaps.fst | FStar.Tactics.CanonCommSwaps.swap_for | val swap_for : xs: Prims.list a -> Type0 | let swap_for (#a:eqtype) (xs:list a) = swap (length xs) | {
"file_name": "ulib/FStar.Tactics.CanonCommSwaps.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 62,
"end_line": 55,
"start_col": 7,
"start_line": 55
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.CanonCommSwaps
open FStar.List.Tot
let swap (n:nat) :Type = x:nat{x < n-1}
let rec apply_swap_aux (#a:Type) (n:nat) (xs:list a) (s:swap (length xs + n)) :
Pure (list a) (requires True)
(ensures (fun zs -> length zs == length xs)) (decreases xs) =
match xs with
| [] | [_] -> xs
| x1 :: x2 :: xs' -> if n = (s <: nat)
then x2 :: x1 :: xs'
else x1 :: apply_swap_aux (n+1) (x2 :: xs') s
let apply_swap (#a:Type) = apply_swap_aux #a 0
let rec apply_swaps (#a:Type) (xs:list a) (ss:list (swap (length xs))) :
Pure (list a) (requires True)
(ensures (fun zs -> length zs == length xs)) (decreases ss) =
match ss with
| [] -> xs
| s::ss' -> apply_swaps (apply_swap xs s) ss'
let equal_counts (#a:eqtype) (xs ys:list a) : Type0 =
(forall (e:a).{:pattern (count e xs) \/ (count e ys)} count e xs == count e ys)
let extend_equal_counts (#a:eqtype) (h:a) (xs ys:list a) : Lemma
(requires equal_counts xs ys)
(ensures equal_counts (h::xs) (h::ys))
=
()
let retract_equal_counts (#a:eqtype) (h:a) (xs ys:list a) : Lemma
(requires equal_counts (h::xs) (h::ys))
(ensures equal_counts xs ys)
=
assert (forall (e:a).{:pattern (count e xs) \/ (count e ys)} count e (h::xs) == count e (h::ys)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Tactics.CanonCommSwaps.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | xs: Prims.list a -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Prims.eqtype",
"Prims.list",
"FStar.Tactics.CanonCommSwaps.swap",
"FStar.List.Tot.Base.length"
] | [] | false | false | false | false | true | let swap_for (#a: eqtype) (xs: list a) =
| swap (length xs) | false |
|
Spec.SHA3.Constants.fst | Spec.SHA3.Constants.rndc_list | val rndc_list:list pub_uint64 | val rndc_list:list pub_uint64 | let rndc_list: list pub_uint64 =
[0x0000000000000001uL; 0x0000000000008082uL; 0x800000000000808auL; 0x8000000080008000uL;
0x000000000000808buL; 0x0000000080000001uL; 0x8000000080008081uL; 0x8000000000008009uL;
0x000000000000008auL; 0x0000000000000088uL; 0x0000000080008009uL; 0x000000008000000auL;
0x000000008000808buL; 0x800000000000008buL; 0x8000000000008089uL; 0x8000000000008003uL;
0x8000000000008002uL; 0x8000000000000080uL; 0x000000000000800auL; 0x800000008000000auL;
0x8000000080008081uL; 0x8000000000008080uL; 0x0000000080000001uL; 0x8000000080008008uL] | {
"file_name": "specs/Spec.SHA3.Constants.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 90,
"end_line": 36,
"start_col": 7,
"start_line": 30
} | module Spec.SHA3.Constants
open Lib.IntTypes
open Lib.Sequence
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let rotc_t = rotval U64
unfold let rotc_list: list rotc_t =
[1ul; 3ul; 6ul; 10ul; 15ul; 21ul; 28ul; 36ul;
45ul; 55ul; 2ul; 14ul; 27ul; 41ul; 56ul; 8ul;
25ul; 43ul; 62ul; 18ul; 39ul; 61ul; 20ul; 44ul]
let keccak_rotc:lseq rotc_t 24 =
assert_norm (List.Tot.length rotc_list == 24);
of_list rotc_list
let piln_t = x:size_t{size_v x < 25}
unfold let piln_list: list piln_t =
[10ul; 7ul; 11ul; 17ul; 18ul; 3ul; 5ul; 16ul;
8ul; 21ul; 24ul; 4ul; 15ul; 23ul; 19ul; 13ul;
12ul; 2ul; 20ul; 14ul; 22ul; 9ul; 6ul; 1ul]
let keccak_piln: lseq piln_t 24 =
assert_norm (List.Tot.length piln_list == 24);
of_list piln_list | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SHA3.Constants.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA3",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA3",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.list (Lib.IntTypes.int_t Lib.IntTypes.U64 Lib.IntTypes.PUB) | Prims.Tot | [
"total"
] | [] | [
"Prims.Cons",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.PUB",
"FStar.UInt64.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | true | false | let rndc_list:list pub_uint64 =
| [
0x0000000000000001uL; 0x0000000000008082uL; 0x800000000000808auL; 0x8000000080008000uL;
0x000000000000808buL; 0x0000000080000001uL; 0x8000000080008081uL; 0x8000000000008009uL;
0x000000000000008auL; 0x0000000000000088uL; 0x0000000080008009uL; 0x000000008000000auL;
0x000000008000808buL; 0x800000000000008buL; 0x8000000000008089uL; 0x8000000000008003uL;
0x8000000000008002uL; 0x8000000000000080uL; 0x000000000000800auL; 0x800000008000000auL;
0x8000000080008081uL; 0x8000000000008080uL; 0x0000000080000001uL; 0x8000000080008008uL
] | false |
Hacl.Poly1305.Field32xN.Lemmas0.fst | Hacl.Poly1305.Field32xN.Lemmas0.smul_add_felem5_fits_lemma_i | val smul_add_felem5_fits_lemma_i:
#w:lanes
-> #m1:scale32
-> #m2:scale32
-> #m3:scale64{m3 + m1 * m2 <= 4096}
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:uint64xN w{felem_fits1 f2 m2}
-> acc1:uint64xN w{felem_wide_fits1 acc1 m3}
-> i:nat{i < w} ->
Lemma ((uint64xN_v (vec_add_mod acc1 (vec_mul_mod f2 u1))).[i] <= (m3 + m1 * m2) * max26 * max26) | val smul_add_felem5_fits_lemma_i:
#w:lanes
-> #m1:scale32
-> #m2:scale32
-> #m3:scale64{m3 + m1 * m2 <= 4096}
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:uint64xN w{felem_fits1 f2 m2}
-> acc1:uint64xN w{felem_wide_fits1 acc1 m3}
-> i:nat{i < w} ->
Lemma ((uint64xN_v (vec_add_mod acc1 (vec_mul_mod f2 u1))).[i] <= (m3 + m1 * m2) * max26 * max26) | let smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 i =
let o = vec_add_mod acc1 (vec_mul_mod f2 u1) in
smul_add_mod_lemma #m1 #m2 #m3 (uint64xN_v u1).[i] (uint64xN_v f2).[i] (uint64xN_v acc1).[i];
assert ((uint64xN_v o).[i] == (uint64xN_v acc1).[i] + (uint64xN_v u1).[i] * (uint64xN_v f2).[i]);
lemma_mult_le (uint64xN_v u1).[i] (m1 * max26) (uint64xN_v f2).[i] (m2 * max26);
assert ((uint64xN_v o).[i] <= m3 * max26 * max26 + m1 * m2 * max26 * max26) | {
"file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas0.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 77,
"end_line": 232,
"start_col": 0,
"start_line": 227
} | module Hacl.Poly1305.Field32xN.Lemmas0
open Lib.IntTypes
open Lib.IntVector
open Lib.Sequence
open FStar.Mul
open FStar.Calc
open Hacl.Spec.Poly1305.Vec
include Hacl.Spec.Poly1305.Field32xN
#reset-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0"
val lemma_prime: unit -> Lemma (pow2 130 % prime = 5)
let lemma_prime () =
assert_norm (pow2 130 % prime = 5 % prime);
assert_norm (5 < prime);
FStar.Math.Lemmas.modulo_lemma 5 prime
val lemma_mult_le: a:nat -> b:nat -> c:nat -> d:nat -> Lemma
(requires a <= b /\ c <= d)
(ensures a * c <= b * d)
let lemma_mult_le a b c d = ()
val lemma_mul5_distr_l: a:nat -> b:nat -> c:nat -> d:nat -> e:nat -> f:nat -> Lemma
(a * (b + c + d + e + f) == a * b + a * c + a * d + a * e + a * f)
let lemma_mul5_distr_l a b c d e f = ()
val lemma_mul5_distr_r: a:nat -> b:nat -> c:nat -> d:nat -> e:nat -> f:nat -> Lemma
((a + b + c + d + e) * f == a * f + b * f + c * f + d * f + e * f)
let lemma_mul5_distr_r a b c d e f = ()
val smul_mod_lemma:
#m1:scale32
-> #m2:scale32
-> a:nat{a <= m1 * max26}
-> b:nat{b <= m2 * max26} ->
Lemma (a * b % pow2 64 == a * b)
let smul_mod_lemma #m1 #m2 a b =
lemma_mult_le a (m1 * max26) b (m2 * max26);
assert (a * b <= m1 * m2 * max26 * max26);
FStar.Math.Lemmas.modulo_lemma (a * b) (pow2 64)
val smul_add_mod_lemma:
#m1:scale32
-> #m2:scale32
-> #m3:scale64{m3 + m1 * m2 <= 4096}
-> a:nat{a <= m1 * max26}
-> b:nat{b <= m2 * max26}
-> c:nat{c <= m3 * max26 * max26} ->
Lemma ((c + a * b % pow2 64) % pow2 64 == c + a * b)
let smul_add_mod_lemma #m1 #m2 #m3 a b c =
assert_norm ((m3 + m1 * m2) * max26 * max26 < pow2 64);
lemma_mult_le a (m1 * max26) b (m2 * max26);
assert (c + a * b <= m3 * max26 * max26 + m1 * m2 * max26 * max26);
FStar.Math.Lemmas.modulo_lemma (c + a * b) (pow2 64)
val add5_lemma1: ma:scale64 -> mb:scale64 -> a:uint64 -> b:uint64 -> Lemma
(requires v a <= ma * max26 /\ v b <= mb * max26 /\ ma + mb <= 64)
(ensures v (a +. b) == v a + v b /\ v (a +. b) <= (ma + mb) * max26)
let add5_lemma1 ma mb a b =
assert (v a + v b <= (ma + mb) * max26);
Math.Lemmas.lemma_mult_le_right max26 (ma + mb) 64;
assert (v a + v b <= 64 * max26);
assert_norm (64 * max26 < pow2 32);
Math.Lemmas.small_mod (v a + v b) (pow2 32)
#set-options "--ifuel 1"
val fadd5_eval_lemma_i:
#w:lanes
-> f1:felem5 w{felem_fits5 f1 (2,2,2,2,2)}
-> f2:felem5 w{felem_fits5 f2 (1,1,1,1,1)}
-> i:nat{i < w} ->
Lemma ((feval5 (fadd5 f1 f2)).[i] == pfadd (feval5 f1).[i] (feval5 f2).[i])
let fadd5_eval_lemma_i #w f1 f2 i =
let o = fadd5 f1 f2 in
let (f10, f11, f12, f13, f14) = as_tup64_i f1 i in
let (f20, f21, f22, f23, f24) = as_tup64_i f2 i in
let (o0, o1, o2, o3, o4) = as_tup64_i o i in
add5_lemma1 2 1 f10 f20;
add5_lemma1 2 1 f11 f21;
add5_lemma1 2 1 f12 f22;
add5_lemma1 2 1 f13 f23;
add5_lemma1 2 1 f14 f24;
assert (as_nat5 (o0, o1, o2, o3, o4) ==
as_nat5 (f10, f11, f12, f13, f14) + as_nat5 (f20, f21, f22, f23, f24));
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (f10, f11, f12, f13, f14)) (as_nat5 (f20, f21, f22, f23, f24)) prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
(as_nat5 (f10, f11, f12, f13, f14) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime
val smul_felem5_fits_lemma_i:
#w:lanes
-> #m1:scale32
-> #m2:scale32
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:uint64xN w{felem_fits1 f2 m2}
-> i:nat{i < w} ->
Lemma ((uint64xN_v (vec_mul_mod f2 u1)).[i] <= m1 * m2 * max26 * max26)
let smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 i =
let o = vec_mul_mod f2 u1 in
smul_mod_lemma #m1 #m2 (uint64xN_v u1).[i] (uint64xN_v f2).[i];
assert ((uint64xN_v o).[i] == (uint64xN_v u1).[i] * (uint64xN_v f2).[i]);
lemma_mult_le (uint64xN_v u1).[i] (m1 * max26) (uint64xN_v f2).[i] (m2 * max26)
val smul_felem5_eval_lemma_i:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2}
-> i:nat{i < w} ->
Lemma ((fas_nat5 (smul_felem5 #w u1 f2)).[i] == (uint64xN_v u1).[i] * (fas_nat5 f2).[i])
let smul_felem5_eval_lemma_i #w #m1 #m2 u1 f2 i =
let o = smul_felem5 #w u1 f2 in
let (m20, m21, m22, m23, m24) = m2 in
let vu1 = (uint64xN_v u1).[i] in
let (tf20, tf21, tf22, tf23, tf24) = as_tup64_i f2 i in
let (to0, to1, to2, to3, to4) = as_tup64_i o i in
smul_mod_lemma #m1 #m20 vu1 (v tf20);
smul_mod_lemma #m1 #m21 vu1 (v tf21);
smul_mod_lemma #m1 #m22 vu1 (v tf22);
smul_mod_lemma #m1 #m23 vu1 (v tf23);
smul_mod_lemma #m1 #m24 vu1 (v tf24);
assert ((fas_nat5 o).[i] == vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 +
vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104);
calc (==) {
vu1 * (fas_nat5 f2).[i];
(==) { }
vu1 * (v tf20 + v tf21 * pow26 + v tf22 * pow52 + v tf23 * pow78 + v tf24 * pow104);
(==) { lemma_mul5_distr_l vu1 (v tf20) (v tf21 * pow26) (v tf22 * pow52) (v tf23 * pow78) (v tf24 * pow104)}
vu1 * v tf20 + vu1 * (v tf21 * pow26) + vu1 * (v tf22 * pow52) + vu1 * (v tf23 * pow78) + vu1 * (v tf24 * pow104);
(==) {
FStar.Math.Lemmas.paren_mul_right vu1 (v tf21) pow26;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf22) pow52;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf23) pow78;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf24) pow104}
vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 + vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104;
};
assert (vu1 * (fas_nat5 f2).[i] == (fas_nat5 o).[i])
val smul_felem5_fits_lemma1:
#w:lanes
-> #m1:scale32
-> #m2:scale32
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:uint64xN w{felem_fits1 f2 m2} ->
Lemma (felem_wide_fits1 (vec_mul_mod f2 u1) (m1 * m2))
let smul_felem5_fits_lemma1 #w #m1 #m2 u1 f2 =
match w with
| 1 ->
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 0
| 2 ->
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 0;
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 1
| 4 ->
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 0;
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 1;
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 2;
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 3
val smul_felem5_fits_lemma:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2} ->
Lemma (felem_wide_fits5 (smul_felem5 #w u1 f2) (m1 *^ m2))
let smul_felem5_fits_lemma #w #m1 #m2 u1 f2 =
let (f20, f21, f22, f23, f24) = f2 in
let (m20, m21, m22, m23, m24) = m2 in
smul_felem5_fits_lemma1 #w #m1 #m20 u1 f20;
smul_felem5_fits_lemma1 #w #m1 #m21 u1 f21;
smul_felem5_fits_lemma1 #w #m1 #m22 u1 f22;
smul_felem5_fits_lemma1 #w #m1 #m23 u1 f23;
smul_felem5_fits_lemma1 #w #m1 #m24 u1 f24
val smul_felem5_eval_lemma:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2} ->
Lemma (fas_nat5 (smul_felem5 #w u1 f2) ==
map2 #nat #nat #nat (fun a b -> a * b) (uint64xN_v u1) (fas_nat5 f2))
let smul_felem5_eval_lemma #w #m1 #m2 u1 f2 =
FStar.Classical.forall_intro (smul_felem5_eval_lemma_i #w #m1 #m2 u1 f2);
eq_intro (fas_nat5 (smul_felem5 #w u1 f2))
(map2 #nat #nat #nat (fun a b -> a * b) (uint64xN_v u1) (fas_nat5 f2))
val smul_add_felem5_fits_lemma_i:
#w:lanes
-> #m1:scale32
-> #m2:scale32
-> #m3:scale64{m3 + m1 * m2 <= 4096}
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:uint64xN w{felem_fits1 f2 m2}
-> acc1:uint64xN w{felem_wide_fits1 acc1 m3}
-> i:nat{i < w} ->
Lemma ((uint64xN_v (vec_add_mod acc1 (vec_mul_mod f2 u1))).[i] <= (m3 + m1 * m2) * max26 * max26) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Poly1305.Vec.fst.checked",
"Hacl.Spec.Poly1305.Field32xN.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Poly1305.Field32xN.Lemmas0.fst"
} | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Poly1305.Field32xN",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Poly1305.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Poly1305.Field32xN",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Poly1305.Field32xN",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
u1: Hacl.Spec.Poly1305.Field32xN.uint64xN w {Hacl.Spec.Poly1305.Field32xN.felem_fits1 u1 m1} ->
f2: Hacl.Spec.Poly1305.Field32xN.uint64xN w {Hacl.Spec.Poly1305.Field32xN.felem_fits1 f2 m2} ->
acc1:
Hacl.Spec.Poly1305.Field32xN.uint64xN w
{Hacl.Spec.Poly1305.Field32xN.felem_wide_fits1 acc1 m3} ->
i: Prims.nat{i < w}
-> FStar.Pervasives.Lemma
(ensures
(Hacl.Spec.Poly1305.Field32xN.uint64xN_v (Lib.IntVector.vec_add_mod acc1
(Lib.IntVector.vec_mul_mod f2 u1))).[ i ] <=
((m3 + m1 * m2) * Hacl.Spec.Poly1305.Field32xN.max26) * Hacl.Spec.Poly1305.Field32xN.max26) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Hacl.Spec.Poly1305.Field32xN.lanes",
"Hacl.Spec.Poly1305.Field32xN.scale32",
"Hacl.Spec.Poly1305.Field32xN.scale64",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Hacl.Spec.Poly1305.Field32xN.uint64xN",
"Hacl.Spec.Poly1305.Field32xN.felem_fits1",
"Hacl.Spec.Poly1305.Field32xN.felem_wide_fits1",
"Prims.nat",
"Prims.op_LessThan",
"Prims._assert",
"Lib.Sequence.op_String_Access",
"Hacl.Spec.Poly1305.Field32xN.uint64xN_v",
"Hacl.Spec.Poly1305.Field32xN.max26",
"Prims.unit",
"Hacl.Poly1305.Field32xN.Lemmas0.lemma_mult_le",
"Prims.eq2",
"Prims.int",
"Hacl.Poly1305.Field32xN.Lemmas0.smul_add_mod_lemma",
"Lib.IntVector.vec_t",
"Lib.IntTypes.U64",
"Lib.IntVector.vec_add_mod",
"Lib.IntVector.vec_mul_mod"
] | [] | true | false | true | false | false | let smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 i =
| let o = vec_add_mod acc1 (vec_mul_mod f2 u1) in
smul_add_mod_lemma #m1 #m2 #m3 (uint64xN_v u1).[ i ] (uint64xN_v f2).[ i ] (uint64xN_v acc1).[ i ];
assert ((uint64xN_v o).[ i ] ==
(uint64xN_v acc1).[ i ] + (uint64xN_v u1).[ i ] * (uint64xN_v f2).[ i ]);
lemma_mult_le (uint64xN_v u1).[ i ] (m1 * max26) (uint64xN_v f2).[ i ] (m2 * max26);
assert ((uint64xN_v o).[ i ] <= (m3 * max26) * max26 + ((m1 * m2) * max26) * max26) | false |
FStar.Tactics.CanonCommSwaps.fst | FStar.Tactics.CanonCommSwaps.swaps_for | val swaps_for : xs: Prims.list a -> Type0 | let swaps_for (#a:eqtype) (xs:list a) = list (swap_for xs) | {
"file_name": "ulib/FStar.Tactics.CanonCommSwaps.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 65,
"end_line": 56,
"start_col": 7,
"start_line": 56
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.CanonCommSwaps
open FStar.List.Tot
let swap (n:nat) :Type = x:nat{x < n-1}
let rec apply_swap_aux (#a:Type) (n:nat) (xs:list a) (s:swap (length xs + n)) :
Pure (list a) (requires True)
(ensures (fun zs -> length zs == length xs)) (decreases xs) =
match xs with
| [] | [_] -> xs
| x1 :: x2 :: xs' -> if n = (s <: nat)
then x2 :: x1 :: xs'
else x1 :: apply_swap_aux (n+1) (x2 :: xs') s
let apply_swap (#a:Type) = apply_swap_aux #a 0
let rec apply_swaps (#a:Type) (xs:list a) (ss:list (swap (length xs))) :
Pure (list a) (requires True)
(ensures (fun zs -> length zs == length xs)) (decreases ss) =
match ss with
| [] -> xs
| s::ss' -> apply_swaps (apply_swap xs s) ss'
let equal_counts (#a:eqtype) (xs ys:list a) : Type0 =
(forall (e:a).{:pattern (count e xs) \/ (count e ys)} count e xs == count e ys)
let extend_equal_counts (#a:eqtype) (h:a) (xs ys:list a) : Lemma
(requires equal_counts xs ys)
(ensures equal_counts (h::xs) (h::ys))
=
()
let retract_equal_counts (#a:eqtype) (h:a) (xs ys:list a) : Lemma
(requires equal_counts (h::xs) (h::ys))
(ensures equal_counts xs ys)
=
assert (forall (e:a).{:pattern (count e xs) \/ (count e ys)} count e (h::xs) == count e (h::ys)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Tactics.CanonCommSwaps.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | xs: Prims.list a -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Prims.eqtype",
"Prims.list",
"FStar.Tactics.CanonCommSwaps.swap_for"
] | [] | false | false | false | false | true | let swaps_for (#a: eqtype) (xs: list a) =
| list (swap_for xs) | false |
|
MerkleTree.fsti | MerkleTree.mt_deserialize_path | val mt_deserialize_path
(rid: HST.erid)
(buf: MTNLS.const_uint8_p)
(len: UInt64.t{CB.length buf = U64.v len})
: HST.ST (B.pointer_or_null (path)) pf pt | val mt_deserialize_path
(rid: HST.erid)
(buf: MTNLS.const_uint8_p)
(len: UInt64.t{CB.length buf = U64.v len})
: HST.ST (B.pointer_or_null (path)) pf pt | let mt_deserialize_path
(rid:HST.erid)
(buf:MTNLS.const_uint8_p)
(len:UInt64.t{CB.length buf = U64.v len})
: HST.ST (B.pointer_or_null (path)) pf pt
= MTNLS.mt_deserialize_path rid buf len | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 39,
"end_line": 353,
"start_col": 0,
"start_line": 348
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r
[@ (Comment " Destructor for hashes") "c_inline"]
let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h
[@ (Comment " Constructor for paths") "c_inline"]
let mt_init_path (hash_size:hash_size_t) (mtr:HH.rid) (r:HST.erid): HST.ST path_p pf pt = MTNL.init_path hash_size mtr r
[@ (Comment " Destructor for paths") "c_inline"]
let mt_free_path (path:path_p): HST.ST unit pf pt = MTNL.free_path path
[@ (Comment " Length of a path
@param[in] p Path
return The length of the path") "c_inline"]
let mt_get_path_length (mtr:HH.rid) (path:const_path_p): HST.ST U32.t pf pt = MTNL.mt_get_path_length mtr path
[@ (Comment " Insert hash into path
@param[in] p Path
@param[in] hash Hash to insert") "c_inline"]
let mt_path_insert
(#h:HS.mem)
(#mtr:HH.rid)
(path:path_p)
(hash:hash #(MTNL.Path?.hash_size (B.get h path 0)))
: HST.ST unit pf pt
= let hash_size = MTNL.Path?.hash_size (B.index path 0ul) in
MTNL.mt_path_insert #hash_size mtr path hash
inline_for_extraction
let path_hash_size (#h:HS.mem) (path:path_p) = MTNL.Path?.hash_size (B.get h path 0)
inline_for_extraction
let const_path_hash_size (#h:HS.mem) (path:const_path_p) = path_hash_size #h (CB.cast path)
inline_for_extraction
let tree_hash_size (#h:HS.mem) (mt:mt_p) = MTNL.MT?.hash_size (B.get h mt 0)
inline_for_extraction
let const_tree_hash_size (#h:HS.mem) (mt:const_mt_p) = tree_hash_size #h (CB.cast mt)
[@ (Comment " Get step on a path
@param[in] p Path
@param[in] i Path step index
return The hash at step i of p") "c_inline"]
let mt_get_path_step
(#h:HS.mem)
(#mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST (hash #(const_path_hash_size #h path)) pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step #hash_size mtr path i
[@ (Comment " Precondition predicate for mt_get_path_step") "c_inline"]
let mt_get_path_step_pre
(#h:HS.mem)
(mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST bool pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step_pre #hash_size mtr path i
[@ (Comment " Construction with custom hash functions
@param[in] hash_size Hash size (in bytes)
@param[in] i The initial hash
return The new Merkle tree") "c_inline"]
let mt_create_custom
(hash_size:hash_size_t)
(hash_spec:Ghost.erased (MTS.hash_fun_t #(U32.v hash_size)))
(r:HST.erid)
(i:hash #hash_size)
(hash_fun:MTNLHF.hash_fun_t #hash_size #hash_spec)
: HST.ST mt_p pf pt
= MTNL.mt_create_custom hash_size hash_spec r i hash_fun
[@ (Comment " Destruction
@param[in] mt The Merkle tree") "c_inline"]
let mt_free (mt:mt_p): HST.ST unit pf pt = MTNL.mt_free mt
[@ (Comment " Insertion
@param[in] mt The Merkle tree
@param[in] v The tree does not take ownership of the hash, it makes a copy of its content.
Note: The content of the hash will be overwritten with an arbitrary value.") "c_inline"]
let mt_insert
(#h:HS.mem)
(mt:mt_p)
(v:hash #(tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index mt 0ul) in
MTNL.mt_insert hash_size mt v
[@ (Comment " Precondition predicate for mt_insert") "c_inline"]
let mt_insert_pre
(#h:HS.mem)
(mt:const_mt_p)
(v:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_insert_pre #hash_size mt v
[@ (Comment " Getting the Merkle root
@param[in] mt The Merkle tree
@param[out] root The Merkle root") "c_inline"]
let mt_get_root
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root #hash_size mt root
[@ (Comment " Precondition predicate for mt_get_root") "c_inline"]
let mt_get_root_pre
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root_pre #hash_size mt root
[@ (Comment " Getting a Merkle path
@param[in] mt The Merkle tree
@param[in] idx The index of the target hash
@param[out] path A resulting Merkle path that contains the leaf hash.
@param[out] root The Merkle root
return The number of elements in the tree
Notes:
- The resulting path contains pointers to hashes in the tree, not copies of
the hash values.
- idx must be within the currently held indices in the tree (past the
last flush index).") "c_inline"]
let mt_get_path
(#h:HS.mem)
(mt:const_mt_p)
(idx:offset_t)
(path:path_p{path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(path_hash_size #h path))
: HST.ST index_t pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_path #hash_size mt idx path root
[@ (Comment " Precondition predicate for mt_get_path") "c_inline"]
let mt_get_path_pre
(#h:HS.mem)
(mt:const_mt_p)
(idx:offset_t)
(path:const_path_p{const_path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(const_path_hash_size #h path))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_path_pre #hash_size mt idx path root
[@ (Comment " Flush the Merkle tree
@param[in] mt The Merkle tree") "c_inline"]
let mt_flush (mt:mt_p): HST.ST unit pf pt = MTNL.mt_flush mt
[@ (Comment " Precondition predicate for mt_flush") "c_inline"]
let mt_flush_pre (mt:const_mt_p): HST.ST bool pf pt = MTNL.mt_flush_pre mt
[@ (Comment " Flush the Merkle tree up to a given index
@param[in] mt The Merkle tree
@param[in] idx The index up to which to flush the tree") "c_inline"]
let mt_flush_to (mt:mt_p) (idx:offset_t): HST.ST unit pf pt = MTNL.mt_flush_to mt idx
[@ (Comment " Precondition predicate for mt_flush_to")]
let mt_flush_to_pre (mt:const_mt_p) (idx:offset_t): HST.ST bool pf pt = MTNL.mt_flush_to_pre mt idx
[@ (Comment " Retract the Merkle tree down to a given index
@param[in] mt The Merkle tree
@param[in] idx The index to retract the tree to
Note: The element and idx will remain in the tree.") "c_inline"]
let mt_retract_to (mt:mt_p) (idx:offset_t): HST.ST unit pf pt = MTNL.mt_retract_to mt idx
[@ (Comment " Precondition predicate for mt_retract_to") "c_inline"]
let mt_retract_to_pre (mt:const_mt_p) (idx:offset_t): HST.ST bool pf pt = MTNL.mt_retract_to_pre mt idx
[@ (Comment " Client-side verification
@param[in] mt The Merkle tree
@param[in] tgt The index of the target hash
@param[in] max The maximum index + 1 of the tree when the path was generated
@param[in] path The Merkle path to verify
@param[in] root
return true if the verification succeeded, false otherwise
Note: max - tgt must be less than 2^32.") "c_inline"]
let mt_verify
(#h:HS.mem)
(#hash_size:Ghost.erased hash_size_t)
(#hash_spec:MTS.hash_fun_t #(U32.v hash_size))
(mt:const_mt_p)
(tgt:UInt64.t)
(max:UInt64.t)
(mtr:HH.rid)
(path:const_path_p{let phs = const_path_hash_size #h path in phs = const_tree_hash_size #h mt /\ phs = Ghost.reveal hash_size})
(root:hash #(const_path_hash_size #h path))
: HST.ST bool pf pt
= let dmt = B.index (CB.cast mt) 0ul in
let hsz = MTNL.MT?.hash_size dmt in
MTNL.mt_verify #hsz #hash_spec mt tgt max mtr path root
[@ (Comment " Precondition predicate for mt_verify") "c_inline"]
let mt_verify_pre
(#h:HS.mem)
(mt:const_mt_p)
(tgt:UInt64.t)
(max:UInt64.t)
(mtr:HH.rid)
(path:const_path_p{const_path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(const_path_hash_size #h path))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_verify_pre #hash_size mt tgt max mtr path root
[@ (Comment " Serialization size
@param[in] mt The Merkle tree
return the number of bytes required to serialize the tree") "c_inline"]
let mt_serialize_size (mt:const_mt_p): HST.ST UInt64.t pf pt = MTNLS.mt_serialize_size mt
[@ (Comment " Merkle tree serialization
@param[in] mt The Merkle tree
@param[out] buf The buffer to serialize the tree into
@param[in] len Length of buf
return the number of bytes written
Note: buf must be a buffer of size mt_serialize_size(mt) or larger, but
smaller than 2^32 (larger buffers are currently not supported).") "c_inline"]
let mt_serialize (mt:const_mt_p) (buf:MTNLS.uint8_p) (len:UInt64.t): HST.ST UInt64.t pf pt = MTNLS.mt_serialize mt buf len
[@ (Comment " Merkle tree deserialization
@param[in] expected_hash_size Expected hash size to match hash_fun
@param[in] buf The buffer to deserialize the tree from
@param[in] len Length of buf
@param[in] hash_fun Hash function
return pointer to the new tree if successful, NULL otherwise
Note: buf must point to an allocated buffer.") "c_inline"]
let mt_deserialize
(#hsz:Ghost.erased hash_size_t)
(rid:HST.erid)
(buf:MTNLS.const_uint8_p)
(len:UInt64.t{CB.length buf = U64.v len})
(hash_spec:Ghost.erased(MTS.hash_fun_t #(U32.v hsz)))
(hash_fun:MTNLHF.hash_fun_t #hsz #hash_spec)
: HST.ST (B.pointer_or_null merkle_tree) pf pt
= MTNLS.mt_deserialize #hsz rid buf len hash_spec hash_fun
[@ (Comment " Path serialization
@param[in] path The path
@param[out] buf The buffer to serialize the path into
@param[in] len Length of buf
return the number of bytes written") "c_inline"]
let mt_serialize_path
(path:const_path_p)
(buf:MTNLS.uint8_p)
(len:UInt64.t)
: HST.ST UInt64.t pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNLS.mt_serialize_path #hash_size path buf len
[@ (Comment " Path deserialization
@param[in] buf The buffer to deserialize the path from
@param[in] len Length of buf
return pointer to the new path if successful, NULL otherwise | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 |
rid: FStar.HyperStack.ST.erid ->
buf: MerkleTree.Low.Serialization.const_uint8_p ->
len: FStar.UInt64.t{LowStar.ConstBuffer.length buf = FStar.UInt64.v len}
-> FStar.HyperStack.ST.ST (LowStar.Buffer.pointer_or_null MerkleTree.path) | FStar.HyperStack.ST.ST | [] | [] | [
"FStar.HyperStack.ST.erid",
"MerkleTree.Low.Serialization.const_uint8_p",
"FStar.UInt64.t",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt.size",
"FStar.UInt64.n",
"LowStar.ConstBuffer.length",
"MerkleTree.Low.Serialization.uint8_t",
"FStar.UInt64.v",
"MerkleTree.Low.Serialization.mt_deserialize_path",
"LowStar.Buffer.pointer_or_null",
"MerkleTree.Low.path",
"MerkleTree.path",
"MerkleTree.pf",
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.pt"
] | [] | false | true | false | false | false | let mt_deserialize_path
(rid: HST.erid)
(buf: MTNLS.const_uint8_p)
(len: UInt64.t{CB.length buf = U64.v len})
: HST.ST (B.pointer_or_null (path)) pf pt =
| MTNLS.mt_deserialize_path rid buf len | false |
FStar.Tactics.CanonCommSwaps.fst | FStar.Tactics.CanonCommSwaps.apply_swaps | val apply_swaps (#a: Type) (xs: list a) (ss: list (swap (length xs)))
: Pure (list a) (requires True) (ensures (fun zs -> length zs == length xs)) (decreases ss) | val apply_swaps (#a: Type) (xs: list a) (ss: list (swap (length xs)))
: Pure (list a) (requires True) (ensures (fun zs -> length zs == length xs)) (decreases ss) | let rec apply_swaps (#a:Type) (xs:list a) (ss:list (swap (length xs))) :
Pure (list a) (requires True)
(ensures (fun zs -> length zs == length xs)) (decreases ss) =
match ss with
| [] -> xs
| s::ss' -> apply_swaps (apply_swap xs s) ss' | {
"file_name": "ulib/FStar.Tactics.CanonCommSwaps.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 47,
"end_line": 38,
"start_col": 0,
"start_line": 33
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.CanonCommSwaps
open FStar.List.Tot
let swap (n:nat) :Type = x:nat{x < n-1}
let rec apply_swap_aux (#a:Type) (n:nat) (xs:list a) (s:swap (length xs + n)) :
Pure (list a) (requires True)
(ensures (fun zs -> length zs == length xs)) (decreases xs) =
match xs with
| [] | [_] -> xs
| x1 :: x2 :: xs' -> if n = (s <: nat)
then x2 :: x1 :: xs'
else x1 :: apply_swap_aux (n+1) (x2 :: xs') s
let apply_swap (#a:Type) = apply_swap_aux #a 0 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Tactics.CanonCommSwaps.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 |
xs: Prims.list a ->
ss: Prims.list (FStar.Tactics.CanonCommSwaps.swap (FStar.List.Tot.Base.length xs))
-> Prims.Pure (Prims.list a) | Prims.Pure | [
""
] | [] | [
"Prims.list",
"FStar.Tactics.CanonCommSwaps.swap",
"FStar.List.Tot.Base.length",
"FStar.Tactics.CanonCommSwaps.apply_swaps",
"FStar.Tactics.CanonCommSwaps.apply_swap",
"Prims.l_True",
"Prims.eq2",
"Prims.nat"
] | [
"recursion"
] | false | false | false | false | false | let rec apply_swaps (#a: Type) (xs: list a) (ss: list (swap (length xs)))
: Pure (list a) (requires True) (ensures (fun zs -> length zs == length xs)) (decreases ss) =
| match ss with
| [] -> xs
| s :: ss' -> apply_swaps (apply_swap xs s) ss' | false |
MerkleTree.fsti | MerkleTree.mt_deserialize | val mt_deserialize
(#hsz: Ghost.erased hash_size_t)
(rid: HST.erid)
(buf: MTNLS.const_uint8_p)
(len: UInt64.t{CB.length buf = U64.v len})
(hash_spec: Ghost.erased (MTS.hash_fun_t #(U32.v hsz)))
(hash_fun: MTNLHF.hash_fun_t #hsz #hash_spec)
: HST.ST (B.pointer_or_null merkle_tree) pf pt | val mt_deserialize
(#hsz: Ghost.erased hash_size_t)
(rid: HST.erid)
(buf: MTNLS.const_uint8_p)
(len: UInt64.t{CB.length buf = U64.v len})
(hash_spec: Ghost.erased (MTS.hash_fun_t #(U32.v hsz)))
(hash_fun: MTNLHF.hash_fun_t #hsz #hash_spec)
: HST.ST (B.pointer_or_null merkle_tree) pf pt | let mt_deserialize
(#hsz:Ghost.erased hash_size_t)
(rid:HST.erid)
(buf:MTNLS.const_uint8_p)
(len:UInt64.t{CB.length buf = U64.v len})
(hash_spec:Ghost.erased(MTS.hash_fun_t #(U32.v hsz)))
(hash_fun:MTNLHF.hash_fun_t #hsz #hash_spec)
: HST.ST (B.pointer_or_null merkle_tree) pf pt
= MTNLS.mt_deserialize #hsz rid buf len hash_spec hash_fun | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 58,
"end_line": 321,
"start_col": 0,
"start_line": 313
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r
[@ (Comment " Destructor for hashes") "c_inline"]
let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h
[@ (Comment " Constructor for paths") "c_inline"]
let mt_init_path (hash_size:hash_size_t) (mtr:HH.rid) (r:HST.erid): HST.ST path_p pf pt = MTNL.init_path hash_size mtr r
[@ (Comment " Destructor for paths") "c_inline"]
let mt_free_path (path:path_p): HST.ST unit pf pt = MTNL.free_path path
[@ (Comment " Length of a path
@param[in] p Path
return The length of the path") "c_inline"]
let mt_get_path_length (mtr:HH.rid) (path:const_path_p): HST.ST U32.t pf pt = MTNL.mt_get_path_length mtr path
[@ (Comment " Insert hash into path
@param[in] p Path
@param[in] hash Hash to insert") "c_inline"]
let mt_path_insert
(#h:HS.mem)
(#mtr:HH.rid)
(path:path_p)
(hash:hash #(MTNL.Path?.hash_size (B.get h path 0)))
: HST.ST unit pf pt
= let hash_size = MTNL.Path?.hash_size (B.index path 0ul) in
MTNL.mt_path_insert #hash_size mtr path hash
inline_for_extraction
let path_hash_size (#h:HS.mem) (path:path_p) = MTNL.Path?.hash_size (B.get h path 0)
inline_for_extraction
let const_path_hash_size (#h:HS.mem) (path:const_path_p) = path_hash_size #h (CB.cast path)
inline_for_extraction
let tree_hash_size (#h:HS.mem) (mt:mt_p) = MTNL.MT?.hash_size (B.get h mt 0)
inline_for_extraction
let const_tree_hash_size (#h:HS.mem) (mt:const_mt_p) = tree_hash_size #h (CB.cast mt)
[@ (Comment " Get step on a path
@param[in] p Path
@param[in] i Path step index
return The hash at step i of p") "c_inline"]
let mt_get_path_step
(#h:HS.mem)
(#mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST (hash #(const_path_hash_size #h path)) pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step #hash_size mtr path i
[@ (Comment " Precondition predicate for mt_get_path_step") "c_inline"]
let mt_get_path_step_pre
(#h:HS.mem)
(mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST bool pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step_pre #hash_size mtr path i
[@ (Comment " Construction with custom hash functions
@param[in] hash_size Hash size (in bytes)
@param[in] i The initial hash
return The new Merkle tree") "c_inline"]
let mt_create_custom
(hash_size:hash_size_t)
(hash_spec:Ghost.erased (MTS.hash_fun_t #(U32.v hash_size)))
(r:HST.erid)
(i:hash #hash_size)
(hash_fun:MTNLHF.hash_fun_t #hash_size #hash_spec)
: HST.ST mt_p pf pt
= MTNL.mt_create_custom hash_size hash_spec r i hash_fun
[@ (Comment " Destruction
@param[in] mt The Merkle tree") "c_inline"]
let mt_free (mt:mt_p): HST.ST unit pf pt = MTNL.mt_free mt
[@ (Comment " Insertion
@param[in] mt The Merkle tree
@param[in] v The tree does not take ownership of the hash, it makes a copy of its content.
Note: The content of the hash will be overwritten with an arbitrary value.") "c_inline"]
let mt_insert
(#h:HS.mem)
(mt:mt_p)
(v:hash #(tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index mt 0ul) in
MTNL.mt_insert hash_size mt v
[@ (Comment " Precondition predicate for mt_insert") "c_inline"]
let mt_insert_pre
(#h:HS.mem)
(mt:const_mt_p)
(v:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_insert_pre #hash_size mt v
[@ (Comment " Getting the Merkle root
@param[in] mt The Merkle tree
@param[out] root The Merkle root") "c_inline"]
let mt_get_root
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root #hash_size mt root
[@ (Comment " Precondition predicate for mt_get_root") "c_inline"]
let mt_get_root_pre
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root_pre #hash_size mt root
[@ (Comment " Getting a Merkle path
@param[in] mt The Merkle tree
@param[in] idx The index of the target hash
@param[out] path A resulting Merkle path that contains the leaf hash.
@param[out] root The Merkle root
return The number of elements in the tree
Notes:
- The resulting path contains pointers to hashes in the tree, not copies of
the hash values.
- idx must be within the currently held indices in the tree (past the
last flush index).") "c_inline"]
let mt_get_path
(#h:HS.mem)
(mt:const_mt_p)
(idx:offset_t)
(path:path_p{path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(path_hash_size #h path))
: HST.ST index_t pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_path #hash_size mt idx path root
[@ (Comment " Precondition predicate for mt_get_path") "c_inline"]
let mt_get_path_pre
(#h:HS.mem)
(mt:const_mt_p)
(idx:offset_t)
(path:const_path_p{const_path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(const_path_hash_size #h path))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_path_pre #hash_size mt idx path root
[@ (Comment " Flush the Merkle tree
@param[in] mt The Merkle tree") "c_inline"]
let mt_flush (mt:mt_p): HST.ST unit pf pt = MTNL.mt_flush mt
[@ (Comment " Precondition predicate for mt_flush") "c_inline"]
let mt_flush_pre (mt:const_mt_p): HST.ST bool pf pt = MTNL.mt_flush_pre mt
[@ (Comment " Flush the Merkle tree up to a given index
@param[in] mt The Merkle tree
@param[in] idx The index up to which to flush the tree") "c_inline"]
let mt_flush_to (mt:mt_p) (idx:offset_t): HST.ST unit pf pt = MTNL.mt_flush_to mt idx
[@ (Comment " Precondition predicate for mt_flush_to")]
let mt_flush_to_pre (mt:const_mt_p) (idx:offset_t): HST.ST bool pf pt = MTNL.mt_flush_to_pre mt idx
[@ (Comment " Retract the Merkle tree down to a given index
@param[in] mt The Merkle tree
@param[in] idx The index to retract the tree to
Note: The element and idx will remain in the tree.") "c_inline"]
let mt_retract_to (mt:mt_p) (idx:offset_t): HST.ST unit pf pt = MTNL.mt_retract_to mt idx
[@ (Comment " Precondition predicate for mt_retract_to") "c_inline"]
let mt_retract_to_pre (mt:const_mt_p) (idx:offset_t): HST.ST bool pf pt = MTNL.mt_retract_to_pre mt idx
[@ (Comment " Client-side verification
@param[in] mt The Merkle tree
@param[in] tgt The index of the target hash
@param[in] max The maximum index + 1 of the tree when the path was generated
@param[in] path The Merkle path to verify
@param[in] root
return true if the verification succeeded, false otherwise
Note: max - tgt must be less than 2^32.") "c_inline"]
let mt_verify
(#h:HS.mem)
(#hash_size:Ghost.erased hash_size_t)
(#hash_spec:MTS.hash_fun_t #(U32.v hash_size))
(mt:const_mt_p)
(tgt:UInt64.t)
(max:UInt64.t)
(mtr:HH.rid)
(path:const_path_p{let phs = const_path_hash_size #h path in phs = const_tree_hash_size #h mt /\ phs = Ghost.reveal hash_size})
(root:hash #(const_path_hash_size #h path))
: HST.ST bool pf pt
= let dmt = B.index (CB.cast mt) 0ul in
let hsz = MTNL.MT?.hash_size dmt in
MTNL.mt_verify #hsz #hash_spec mt tgt max mtr path root
[@ (Comment " Precondition predicate for mt_verify") "c_inline"]
let mt_verify_pre
(#h:HS.mem)
(mt:const_mt_p)
(tgt:UInt64.t)
(max:UInt64.t)
(mtr:HH.rid)
(path:const_path_p{const_path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(const_path_hash_size #h path))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_verify_pre #hash_size mt tgt max mtr path root
[@ (Comment " Serialization size
@param[in] mt The Merkle tree
return the number of bytes required to serialize the tree") "c_inline"]
let mt_serialize_size (mt:const_mt_p): HST.ST UInt64.t pf pt = MTNLS.mt_serialize_size mt
[@ (Comment " Merkle tree serialization
@param[in] mt The Merkle tree
@param[out] buf The buffer to serialize the tree into
@param[in] len Length of buf
return the number of bytes written
Note: buf must be a buffer of size mt_serialize_size(mt) or larger, but
smaller than 2^32 (larger buffers are currently not supported).") "c_inline"]
let mt_serialize (mt:const_mt_p) (buf:MTNLS.uint8_p) (len:UInt64.t): HST.ST UInt64.t pf pt = MTNLS.mt_serialize mt buf len
[@ (Comment " Merkle tree deserialization
@param[in] expected_hash_size Expected hash size to match hash_fun
@param[in] buf The buffer to deserialize the tree from
@param[in] len Length of buf
@param[in] hash_fun Hash function
return pointer to the new tree if successful, NULL otherwise | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 |
rid: FStar.HyperStack.ST.erid ->
buf: MerkleTree.Low.Serialization.const_uint8_p ->
len: FStar.UInt64.t{LowStar.ConstBuffer.length buf = FStar.UInt64.v len} ->
hash_spec: FStar.Ghost.erased MerkleTree.Spec.hash_fun_t ->
hash_fun: MerkleTree.Low.Hashfunctions.hash_fun_t
-> FStar.HyperStack.ST.ST (LowStar.Buffer.pointer_or_null MerkleTree.merkle_tree) | FStar.HyperStack.ST.ST | [] | [] | [
"FStar.Ghost.erased",
"MerkleTree.hash_size_t",
"FStar.HyperStack.ST.erid",
"MerkleTree.Low.Serialization.const_uint8_p",
"FStar.UInt64.t",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt.size",
"FStar.UInt64.n",
"LowStar.ConstBuffer.length",
"MerkleTree.Low.Serialization.uint8_t",
"FStar.UInt64.v",
"MerkleTree.Spec.hash_fun_t",
"FStar.UInt32.v",
"FStar.Ghost.reveal",
"MerkleTree.Low.Hashfunctions.hash_fun_t",
"MerkleTree.Low.Serialization.mt_deserialize",
"LowStar.Buffer.pointer_or_null",
"MerkleTree.Low.merkle_tree",
"MerkleTree.merkle_tree",
"MerkleTree.pf",
"FStar.Monotonic.HyperStack.mem",
"MerkleTree.pt"
] | [] | false | true | false | false | false | let mt_deserialize
(#hsz: Ghost.erased hash_size_t)
(rid: HST.erid)
(buf: MTNLS.const_uint8_p)
(len: UInt64.t{CB.length buf = U64.v len})
(hash_spec: Ghost.erased (MTS.hash_fun_t #(U32.v hsz)))
(hash_fun: MTNLHF.hash_fun_t #hsz #hash_spec)
: HST.ST (B.pointer_or_null merkle_tree) pf pt =
| MTNLS.mt_deserialize #hsz rid buf len hash_spec hash_fun | false |
FStar.Tactics.CanonCommSwaps.fst | FStar.Tactics.CanonCommSwaps.retract_equal_counts | val retract_equal_counts (#a: eqtype) (h: a) (xs ys: list a)
: Lemma (requires equal_counts (h :: xs) (h :: ys)) (ensures equal_counts xs ys) | val retract_equal_counts (#a: eqtype) (h: a) (xs ys: list a)
: Lemma (requires equal_counts (h :: xs) (h :: ys)) (ensures equal_counts xs ys) | let retract_equal_counts (#a:eqtype) (h:a) (xs ys:list a) : Lemma
(requires equal_counts (h::xs) (h::ys))
(ensures equal_counts xs ys)
=
assert (forall (e:a).{:pattern (count e xs) \/ (count e ys)} count e (h::xs) == count e (h::ys)) | {
"file_name": "ulib/FStar.Tactics.CanonCommSwaps.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 98,
"end_line": 53,
"start_col": 0,
"start_line": 49
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.CanonCommSwaps
open FStar.List.Tot
let swap (n:nat) :Type = x:nat{x < n-1}
let rec apply_swap_aux (#a:Type) (n:nat) (xs:list a) (s:swap (length xs + n)) :
Pure (list a) (requires True)
(ensures (fun zs -> length zs == length xs)) (decreases xs) =
match xs with
| [] | [_] -> xs
| x1 :: x2 :: xs' -> if n = (s <: nat)
then x2 :: x1 :: xs'
else x1 :: apply_swap_aux (n+1) (x2 :: xs') s
let apply_swap (#a:Type) = apply_swap_aux #a 0
let rec apply_swaps (#a:Type) (xs:list a) (ss:list (swap (length xs))) :
Pure (list a) (requires True)
(ensures (fun zs -> length zs == length xs)) (decreases ss) =
match ss with
| [] -> xs
| s::ss' -> apply_swaps (apply_swap xs s) ss'
let equal_counts (#a:eqtype) (xs ys:list a) : Type0 =
(forall (e:a).{:pattern (count e xs) \/ (count e ys)} count e xs == count e ys)
let extend_equal_counts (#a:eqtype) (h:a) (xs ys:list a) : Lemma
(requires equal_counts xs ys)
(ensures equal_counts (h::xs) (h::ys))
=
() | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Tactics.CanonCommSwaps.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | h: a -> xs: Prims.list a -> ys: Prims.list a
-> FStar.Pervasives.Lemma (requires FStar.Tactics.CanonCommSwaps.equal_counts (h :: xs) (h :: ys))
(ensures FStar.Tactics.CanonCommSwaps.equal_counts xs ys) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.eqtype",
"Prims.list",
"Prims._assert",
"Prims.l_Forall",
"Prims.eq2",
"Prims.nat",
"FStar.List.Tot.Base.count",
"Prims.Cons",
"Prims.unit",
"FStar.Tactics.CanonCommSwaps.equal_counts",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let retract_equal_counts (#a: eqtype) (h: a) (xs ys: list a)
: Lemma (requires equal_counts (h :: xs) (h :: ys)) (ensures equal_counts xs ys) =
| assert (forall (e: a). {:pattern (count e xs)\/(count e ys)} count e (h :: xs) == count e (h :: ys)) | false |
Hacl.Poly1305.Field32xN.Lemmas0.fst | Hacl.Poly1305.Field32xN.Lemmas0.lemma_fmul5_pow26 | val lemma_fmul5_pow26: r:tup64_5 -> Lemma
(requires (let (r0, r1, r2, r3, r4) = r in v r4 * 5 <= 10 * pow26))
(ensures (let (r0, r1, r2, r3, r4) = r in
(pow26 * as_nat5 r) % prime == as_nat5 (r4 *! u64 5, r0, r1, r2, r3) % prime)) | val lemma_fmul5_pow26: r:tup64_5 -> Lemma
(requires (let (r0, r1, r2, r3, r4) = r in v r4 * 5 <= 10 * pow26))
(ensures (let (r0, r1, r2, r3, r4) = r in
(pow26 * as_nat5 r) % prime == as_nat5 (r4 *! u64 5, r0, r1, r2, r3) % prime)) | let lemma_fmul5_pow26 r =
let (r0, r1, r2, r3, r4) = r in
calc (==) {
(pow26 * as_nat5 r) % prime;
(==) { }
(pow26 * (v r0 + v r1 * pow26 + v r2 * pow52 + v r3 * pow78 + v r4 * pow104)) % prime;
(==) { lemma_mul5_distr_l pow26 (v r0) (v r1 * pow26) (v r2 * pow52) (v r3 * pow78) (v r4 * pow104) }
(v r0 * pow26 + pow26 * v r1 * pow26 + pow26 * v r2 * pow52 + pow26 * v r3 * pow78 + pow26 * v r4 * pow104) % prime;
(==) { }
(v r0 * pow26 + v r1 * pow26 * pow26 + v r2 * pow26 * pow52 + v r3 * pow26 * pow78 + v r4 * pow26 * pow104) % prime;
(==) {
assert_norm (pow26 * pow26 = pow52);
assert_norm (pow26 * pow52 = pow78);
assert_norm (pow26 * pow78 = pow104);
assert_norm (pow26 * pow104 = pow2 130) }
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + v r4 * pow2 130) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104) (v r4 * pow2 130) prime }
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + (v r4 * pow2 130) % prime) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (v r4) (pow2 130) prime }
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + (v r4 * (pow2 130 % prime)) % prime) % prime;
(==) { lemma_prime () }
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + (v r4 * 5) % prime) % prime;
(==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104) (v r4 * 5) prime }
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + v r4 * 5) % prime;
};
assert ((pow26 * as_nat5 r) % prime ==
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + v r4 * 5) % prime) | {
"file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas0.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 84,
"end_line": 395,
"start_col": 0,
"start_line": 367
} | module Hacl.Poly1305.Field32xN.Lemmas0
open Lib.IntTypes
open Lib.IntVector
open Lib.Sequence
open FStar.Mul
open FStar.Calc
open Hacl.Spec.Poly1305.Vec
include Hacl.Spec.Poly1305.Field32xN
#reset-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0"
val lemma_prime: unit -> Lemma (pow2 130 % prime = 5)
let lemma_prime () =
assert_norm (pow2 130 % prime = 5 % prime);
assert_norm (5 < prime);
FStar.Math.Lemmas.modulo_lemma 5 prime
val lemma_mult_le: a:nat -> b:nat -> c:nat -> d:nat -> Lemma
(requires a <= b /\ c <= d)
(ensures a * c <= b * d)
let lemma_mult_le a b c d = ()
val lemma_mul5_distr_l: a:nat -> b:nat -> c:nat -> d:nat -> e:nat -> f:nat -> Lemma
(a * (b + c + d + e + f) == a * b + a * c + a * d + a * e + a * f)
let lemma_mul5_distr_l a b c d e f = ()
val lemma_mul5_distr_r: a:nat -> b:nat -> c:nat -> d:nat -> e:nat -> f:nat -> Lemma
((a + b + c + d + e) * f == a * f + b * f + c * f + d * f + e * f)
let lemma_mul5_distr_r a b c d e f = ()
val smul_mod_lemma:
#m1:scale32
-> #m2:scale32
-> a:nat{a <= m1 * max26}
-> b:nat{b <= m2 * max26} ->
Lemma (a * b % pow2 64 == a * b)
let smul_mod_lemma #m1 #m2 a b =
lemma_mult_le a (m1 * max26) b (m2 * max26);
assert (a * b <= m1 * m2 * max26 * max26);
FStar.Math.Lemmas.modulo_lemma (a * b) (pow2 64)
val smul_add_mod_lemma:
#m1:scale32
-> #m2:scale32
-> #m3:scale64{m3 + m1 * m2 <= 4096}
-> a:nat{a <= m1 * max26}
-> b:nat{b <= m2 * max26}
-> c:nat{c <= m3 * max26 * max26} ->
Lemma ((c + a * b % pow2 64) % pow2 64 == c + a * b)
let smul_add_mod_lemma #m1 #m2 #m3 a b c =
assert_norm ((m3 + m1 * m2) * max26 * max26 < pow2 64);
lemma_mult_le a (m1 * max26) b (m2 * max26);
assert (c + a * b <= m3 * max26 * max26 + m1 * m2 * max26 * max26);
FStar.Math.Lemmas.modulo_lemma (c + a * b) (pow2 64)
val add5_lemma1: ma:scale64 -> mb:scale64 -> a:uint64 -> b:uint64 -> Lemma
(requires v a <= ma * max26 /\ v b <= mb * max26 /\ ma + mb <= 64)
(ensures v (a +. b) == v a + v b /\ v (a +. b) <= (ma + mb) * max26)
let add5_lemma1 ma mb a b =
assert (v a + v b <= (ma + mb) * max26);
Math.Lemmas.lemma_mult_le_right max26 (ma + mb) 64;
assert (v a + v b <= 64 * max26);
assert_norm (64 * max26 < pow2 32);
Math.Lemmas.small_mod (v a + v b) (pow2 32)
#set-options "--ifuel 1"
val fadd5_eval_lemma_i:
#w:lanes
-> f1:felem5 w{felem_fits5 f1 (2,2,2,2,2)}
-> f2:felem5 w{felem_fits5 f2 (1,1,1,1,1)}
-> i:nat{i < w} ->
Lemma ((feval5 (fadd5 f1 f2)).[i] == pfadd (feval5 f1).[i] (feval5 f2).[i])
let fadd5_eval_lemma_i #w f1 f2 i =
let o = fadd5 f1 f2 in
let (f10, f11, f12, f13, f14) = as_tup64_i f1 i in
let (f20, f21, f22, f23, f24) = as_tup64_i f2 i in
let (o0, o1, o2, o3, o4) = as_tup64_i o i in
add5_lemma1 2 1 f10 f20;
add5_lemma1 2 1 f11 f21;
add5_lemma1 2 1 f12 f22;
add5_lemma1 2 1 f13 f23;
add5_lemma1 2 1 f14 f24;
assert (as_nat5 (o0, o1, o2, o3, o4) ==
as_nat5 (f10, f11, f12, f13, f14) + as_nat5 (f20, f21, f22, f23, f24));
FStar.Math.Lemmas.lemma_mod_plus_distr_l
(as_nat5 (f10, f11, f12, f13, f14)) (as_nat5 (f20, f21, f22, f23, f24)) prime;
FStar.Math.Lemmas.lemma_mod_plus_distr_r
(as_nat5 (f10, f11, f12, f13, f14) % prime) (as_nat5 (f20, f21, f22, f23, f24)) prime
val smul_felem5_fits_lemma_i:
#w:lanes
-> #m1:scale32
-> #m2:scale32
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:uint64xN w{felem_fits1 f2 m2}
-> i:nat{i < w} ->
Lemma ((uint64xN_v (vec_mul_mod f2 u1)).[i] <= m1 * m2 * max26 * max26)
let smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 i =
let o = vec_mul_mod f2 u1 in
smul_mod_lemma #m1 #m2 (uint64xN_v u1).[i] (uint64xN_v f2).[i];
assert ((uint64xN_v o).[i] == (uint64xN_v u1).[i] * (uint64xN_v f2).[i]);
lemma_mult_le (uint64xN_v u1).[i] (m1 * max26) (uint64xN_v f2).[i] (m2 * max26)
val smul_felem5_eval_lemma_i:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2}
-> i:nat{i < w} ->
Lemma ((fas_nat5 (smul_felem5 #w u1 f2)).[i] == (uint64xN_v u1).[i] * (fas_nat5 f2).[i])
let smul_felem5_eval_lemma_i #w #m1 #m2 u1 f2 i =
let o = smul_felem5 #w u1 f2 in
let (m20, m21, m22, m23, m24) = m2 in
let vu1 = (uint64xN_v u1).[i] in
let (tf20, tf21, tf22, tf23, tf24) = as_tup64_i f2 i in
let (to0, to1, to2, to3, to4) = as_tup64_i o i in
smul_mod_lemma #m1 #m20 vu1 (v tf20);
smul_mod_lemma #m1 #m21 vu1 (v tf21);
smul_mod_lemma #m1 #m22 vu1 (v tf22);
smul_mod_lemma #m1 #m23 vu1 (v tf23);
smul_mod_lemma #m1 #m24 vu1 (v tf24);
assert ((fas_nat5 o).[i] == vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 +
vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104);
calc (==) {
vu1 * (fas_nat5 f2).[i];
(==) { }
vu1 * (v tf20 + v tf21 * pow26 + v tf22 * pow52 + v tf23 * pow78 + v tf24 * pow104);
(==) { lemma_mul5_distr_l vu1 (v tf20) (v tf21 * pow26) (v tf22 * pow52) (v tf23 * pow78) (v tf24 * pow104)}
vu1 * v tf20 + vu1 * (v tf21 * pow26) + vu1 * (v tf22 * pow52) + vu1 * (v tf23 * pow78) + vu1 * (v tf24 * pow104);
(==) {
FStar.Math.Lemmas.paren_mul_right vu1 (v tf21) pow26;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf22) pow52;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf23) pow78;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf24) pow104}
vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 + vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104;
};
assert (vu1 * (fas_nat5 f2).[i] == (fas_nat5 o).[i])
val smul_felem5_fits_lemma1:
#w:lanes
-> #m1:scale32
-> #m2:scale32
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:uint64xN w{felem_fits1 f2 m2} ->
Lemma (felem_wide_fits1 (vec_mul_mod f2 u1) (m1 * m2))
let smul_felem5_fits_lemma1 #w #m1 #m2 u1 f2 =
match w with
| 1 ->
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 0
| 2 ->
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 0;
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 1
| 4 ->
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 0;
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 1;
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 2;
smul_felem5_fits_lemma_i #w #m1 #m2 u1 f2 3
val smul_felem5_fits_lemma:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2} ->
Lemma (felem_wide_fits5 (smul_felem5 #w u1 f2) (m1 *^ m2))
let smul_felem5_fits_lemma #w #m1 #m2 u1 f2 =
let (f20, f21, f22, f23, f24) = f2 in
let (m20, m21, m22, m23, m24) = m2 in
smul_felem5_fits_lemma1 #w #m1 #m20 u1 f20;
smul_felem5_fits_lemma1 #w #m1 #m21 u1 f21;
smul_felem5_fits_lemma1 #w #m1 #m22 u1 f22;
smul_felem5_fits_lemma1 #w #m1 #m23 u1 f23;
smul_felem5_fits_lemma1 #w #m1 #m24 u1 f24
val smul_felem5_eval_lemma:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2} ->
Lemma (fas_nat5 (smul_felem5 #w u1 f2) ==
map2 #nat #nat #nat (fun a b -> a * b) (uint64xN_v u1) (fas_nat5 f2))
let smul_felem5_eval_lemma #w #m1 #m2 u1 f2 =
FStar.Classical.forall_intro (smul_felem5_eval_lemma_i #w #m1 #m2 u1 f2);
eq_intro (fas_nat5 (smul_felem5 #w u1 f2))
(map2 #nat #nat #nat (fun a b -> a * b) (uint64xN_v u1) (fas_nat5 f2))
val smul_add_felem5_fits_lemma_i:
#w:lanes
-> #m1:scale32
-> #m2:scale32
-> #m3:scale64{m3 + m1 * m2 <= 4096}
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:uint64xN w{felem_fits1 f2 m2}
-> acc1:uint64xN w{felem_wide_fits1 acc1 m3}
-> i:nat{i < w} ->
Lemma ((uint64xN_v (vec_add_mod acc1 (vec_mul_mod f2 u1))).[i] <= (m3 + m1 * m2) * max26 * max26)
#push-options "--z3rlimit 200"
let smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 i =
let o = vec_add_mod acc1 (vec_mul_mod f2 u1) in
smul_add_mod_lemma #m1 #m2 #m3 (uint64xN_v u1).[i] (uint64xN_v f2).[i] (uint64xN_v acc1).[i];
assert ((uint64xN_v o).[i] == (uint64xN_v acc1).[i] + (uint64xN_v u1).[i] * (uint64xN_v f2).[i]);
lemma_mult_le (uint64xN_v u1).[i] (m1 * max26) (uint64xN_v f2).[i] (m2 * max26);
assert ((uint64xN_v o).[i] <= m3 * max26 * max26 + m1 * m2 * max26 * max26)
#pop-options
val smul_add_felem5_eval_lemma_i:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> #m3:scale64_5{m3 +* m1 *^ m2 <=* s64x5 4096}
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2}
-> acc1:felem_wide5 w{felem_wide_fits5 acc1 m3}
-> i:nat{i < w} ->
Lemma ((fas_nat5 (smul_add_felem5 #w u1 f2 acc1)).[i] ==
(fas_nat5 acc1).[i] + (uint64xN_v u1).[i] * (fas_nat5 f2).[i])
let smul_add_felem5_eval_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 i =
let o = smul_add_felem5 #w u1 f2 acc1 in
let (m20, m21, m22, m23, m24) = m2 in
let (m30, m31, m32, m33, m34) = m3 in
let vu1 = (uint64xN_v u1).[i] in
let (tf20, tf21, tf22, tf23, tf24) = as_tup64_i f2 i in
let (ta0, ta1, ta2, ta3, ta4) = as_tup64_i acc1 i in
let (to0, to1, to2, to3, to4) = as_tup64_i o i in
smul_add_mod_lemma #m1 #m20 #m30 vu1 (v tf20) (v ta0);
smul_add_mod_lemma #m1 #m21 #m31 vu1 (v tf21) (v ta1);
smul_add_mod_lemma #m1 #m22 #m32 vu1 (v tf22) (v ta2);
smul_add_mod_lemma #m1 #m23 #m33 vu1 (v tf23) (v ta3);
smul_add_mod_lemma #m1 #m24 #m34 vu1 (v tf24) (v ta4);
calc (==) {
(fas_nat5 o).[i];
(==) { }
v ta0 + vu1 * v tf20 + (v ta1 + vu1 * v tf21) * pow26 + (v ta2 + vu1 * v tf22) * pow52 +
(v ta3 + vu1 * v tf23) * pow78 + (v ta4 + vu1 * v tf24) * pow104;
(==) {
FStar.Math.Lemmas.distributivity_add_left (v ta1) (vu1 * v tf21) pow26;
FStar.Math.Lemmas.distributivity_add_left (v ta2) (vu1 * v tf22) pow52;
FStar.Math.Lemmas.distributivity_add_left (v ta3) (vu1 * v tf23) pow78;
FStar.Math.Lemmas.distributivity_add_left (v ta1) (vu1 * v tf24) pow104 }
v ta0 + v ta1 * pow26 + v ta2 * pow52 + v ta3 * pow78 + v ta4 * pow104 +
vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 + vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104;
(==) { }
(fas_nat5 acc1).[i] + vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 + vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104;
};
assert ((fas_nat5 o).[i] == (fas_nat5 acc1).[i] +
vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 + vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104);
calc (==) {
vu1 * (fas_nat5 f2).[i];
(==) { }
vu1 * (v tf20 + v tf21 * pow26 + v tf22 * pow52 + v tf23 * pow78 + v tf24 * pow104);
(==) { lemma_mul5_distr_l vu1 (v tf20) (v tf21 * pow26) (v tf22 * pow52) (v tf23 * pow78) (v tf24 * pow104)}
vu1 * v tf20 + vu1 * (v tf21 * pow26) + vu1 * (v tf22 * pow52) + vu1 * (v tf23 * pow78) + vu1 * (v tf24 * pow104);
(==) {
FStar.Math.Lemmas.paren_mul_right vu1 (v tf21) pow26;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf22) pow52;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf23) pow78;
FStar.Math.Lemmas.paren_mul_right vu1 (v tf24) pow104}
vu1 * v tf20 + vu1 * v tf21 * pow26 + vu1 * v tf22 * pow52 + vu1 * v tf23 * pow78 + vu1 * v tf24 * pow104;
};
assert ((fas_nat5 o).[i] == (fas_nat5 acc1).[i] + vu1 * (fas_nat5 f2).[i])
val smul_add_felem5_fits_lemma1:
#w:lanes
-> #m1:scale32
-> #m2:scale32
-> #m3:scale64{m3 + m1 * m2 <= 4096}
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:uint64xN w{felem_fits1 f2 m2}
-> acc1:uint64xN w{felem_wide_fits1 acc1 m3} ->
Lemma (felem_wide_fits1 (vec_add_mod acc1 (vec_mul_mod f2 u1)) (m3 + m1 * m2))
let smul_add_felem5_fits_lemma1 #w #m1 #m2 #m3 u1 f2 acc1 =
match w with
| 1 ->
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 0
| 2 ->
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 0;
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 1
| 4 ->
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 0;
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 1;
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 2;
smul_add_felem5_fits_lemma_i #w #m1 #m2 #m3 u1 f2 acc1 3
val smul_add_felem5_fits_lemma:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> #m3:scale64_5{m3 +* m1 *^ m2 <=* s64x5 4096}
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2}
-> acc1:felem_wide5 w{felem_wide_fits5 acc1 m3} ->
Lemma (felem_wide_fits5 (smul_add_felem5 #w u1 f2 acc1) (m3 +* m1 *^ m2))
let smul_add_felem5_fits_lemma #w #m1 #m2 #m3 u1 f2 acc1 =
let (f20, f21, f22, f23, f24) = f2 in
let (m20, m21, m22, m23, m24) = m2 in
let (a0, a1, a2, a3, a4) = acc1 in
let (m30, m31, m32, m33, m34) = m3 in
smul_add_felem5_fits_lemma1 #w #m1 #m20 #m30 u1 f20 a0;
smul_add_felem5_fits_lemma1 #w #m1 #m21 #m31 u1 f21 a1;
smul_add_felem5_fits_lemma1 #w #m1 #m22 #m32 u1 f22 a2;
smul_add_felem5_fits_lemma1 #w #m1 #m23 #m33 u1 f23 a3;
smul_add_felem5_fits_lemma1 #w #m1 #m24 #m34 u1 f24 a4
val smul_add_felem5_eval_lemma:
#w:lanes
-> #m1:scale32
-> #m2:scale32_5
-> #m3:scale64_5{m3 +* m1 *^ m2 <=* s64x5 4096}
-> u1:uint64xN w{felem_fits1 u1 m1}
-> f2:felem5 w{felem_fits5 f2 m2}
-> acc1:felem_wide5 w{felem_wide_fits5 acc1 m3} ->
Lemma (fas_nat5 (smul_add_felem5 #w u1 f2 acc1) ==
map2 #nat #nat #nat (fun a b -> a + b) (fas_nat5 acc1)
(map2 #nat #nat #nat (fun a b -> a * b) (uint64xN_v u1) (fas_nat5 f2)))
let smul_add_felem5_eval_lemma #w #m1 #m2 #m3 u1 f2 acc1 =
let tmp =
map2 #nat #nat #nat (fun a b -> a + b) (fas_nat5 acc1)
(map2 #nat #nat #nat (fun a b -> a * b) (uint64xN_v u1) (fas_nat5 f2)) in
FStar.Classical.forall_intro (smul_add_felem5_eval_lemma_i #w #m1 #m2 #m3 u1 f2 acc1);
eq_intro (fas_nat5 (smul_add_felem5 #w u1 f2 acc1)) tmp
val lemma_fmul5_pow26: r:tup64_5 -> Lemma
(requires (let (r0, r1, r2, r3, r4) = r in v r4 * 5 <= 10 * pow26))
(ensures (let (r0, r1, r2, r3, r4) = r in
(pow26 * as_nat5 r) % prime == as_nat5 (r4 *! u64 5, r0, r1, r2, r3) % prime)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Spec.Poly1305.Vec.fst.checked",
"Hacl.Spec.Poly1305.Field32xN.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Poly1305.Field32xN.Lemmas0.fst"
} | [
{
"abbrev": false,
"full_module": "Hacl.Spec.Poly1305.Field32xN",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Poly1305.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Calc",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Poly1305.Field32xN",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Poly1305.Field32xN",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | r: Hacl.Spec.Poly1305.Field32xN.tup64_5
-> FStar.Pervasives.Lemma
(requires
(let _ = r in
(let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ _ _ _ _ r4 = _ in
Lib.IntTypes.v r4 * 5 <= 10 * Hacl.Spec.Poly1305.Field32xN.pow26)
<:
Type0))
(ensures
(let _ = r in
(let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ r0 r1 r2 r3 r4 = _ in
Hacl.Spec.Poly1305.Field32xN.pow26 * Hacl.Spec.Poly1305.Field32xN.as_nat5 r %
Hacl.Spec.Poly1305.Vec.prime ==
Hacl.Spec.Poly1305.Field32xN.as_nat5 (r4 *! Lib.IntTypes.u64 5, r0, r1, r2, r3) %
Hacl.Spec.Poly1305.Vec.prime)
<:
Type0)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Hacl.Spec.Poly1305.Field32xN.tup64_5",
"Lib.IntTypes.uint64",
"Prims._assert",
"Prims.eq2",
"Prims.int",
"Prims.op_Modulus",
"FStar.Mul.op_Star",
"Hacl.Spec.Poly1305.Field32xN.pow26",
"Hacl.Spec.Poly1305.Field32xN.as_nat5",
"Hacl.Spec.Poly1305.Vec.prime",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Hacl.Spec.Poly1305.Field32xN.pow52",
"Hacl.Spec.Poly1305.Field32xN.pow78",
"Hacl.Spec.Poly1305.Field32xN.pow104",
"Prims.unit",
"FStar.Calc.calc_finish",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"FStar.Calc.calc_step",
"Prims.pow2",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Prims.squash",
"Hacl.Poly1305.Field32xN.Lemmas0.lemma_mul5_distr_l",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Math.Lemmas.lemma_mod_plus_distr_r",
"FStar.Math.Lemmas.lemma_mod_mul_distr_r",
"Hacl.Poly1305.Field32xN.Lemmas0.lemma_prime"
] | [] | false | false | true | false | false | let lemma_fmul5_pow26 r =
| let r0, r1, r2, r3, r4 = r in
calc ( == ) {
(pow26 * as_nat5 r) % prime;
( == ) { () }
(pow26 * (v r0 + v r1 * pow26 + v r2 * pow52 + v r3 * pow78 + v r4 * pow104)) % prime;
( == ) { lemma_mul5_distr_l pow26
(v r0)
(v r1 * pow26)
(v r2 * pow52)
(v r3 * pow78)
(v r4 * pow104) }
(v r0 * pow26 + (pow26 * v r1) * pow26 + (pow26 * v r2) * pow52 + (pow26 * v r3) * pow78 +
(pow26 * v r4) * pow104) %
prime;
( == ) { () }
(v r0 * pow26 + (v r1 * pow26) * pow26 + (v r2 * pow26) * pow52 + (v r3 * pow26) * pow78 +
(v r4 * pow26) * pow104) %
prime;
( == ) { (assert_norm (pow26 * pow26 = pow52);
assert_norm (pow26 * pow52 = pow78);
assert_norm (pow26 * pow78 = pow104);
assert_norm (pow26 * pow104 = pow2 130)) }
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + v r4 * pow2 130) % prime;
( == ) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (v r0 * pow26 + v r1 * pow52 + v r2 * pow78 +
v r3 * pow104)
(v r4 * pow2 130)
prime }
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + (v r4 * pow2 130) % prime) % prime;
( == ) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (v r4) (pow2 130) prime }
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + (v r4 * (pow2 130 % prime)) % prime) %
prime;
( == ) { lemma_prime () }
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + (v r4 * 5) % prime) % prime;
( == ) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (v r0 * pow26 + v r1 * pow52 + v r2 * pow78 +
v r3 * pow104)
(v r4 * 5)
prime }
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + v r4 * 5) % prime;
};
assert ((pow26 * as_nat5 r) % prime ==
(v r0 * pow26 + v r1 * pow52 + v r2 * pow78 + v r3 * pow104 + v r4 * 5) % prime) | false |
MerkleTree.fsti | MerkleTree.mt_verify | val mt_verify
(#h: HS.mem)
(#hash_size: Ghost.erased hash_size_t)
(#hash_spec: MTS.hash_fun_t #(U32.v hash_size))
(mt: const_mt_p)
(tgt max: UInt64.t)
(mtr: HH.rid)
(path:
const_path_p
{ let phs = const_path_hash_size #h path in
phs = const_tree_hash_size #h mt /\ phs = Ghost.reveal hash_size })
(root: hash #(const_path_hash_size #h path))
: HST.ST bool pf pt | val mt_verify
(#h: HS.mem)
(#hash_size: Ghost.erased hash_size_t)
(#hash_spec: MTS.hash_fun_t #(U32.v hash_size))
(mt: const_mt_p)
(tgt max: UInt64.t)
(mtr: HH.rid)
(path:
const_path_p
{ let phs = const_path_hash_size #h path in
phs = const_tree_hash_size #h mt /\ phs = Ghost.reveal hash_size })
(root: hash #(const_path_hash_size #h path))
: HST.ST bool pf pt | let mt_verify
(#h:HS.mem)
(#hash_size:Ghost.erased hash_size_t)
(#hash_spec:MTS.hash_fun_t #(U32.v hash_size))
(mt:const_mt_p)
(tgt:UInt64.t)
(max:UInt64.t)
(mtr:HH.rid)
(path:const_path_p{let phs = const_path_hash_size #h path in phs = const_tree_hash_size #h mt /\ phs = Ghost.reveal hash_size})
(root:hash #(const_path_hash_size #h path))
: HST.ST bool pf pt
= let dmt = B.index (CB.cast mt) 0ul in
let hsz = MTNL.MT?.hash_size dmt in
MTNL.mt_verify #hsz #hash_spec mt tgt max mtr path root | {
"file_name": "src/MerkleTree.fsti",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | {
"end_col": 57,
"end_line": 266,
"start_col": 0,
"start_line": 253
} | module MerkleTree
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module MTS = MerkleTree.Spec
module MTNL = MerkleTree.Low
module MTNLHF = MerkleTree.Low.Hashfunctions
module MTNLE = MerkleTree.EverCrypt
module MTNLD = MerkleTree.Low.Datastructures
module MTNLS = MerkleTree.Low.Serialization
let hash_size_t = MTNLD.hash_size_t
let offset_t = MTNL.offset_t
let index_t = MTNL.index_t
let hash #hash_size = MTNLD.hash #hash_size
type path = MTNL.path
type path_p = B.pointer path
type const_path_p = MTNL.const_pointer path
let merkle_tree = MTNL.merkle_tree
let mt_p = MTNL.mt_p
let const_mt_p = MTNL.const_mt_p
inline_for_extraction noextract
let pf = fun _ -> False
inline_for_extraction noextract
let pt = fun _ _ _ -> True
[@ (Comment " Constructor for hashes") "c_inline"]
let mt_init_hash (hash_size:hash_size_t) (r:HST.erid): HST.ST (hash #hash_size) pf pt = MTNLHF.init_hash hash_size r
[@ (Comment " Destructor for hashes") "c_inline"]
let mt_free_hash (#hash_size:Ghost.erased hash_size_t) (h:hash #hash_size): HST.ST unit pf pt = MTNLHF.free_hash h
[@ (Comment " Constructor for paths") "c_inline"]
let mt_init_path (hash_size:hash_size_t) (mtr:HH.rid) (r:HST.erid): HST.ST path_p pf pt = MTNL.init_path hash_size mtr r
[@ (Comment " Destructor for paths") "c_inline"]
let mt_free_path (path:path_p): HST.ST unit pf pt = MTNL.free_path path
[@ (Comment " Length of a path
@param[in] p Path
return The length of the path") "c_inline"]
let mt_get_path_length (mtr:HH.rid) (path:const_path_p): HST.ST U32.t pf pt = MTNL.mt_get_path_length mtr path
[@ (Comment " Insert hash into path
@param[in] p Path
@param[in] hash Hash to insert") "c_inline"]
let mt_path_insert
(#h:HS.mem)
(#mtr:HH.rid)
(path:path_p)
(hash:hash #(MTNL.Path?.hash_size (B.get h path 0)))
: HST.ST unit pf pt
= let hash_size = MTNL.Path?.hash_size (B.index path 0ul) in
MTNL.mt_path_insert #hash_size mtr path hash
inline_for_extraction
let path_hash_size (#h:HS.mem) (path:path_p) = MTNL.Path?.hash_size (B.get h path 0)
inline_for_extraction
let const_path_hash_size (#h:HS.mem) (path:const_path_p) = path_hash_size #h (CB.cast path)
inline_for_extraction
let tree_hash_size (#h:HS.mem) (mt:mt_p) = MTNL.MT?.hash_size (B.get h mt 0)
inline_for_extraction
let const_tree_hash_size (#h:HS.mem) (mt:const_mt_p) = tree_hash_size #h (CB.cast mt)
[@ (Comment " Get step on a path
@param[in] p Path
@param[in] i Path step index
return The hash at step i of p") "c_inline"]
let mt_get_path_step
(#h:HS.mem)
(#mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST (hash #(const_path_hash_size #h path)) pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step #hash_size mtr path i
[@ (Comment " Precondition predicate for mt_get_path_step") "c_inline"]
let mt_get_path_step_pre
(#h:HS.mem)
(mtr:HH.rid)
(path:const_path_p)
(i:U32.t)
: HST.ST bool pf pt
= let hash_size = MTNL.Path?.hash_size (B.index (CB.cast path) 0ul) in
MTNL.mt_get_path_step_pre #hash_size mtr path i
[@ (Comment " Construction with custom hash functions
@param[in] hash_size Hash size (in bytes)
@param[in] i The initial hash
return The new Merkle tree") "c_inline"]
let mt_create_custom
(hash_size:hash_size_t)
(hash_spec:Ghost.erased (MTS.hash_fun_t #(U32.v hash_size)))
(r:HST.erid)
(i:hash #hash_size)
(hash_fun:MTNLHF.hash_fun_t #hash_size #hash_spec)
: HST.ST mt_p pf pt
= MTNL.mt_create_custom hash_size hash_spec r i hash_fun
[@ (Comment " Destruction
@param[in] mt The Merkle tree") "c_inline"]
let mt_free (mt:mt_p): HST.ST unit pf pt = MTNL.mt_free mt
[@ (Comment " Insertion
@param[in] mt The Merkle tree
@param[in] v The tree does not take ownership of the hash, it makes a copy of its content.
Note: The content of the hash will be overwritten with an arbitrary value.") "c_inline"]
let mt_insert
(#h:HS.mem)
(mt:mt_p)
(v:hash #(tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index mt 0ul) in
MTNL.mt_insert hash_size mt v
[@ (Comment " Precondition predicate for mt_insert") "c_inline"]
let mt_insert_pre
(#h:HS.mem)
(mt:const_mt_p)
(v:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_insert_pre #hash_size mt v
[@ (Comment " Getting the Merkle root
@param[in] mt The Merkle tree
@param[out] root The Merkle root") "c_inline"]
let mt_get_root
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST unit pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root #hash_size mt root
[@ (Comment " Precondition predicate for mt_get_root") "c_inline"]
let mt_get_root_pre
(#h:HS.mem)
(mt:const_mt_p)
(root:hash #(const_tree_hash_size #h mt))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_root_pre #hash_size mt root
[@ (Comment " Getting a Merkle path
@param[in] mt The Merkle tree
@param[in] idx The index of the target hash
@param[out] path A resulting Merkle path that contains the leaf hash.
@param[out] root The Merkle root
return The number of elements in the tree
Notes:
- The resulting path contains pointers to hashes in the tree, not copies of
the hash values.
- idx must be within the currently held indices in the tree (past the
last flush index).") "c_inline"]
let mt_get_path
(#h:HS.mem)
(mt:const_mt_p)
(idx:offset_t)
(path:path_p{path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(path_hash_size #h path))
: HST.ST index_t pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_path #hash_size mt idx path root
[@ (Comment " Precondition predicate for mt_get_path") "c_inline"]
let mt_get_path_pre
(#h:HS.mem)
(mt:const_mt_p)
(idx:offset_t)
(path:const_path_p{const_path_hash_size #h path = const_tree_hash_size #h mt})
(root:hash #(const_path_hash_size #h path))
: HST.ST bool pf pt
= let hash_size = MTNL.MT?.hash_size (B.index (CB.cast mt) 0ul) in
MTNL.mt_get_path_pre #hash_size mt idx path root
[@ (Comment " Flush the Merkle tree
@param[in] mt The Merkle tree") "c_inline"]
let mt_flush (mt:mt_p): HST.ST unit pf pt = MTNL.mt_flush mt
[@ (Comment " Precondition predicate for mt_flush") "c_inline"]
let mt_flush_pre (mt:const_mt_p): HST.ST bool pf pt = MTNL.mt_flush_pre mt
[@ (Comment " Flush the Merkle tree up to a given index
@param[in] mt The Merkle tree
@param[in] idx The index up to which to flush the tree") "c_inline"]
let mt_flush_to (mt:mt_p) (idx:offset_t): HST.ST unit pf pt = MTNL.mt_flush_to mt idx
[@ (Comment " Precondition predicate for mt_flush_to")]
let mt_flush_to_pre (mt:const_mt_p) (idx:offset_t): HST.ST bool pf pt = MTNL.mt_flush_to_pre mt idx
[@ (Comment " Retract the Merkle tree down to a given index
@param[in] mt The Merkle tree
@param[in] idx The index to retract the tree to
Note: The element and idx will remain in the tree.") "c_inline"]
let mt_retract_to (mt:mt_p) (idx:offset_t): HST.ST unit pf pt = MTNL.mt_retract_to mt idx
[@ (Comment " Precondition predicate for mt_retract_to") "c_inline"]
let mt_retract_to_pre (mt:const_mt_p) (idx:offset_t): HST.ST bool pf pt = MTNL.mt_retract_to_pre mt idx
[@ (Comment " Client-side verification
@param[in] mt The Merkle tree
@param[in] tgt The index of the target hash
@param[in] max The maximum index + 1 of the tree when the path was generated
@param[in] path The Merkle path to verify
@param[in] root
return true if the verification succeeded, false otherwise | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.Low.Serialization.fst.checked",
"MerkleTree.Low.Hashfunctions.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"MerkleTree.Low.fst.checked",
"MerkleTree.EverCrypt.fsti.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.fsti"
} | [
{
"abbrev": true,
"full_module": "MerkleTree.Low.Serialization",
"short_module": "MTNLS"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": "MTNLD"
},
{
"abbrev": true,
"full_module": "MerkleTree.EverCrypt",
"short_module": "MTNLE"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low.Hashfunctions",
"short_module": "MTNLHF"
},
{
"abbrev": true,
"full_module": "MerkleTree.Low",
"short_module": "MTNL"
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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.const_mt_p ->
tgt: FStar.UInt64.t ->
max: FStar.UInt64.t ->
mtr: FStar.Monotonic.HyperHeap.rid ->
path:
MerkleTree.const_path_p
{ let phs = MerkleTree.const_path_hash_size path in
phs = MerkleTree.const_tree_hash_size mt /\ phs = FStar.Ghost.reveal hash_size } ->
root: MerkleTree.hash
-> FStar.HyperStack.ST.ST Prims.bool | FStar.HyperStack.ST.ST | [] | [] | [
"FStar.Monotonic.HyperStack.mem",
"FStar.Ghost.erased",
"MerkleTree.hash_size_t",
"MerkleTree.Spec.hash_fun_t",
"FStar.UInt32.v",
"FStar.Ghost.reveal",
"MerkleTree.const_mt_p",
"FStar.UInt64.t",
"FStar.Monotonic.HyperHeap.rid",
"MerkleTree.const_path_p",
"Prims.l_and",
"Prims.b2t",
"Prims.op_Equality",
"MerkleTree.Low.Datastructures.hash_size_t",
"MerkleTree.const_tree_hash_size",
"MerkleTree.const_path_hash_size",
"MerkleTree.hash",
"MerkleTree.Low.mt_verify",
"FStar.Ghost.hide",
"Prims.bool",
"MerkleTree.Low.__proj__MT__item__hash_size",
"MerkleTree.Low.merkle_tree",
"LowStar.Monotonic.Buffer.index",
"LowStar.ConstBuffer.qbuf_pre",
"LowStar.ConstBuffer.as_qbuf",
"LowStar.ConstBuffer.cast",
"FStar.UInt32.__uint_to_t",
"MerkleTree.pf",
"MerkleTree.pt"
] | [] | false | true | false | false | false | let mt_verify
(#h: HS.mem)
(#hash_size: Ghost.erased hash_size_t)
(#hash_spec: MTS.hash_fun_t #(U32.v hash_size))
(mt: const_mt_p)
(tgt max: UInt64.t)
(mtr: HH.rid)
(path:
const_path_p
{ let phs = const_path_hash_size #h path in
phs = const_tree_hash_size #h mt /\ phs = Ghost.reveal hash_size })
(root: hash #(const_path_hash_size #h path))
: HST.ST bool pf pt =
| let dmt = B.index (CB.cast mt) 0ul in
let hsz = MTNL.MT?.hash_size dmt in
MTNL.mt_verify #hsz #hash_spec mt tgt max mtr path root | false |
Spec.Agile.HPKE.fst | Spec.Agile.HPKE.openBase | val openBase:
cs:ciphersuite_not_export_only
-> enc:key_dh_public_s cs
-> skR:key_dh_secret_s cs
-> info:info_s cs
-> aad:AEAD.ad (aead_alg_of cs)
-> ct:AEAD.cipher (aead_alg_of cs) ->
Tot (option (AEAD.decrypted #(aead_alg_of cs) ct)) | val openBase:
cs:ciphersuite_not_export_only
-> enc:key_dh_public_s cs
-> skR:key_dh_secret_s cs
-> info:info_s cs
-> aad:AEAD.ad (aead_alg_of cs)
-> ct:AEAD.cipher (aead_alg_of cs) ->
Tot (option (AEAD.decrypted #(aead_alg_of cs) ct)) | let openBase cs enc skR info aad ct =
match setupBaseR cs enc skR info with
| None -> None
| Some ctx ->
match context_open cs ctx aad ct with
| None -> None
| Some (_, pt) -> Some pt | {
"file_name": "specs/Spec.Agile.HPKE.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 29,
"end_line": 476,
"start_col": 0,
"start_line": 470
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
let pow2_61 : _:unit{pow2 61 == 2305843009213693952} = assert_norm(pow2 61 == 2305843009213693952)
let pow2_35_less_than_pow2_61 : _:unit{pow2 32 * pow2 3 <= pow2 61 - 1} = assert_norm(pow2 32 * pow2 3 <= pow2 61 - 1)
let pow2_35_less_than_pow2_125 : _:unit{pow2 32 * pow2 3 <= pow2 125 - 1} = assert_norm(pow2 32 * pow2 3 <= pow2 125 - 1)
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
/// Types
val id_kem: cs:ciphersuite -> Tot (lbytes 2)
let id_kem cs = let kem_dh, kem_hash, _, _ = cs in
match kem_dh, kem_hash with
| DH.DH_P256, Hash.SHA2_256 -> create 1 (u8 0) @| create 1 (u8 16)
| DH.DH_Curve25519, Hash.SHA2_256 -> create 1 (u8 0) @| create 1 (u8 32)
val id_kdf: cs:ciphersuite -> Tot (lbytes 2)
let id_kdf cs = let _, _, _, h = cs in
match h with
| Hash.SHA2_256 -> create 1 (u8 0) @| create 1 (u8 1)
| Hash.SHA2_384 -> create 1 (u8 0) @| create 1 (u8 2)
| Hash.SHA2_512 -> create 1 (u8 0) @| create 1 (u8 3)
val id_aead: cs:ciphersuite -> Tot (lbytes 2)
let id_aead cs = let _, _, a, _ = cs in
match a with
| Seal AEAD.AES128_GCM -> create 1 (u8 0) @| create 1 (u8 1)
| Seal AEAD.AES256_GCM -> create 1 (u8 0) @| create 1 (u8 2)
| Seal AEAD.CHACHA20_POLY1305 -> create 1 (u8 0) @| create 1 (u8 3)
| ExportOnly -> create 1 (u8 255) @| create 1 (u8 255)
val suite_id_kem: cs:ciphersuite -> Tot (lbytes size_suite_id_kem)
let suite_id_kem cs =
Seq.append label_KEM (id_kem cs)
val suite_id_hpke: cs:ciphersuite -> Tot (lbytes size_suite_id_hpke)
let suite_id_hpke cs =
Seq.append label_HPKE (id_kem cs @| id_kdf cs @| id_aead cs)
val id_of_mode: m:mode -> Tot (lbytes size_mode_identifier)
let id_of_mode m =
match m with
| Base -> create 1 (u8 0)
| PSK -> create 1 (u8 1)
| Auth -> create 1 (u8 2)
| AuthPSK -> create 1 (u8 3)
val labeled_extract:
a:hash_algorithm
-> suite_id:bytes
-> salt:bytes
-> label:bytes
-> ikm:bytes ->
Pure (lbytes (Spec.Hash.Definitions.hash_length a))
(requires
Spec.Agile.HMAC.keysized a (Seq.length salt) /\
labeled_extract_ikm_length_pred a (Seq.length suite_id + Seq.length label + Seq.length ikm))
(ensures fun _ -> True)
let labeled_extract a suite_id salt label ikm =
let labeled_ikm1 = Seq.append label_version suite_id in
let labeled_ikm2 = Seq.append labeled_ikm1 label in
let labeled_ikm3 = Seq.append labeled_ikm2 ikm in
HKDF.extract a salt labeled_ikm3
val labeled_expand:
a:hash_algorithm
-> suite_id:bytes
-> prk:bytes
-> label:bytes
-> info:bytes
-> l:size_nat ->
Pure (lbytes l)
(requires
Spec.Hash.Definitions.hash_length a <= Seq.length prk /\
Spec.Agile.HMAC.keysized a (Seq.length prk) /\
labeled_expand_info_length_pred a (Seq.length suite_id + Seq.length label + Seq.length info) /\
HKDF.expand_output_length_pred a l)
(ensures fun _ -> True)
let labeled_expand a suite_id prk label info l =
let labeled_info1 = nat_to_bytes_be 2 l in
let labeled_info2 = Seq.append labeled_info1 label_version in
let labeled_info3 = Seq.append labeled_info2 suite_id in
let labeled_info4 = Seq.append labeled_info3 label in
let labeled_info5 = Seq.append labeled_info4 info in
HKDF.expand a prk labeled_info5 l
let extract_and_expand_dh_pred (cs:ciphersuite) (dh_length:nat) =
labeled_extract_ikm_length_pred (kem_hash_of_cs cs) (size_suite_id_kem + size_label_eae_prk + dh_length)
let extract_and_expand_ctx_pred (cs:ciphersuite) (ctx_length:nat) =
labeled_expand_info_length_pred (kem_hash_of_cs cs) (size_suite_id_kem + size_label_shared_secret + ctx_length)
val extract_and_expand:
cs:ciphersuite
-> dh:bytes
-> kem_context:bytes ->
Pure (key_kem_s cs)
(requires
extract_and_expand_dh_pred cs (Seq.length dh) /\
extract_and_expand_ctx_pred cs (Seq.length kem_context))
(ensures fun _ -> True)
let extract_and_expand cs dh kem_context =
let eae_prk = labeled_extract (kem_hash_of_cs cs) (suite_id_kem cs) lbytes_empty label_eae_prk dh in
labeled_expand (kem_hash_of_cs cs) (suite_id_kem cs) eae_prk label_shared_secret kem_context (size_kem_key cs)
let deserialize_public_key cs pk = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> pk
// Extract the point coordinates by removing the first representation byte
| DH.DH_P256 -> sub pk 1 64
let serialize_public_key cs pk = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> pk
// Add the first representation byte to the point coordinates
| DH.DH_P256 -> create 1 (u8 4) @| pk
val dkp_nist_p: cs:ciphersuite -> lbytes (size_kem_kdf cs) -> counter:uint8 -> Tot (option (key_dh_secret_s cs & key_dh_public_s cs)) (decreases 255 - v counter)
let rec dkp_nist_p cs dkp_prk counter =
let counterbyte = nat_to_intseq_be #U8 #SEC 1 (v counter) in
let bytes = labeled_expand (kem_hash_of_cs cs) (suite_id_kem cs) dkp_prk label_candidate counterbyte (size_dh_key cs) in
let bytes = Lib.Sequence.map2 (logand #U8 #SEC) bytes (Seq.create (size_dh_key cs) (u8 255)) in
let sk = nat_from_intseq_be #U8 #SEC bytes in
if sk = 0 || sk >= Spec.P256.prime then
if (v counter) = 255 then None
else dkp_nist_p cs dkp_prk (counter +! (u8 1))
else
match DH.secret_to_public (kem_dh_of_cs cs) bytes with
| Some pk -> Some (bytes, serialize_public_key cs pk)
| None ->
if (v counter) = 255 then None
else dkp_nist_p cs dkp_prk (counter +! (u8 1))
let derive_key_pair cs ikm =
match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> begin
let dkp_prk = labeled_extract (kem_hash_of_cs cs) (suite_id_kem cs) lbytes_empty label_dkp_prk ikm in
let sk = labeled_expand (kem_hash_of_cs cs) (suite_id_kem cs) dkp_prk label_sk lbytes_empty (size_dh_key cs) in
match DH.secret_to_public (kem_dh_of_cs cs) sk with
| Some pk -> Some (sk, serialize_public_key cs pk)
end
| DH.DH_P256 ->
let dkp_prk = labeled_extract (kem_hash_of_cs cs) (suite_id_kem cs) lbytes_empty label_dkp_prk ikm in
dkp_nist_p cs dkp_prk (u8 0)
val prepare_dh: cs:ciphersuite -> DH.serialized_point (kem_dh_of_cs cs) -> Tot (lbytes 32)
let prepare_dh cs dh = match (kem_dh_of_cs cs) with
| DH.DH_Curve25519 -> serialize_public_key cs dh
| DH.DH_P256 -> sub dh 0 32
val encap:
cs:ciphersuite
-> skE:key_dh_secret_s cs
-> pkR:DH.serialized_point (kem_dh_of_cs cs) ->
Tot (option (key_kem_s cs & key_dh_public_s cs))
#restart-solver
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
let encap cs skE pkR =
let _ = allow_inversion Spec.Agile.DH.algorithm in
match DH.secret_to_public (kem_dh_of_cs cs) skE with
| None -> None
| Some pkE ->
let enc = serialize_public_key cs pkE in
match DH.dh (kem_dh_of_cs cs) skE pkR with
| None -> None
| Some dh ->
let pkRm = serialize_public_key cs pkR in
let kem_context = concat enc pkRm in
let dhm = prepare_dh cs dh in
assert (Seq.length kem_context = 2*size_dh_public cs);
assert (extract_and_expand_ctx_pred cs (Seq.length kem_context));
let shared_secret:key_kem_s cs = extract_and_expand cs dhm kem_context in
Some (shared_secret, enc)
val decap:
cs: ciphersuite
-> enc: key_dh_public_s cs
-> skR: key_dh_secret_s cs ->
Tot (option (key_kem_s cs))
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
let decap cs enc skR =
let _ = allow_inversion Spec.Agile.DH.algorithm in
let _ = allow_inversion Spec.Agile.Hash.hash_alg in
let pkE = deserialize_public_key cs enc in
match DH.dh (kem_dh_of_cs cs) skR pkE with
| None -> None
| Some dh ->
match DH.secret_to_public (kem_dh_of_cs cs) skR with
| None -> None
| Some pkR ->
let pkRm = serialize_public_key cs pkR in
let kem_context = concat enc pkRm in
let dhm = prepare_dh cs dh in
assert (Seq.length kem_context = 2*size_dh_public cs);
assert (extract_and_expand_ctx_pred cs (Seq.length kem_context));
let shared_secret = extract_and_expand cs dhm kem_context in
Some (shared_secret)
val auth_encap:
cs:ciphersuite
-> skE:key_dh_secret_s cs
-> pkR:DH.serialized_point (kem_dh_of_cs cs)
-> skS:key_dh_secret_s cs ->
Tot (option (key_kem_s cs & key_dh_public_s cs))
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
let auth_encap cs skE pkR skS =
let _ = allow_inversion Spec.Agile.DH.algorithm in
match DH.secret_to_public (kem_dh_of_cs cs) skE with
| None -> None
| Some pkE ->
match DH.dh (kem_dh_of_cs cs) skE pkR with
| None -> None
| Some es ->
match DH.dh (kem_dh_of_cs cs) skS pkR with
| None -> None
| Some ss ->
let esm = prepare_dh cs es in
let ssm = prepare_dh cs ss in
// TODO Do not put 32 literally
let dh = concat #uint8 #32 #32 esm ssm in
let enc = serialize_public_key cs pkE in
match DH.secret_to_public (kem_dh_of_cs cs) skS with
| None -> None
| Some pkS ->
let pkSm = serialize_public_key cs pkS in
let pkRm = serialize_public_key cs pkR in
let kem_context = concat enc (concat pkRm pkSm) in
assert (Seq.length kem_context = 3*size_dh_public cs);
assert (labeled_expand_info_length_pred (kem_hash_of_cs cs) (size_suite_id_kem + size_label_shared_secret + Seq.length kem_context));
assert (extract_and_expand_ctx_pred cs (Seq.length kem_context));
// TODO Do not put 64 literally
assert (Seq.length dh = 64);
assert (labeled_extract_ikm_length_pred (kem_hash_of_cs cs) (size_suite_id_kem + size_label_eae_prk + Seq.length dh));
assert (extract_and_expand_dh_pred cs (Seq.length dh));
let shared_secret = extract_and_expand cs dh kem_context in
Some (shared_secret, enc)
#reset-options
val auth_decap:
cs: ciphersuite
-> enc: key_dh_public_s cs
-> skR: key_dh_secret_s cs
-> pkS: DH.serialized_point (kem_dh_of_cs cs) ->
Tot (option (key_kem_s cs))
#restart-solver
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
let auth_decap cs enc skR pkS =
let _ = allow_inversion Spec.Agile.DH.algorithm in
let pkE = deserialize_public_key cs enc in
match DH.dh (kem_dh_of_cs cs) skR pkE with
| None -> None
| Some es ->
match DH.dh (kem_dh_of_cs cs) skR pkS with
| None -> None
| Some ss ->
let esm = prepare_dh cs es in
let ssm = prepare_dh cs ss in
let dh = concat #uint8 #32 #32 esm ssm in
match DH.secret_to_public (kem_dh_of_cs cs) skR with
| None -> None
| Some pkR ->
let pkRm = serialize_public_key cs pkR in
let pkSm = serialize_public_key cs pkS in
let kem_context = concat enc (concat pkRm pkSm) in
assert (Seq.length kem_context = 3*size_dh_public cs);
assert (labeled_expand_info_length_pred (kem_hash_of_cs cs) (size_suite_id_kem + size_label_shared_secret + Seq.length kem_context));
assert (extract_and_expand_ctx_pred cs (Seq.length kem_context));
assert (Seq.length dh = 64);
assert (labeled_extract_ikm_length_pred (kem_hash_of_cs cs) (size_suite_id_kem + size_label_eae_prk + Seq.length dh));
assert (extract_and_expand_dh_pred cs (Seq.length dh));
let shared_secret = extract_and_expand cs dh kem_context in
Some (shared_secret)
#reset-options
let default_psk = lbytes_empty
let default_psk_id = lbytes_empty
val build_context:
cs:ciphersuite
-> m:mode
-> psk_id_hash:lbytes (size_kdf cs)
-> info_hash:lbytes (size_kdf cs) ->
Tot (lbytes (size_ks_ctx cs))
let build_context cs m psk_id_hash info_hash =
let context = id_of_mode m in
let context = Seq.append context psk_id_hash in
let context = Seq.append context info_hash in
context
let verify_psk_inputs (cs:ciphersuite) (m:mode) (opsk:option(psk_s cs & psk_id_s cs)) : bool =
match (m, opsk) with
| Base, None -> true
| PSK, Some _ -> true
| Auth, None -> true
| AuthPSK, Some _ -> true
| _, _ -> false
// key and nonce are zero-length if AEAD is Export-Only
let encryption_context (cs:ciphersuite) = key_aead_s cs & nonce_aead_s cs & seq_aead_s cs & exporter_secret_s cs
val key_schedule:
cs:ciphersuite
-> m:mode
-> shared_secret:key_kem_s cs
-> info:info_s cs
-> opsk:option (psk_s cs & psk_id_s cs) ->
Pure (encryption_context cs)
(requires verify_psk_inputs cs m opsk)
(ensures fun _ -> True)
#set-options "--z3rlimit 500 --fuel 0 --ifuel 2"
let key_schedule_core
(cs:ciphersuite)
(m:mode)
(shared_secret:key_kem_s cs)
(info:info_s cs)
(opsk:option (psk_s cs & psk_id_s cs))
: (lbytes (size_ks_ctx cs) & exporter_secret_s cs & (lbytes (Spec.Hash.Definitions.hash_length (hash_of_cs cs)))) =
let (psk, psk_id) =
match opsk with
| None -> (default_psk, default_psk_id)
| Some (psk, psk_id) -> (psk, psk_id)
in
let psk_id_hash = labeled_extract (hash_of_cs cs) (suite_id_hpke cs) lbytes_empty label_psk_id_hash psk_id in
let info_hash = labeled_extract (hash_of_cs cs) (suite_id_hpke cs) lbytes_empty label_info_hash info in
let context = build_context cs m psk_id_hash info_hash in
let secret = labeled_extract (hash_of_cs cs) (suite_id_hpke cs) shared_secret label_secret psk in
let exporter_secret = labeled_expand (hash_of_cs cs) (suite_id_hpke cs) secret label_exp context (size_kdf cs) in
context, exporter_secret, secret
let key_schedule_end
(cs:ciphersuite)
(m:mode)
(context:lbytes (size_ks_ctx cs))
(exporter_secret:exporter_secret_s cs)
(secret:(lbytes (Spec.Hash.Definitions.hash_length (hash_of_cs cs))))
: encryption_context cs
=
if is_valid_not_export_only_ciphersuite cs then (
let key = labeled_expand (hash_of_cs cs) (suite_id_hpke cs) secret label_key context (size_aead_key cs) in
let base_nonce = labeled_expand (hash_of_cs cs) (suite_id_hpke cs) secret label_base_nonce context (size_aead_nonce cs) in
(key, base_nonce, 0, exporter_secret)
) else (
(* if AEAD is Export-Only, then skip computation of key and base_nonce *)
assert (size_aead_key cs = 0);
assert (size_aead_nonce cs = 0);
(lbytes_empty, lbytes_empty, 0, exporter_secret))
let key_schedule cs m shared_secret info opsk =
let context, exporter_secret, secret = key_schedule_core cs m shared_secret info opsk in
key_schedule_end cs m context exporter_secret secret
let key_of_ctx (cs:ciphersuite) (ctx:encryption_context cs) =
let key, _, _, _ = ctx in key
let base_nonce_of_ctx (cs:ciphersuite) (ctx:encryption_context cs) =
let _, base_nonce, _, _ = ctx in base_nonce
let seq_of_ctx (cs:ciphersuite) (ctx:encryption_context cs) =
let _, _, seq, _ = ctx in seq
let exp_sec_of_ctx (cs:ciphersuite) (ctx:encryption_context cs) =
let _, _, _, exp_sec = ctx in exp_sec
let set_seq (cs:ciphersuite) (ctx:encryption_context cs) (seq:seq_aead_s cs) =
let key, base_nonce, _, exp_sec = ctx in
(key, base_nonce, seq, exp_sec)
///
/// Encryption Context
///
let context_export cs ctx exp_ctx l =
let exp_sec = exp_sec_of_ctx cs ctx in
labeled_expand (hash_of_cs cs) (suite_id_hpke cs) exp_sec label_sec exp_ctx l
let context_compute_nonce cs ctx seq =
let base_nonce = base_nonce_of_ctx cs ctx in
let enc_seq = nat_to_bytes_be (size_aead_nonce cs) seq in
Spec.Loops.seq_map2 logxor enc_seq base_nonce
let context_increment_seq cs ctx =
let seq = seq_of_ctx cs ctx in
if seq = max_seq cs then None else
Some (set_seq cs ctx (seq + 1))
let context_seal cs ctx aad pt =
let key = key_of_ctx cs ctx in
let seq = seq_of_ctx cs ctx in
let nonce = context_compute_nonce cs ctx seq in
let ct = AEAD.encrypt key nonce aad pt in
match context_increment_seq cs ctx with
| None -> None
| Some new_ctx -> Some (new_ctx, ct)
let context_open cs ctx aad ct =
let key = key_of_ctx cs ctx in
let seq = seq_of_ctx cs ctx in
let nonce = context_compute_nonce cs ctx seq in
match AEAD.decrypt key nonce aad ct with
| None -> None
| Some pt ->
match context_increment_seq cs ctx with
| None -> None
| Some new_ctx -> Some (new_ctx, pt)
///
/// Base Mode
///
let setupBaseS cs skE pkR info =
match encap cs skE pkR with
| None -> None
| Some (shared_secret, enc) ->
let enc_ctx = key_schedule cs Base shared_secret info None in
Some (enc, enc_ctx)
let setupBaseR cs enc skR info =
let pkR = DH.secret_to_public (kem_dh_of_cs cs) skR in
let shared_secret = decap cs enc skR in
match pkR, shared_secret with
| Some pkR, Some shared_secret ->
Some (key_schedule cs Base shared_secret info None)
| _ -> None
let sealBase cs skE pkR info aad pt =
match setupBaseS cs skE pkR info with
| None -> None
| Some (enc, ctx) ->
match context_seal cs ctx aad pt with
| None -> None
| Some (_, ct) -> Some (enc, ct) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HMAC.fsti.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Spec.Agile.HPKE.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 500,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
cs: Spec.Agile.HPKE.ciphersuite_not_export_only ->
enc: Spec.Agile.HPKE.key_dh_public_s cs ->
skR: Spec.Agile.HPKE.key_dh_secret_s cs ->
info: Spec.Agile.HPKE.info_s cs ->
aad: Spec.Agile.AEAD.ad (Spec.Agile.HPKE.aead_alg_of cs) ->
ct: Spec.Agile.AEAD.cipher (Spec.Agile.HPKE.aead_alg_of cs)
-> FStar.Pervasives.Native.option (Spec.Agile.AEAD.decrypted ct) | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.ciphersuite_not_export_only",
"Spec.Agile.HPKE.key_dh_public_s",
"Spec.Agile.HPKE.key_dh_secret_s",
"Spec.Agile.HPKE.info_s",
"Spec.Agile.AEAD.ad",
"Spec.Agile.HPKE.aead_alg_of",
"Spec.Agile.AEAD.cipher",
"Spec.Agile.HPKE.setupBaseR",
"FStar.Pervasives.Native.None",
"Spec.Agile.AEAD.decrypted",
"Spec.Agile.HPKE.encryption_context",
"Spec.Agile.HPKE.context_open",
"Spec.Agile.AEAD.plain",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | false | false | let openBase cs enc skR info aad ct =
| match setupBaseR cs enc skR info with
| None -> None
| Some ctx ->
match context_open cs ctx aad ct with
| None -> None
| Some (_, pt) -> Some pt | false |
FStar.Tactics.CanonCommSwaps.fst | FStar.Tactics.CanonCommSwaps.apply_swap_aux | val apply_swap_aux (#a: Type) (n: nat) (xs: list a) (s: swap (length xs + n))
: Pure (list a) (requires True) (ensures (fun zs -> length zs == length xs)) (decreases xs) | val apply_swap_aux (#a: Type) (n: nat) (xs: list a) (s: swap (length xs + n))
: Pure (list a) (requires True) (ensures (fun zs -> length zs == length xs)) (decreases xs) | let rec apply_swap_aux (#a:Type) (n:nat) (xs:list a) (s:swap (length xs + n)) :
Pure (list a) (requires True)
(ensures (fun zs -> length zs == length xs)) (decreases xs) =
match xs with
| [] | [_] -> xs
| x1 :: x2 :: xs' -> if n = (s <: nat)
then x2 :: x1 :: xs'
else x1 :: apply_swap_aux (n+1) (x2 :: xs') s | {
"file_name": "ulib/FStar.Tactics.CanonCommSwaps.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 68,
"end_line": 29,
"start_col": 0,
"start_line": 22
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.CanonCommSwaps
open FStar.List.Tot
let swap (n:nat) :Type = x:nat{x < n-1} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Tactics.CanonCommSwaps.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
n: Prims.nat ->
xs: Prims.list a ->
s: FStar.Tactics.CanonCommSwaps.swap (FStar.List.Tot.Base.length xs + n)
-> Prims.Pure (Prims.list a) | Prims.Pure | [
""
] | [] | [
"Prims.nat",
"Prims.list",
"FStar.Tactics.CanonCommSwaps.swap",
"Prims.op_Addition",
"FStar.List.Tot.Base.length",
"Prims.op_Equality",
"Prims.Cons",
"Prims.bool",
"FStar.Tactics.CanonCommSwaps.apply_swap_aux",
"Prims.l_True",
"Prims.eq2"
] | [
"recursion"
] | false | false | false | false | false | let rec apply_swap_aux (#a: Type) (n: nat) (xs: list a) (s: swap (length xs + n))
: Pure (list a) (requires True) (ensures (fun zs -> length zs == length xs)) (decreases xs) =
| match xs with
| [] | [_] -> xs
| x1 :: x2 :: xs' ->
if n = (s <: nat) then x2 :: x1 :: xs' else x1 :: apply_swap_aux (n + 1) (x2 :: xs') s | false |
FStar.Tactics.CanonCommSwaps.fst | FStar.Tactics.CanonCommSwaps.lift_swaps_cons | val lift_swaps_cons (#a: eqtype) (h: a) (xs: list a) (ss: swaps_for xs)
: Pure (swaps_for (h :: xs))
(requires True)
(ensures (fun ss' -> apply_swaps (h :: xs) ss' == h :: (apply_swaps xs ss)))
(decreases ss) | val lift_swaps_cons (#a: eqtype) (h: a) (xs: list a) (ss: swaps_for xs)
: Pure (swaps_for (h :: xs))
(requires True)
(ensures (fun ss' -> apply_swaps (h :: xs) ss' == h :: (apply_swaps xs ss)))
(decreases ss) | let rec lift_swaps_cons (#a:eqtype) (h:a) (xs:list a) (ss:swaps_for xs) : Pure (swaps_for (h::xs))
(requires True)
(ensures (fun ss' ->
apply_swaps (h::xs) ss' == h::(apply_swaps xs ss)
))
(decreases ss)
=
match ss with
| [] -> []
| s::st ->
(
lift_swap_cons 0 h xs s;
(s + 1)::(lift_swaps_cons h (apply_swap xs s) st)
) | {
"file_name": "ulib/FStar.Tactics.CanonCommSwaps.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 5,
"end_line": 88,
"start_col": 0,
"start_line": 75
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.CanonCommSwaps
open FStar.List.Tot
let swap (n:nat) :Type = x:nat{x < n-1}
let rec apply_swap_aux (#a:Type) (n:nat) (xs:list a) (s:swap (length xs + n)) :
Pure (list a) (requires True)
(ensures (fun zs -> length zs == length xs)) (decreases xs) =
match xs with
| [] | [_] -> xs
| x1 :: x2 :: xs' -> if n = (s <: nat)
then x2 :: x1 :: xs'
else x1 :: apply_swap_aux (n+1) (x2 :: xs') s
let apply_swap (#a:Type) = apply_swap_aux #a 0
let rec apply_swaps (#a:Type) (xs:list a) (ss:list (swap (length xs))) :
Pure (list a) (requires True)
(ensures (fun zs -> length zs == length xs)) (decreases ss) =
match ss with
| [] -> xs
| s::ss' -> apply_swaps (apply_swap xs s) ss'
let equal_counts (#a:eqtype) (xs ys:list a) : Type0 =
(forall (e:a).{:pattern (count e xs) \/ (count e ys)} count e xs == count e ys)
let extend_equal_counts (#a:eqtype) (h:a) (xs ys:list a) : Lemma
(requires equal_counts xs ys)
(ensures equal_counts (h::xs) (h::ys))
=
()
let retract_equal_counts (#a:eqtype) (h:a) (xs ys:list a) : Lemma
(requires equal_counts (h::xs) (h::ys))
(ensures equal_counts xs ys)
=
assert (forall (e:a).{:pattern (count e xs) \/ (count e ys)} count e (h::xs) == count e (h::ys))
unfold let swap_for (#a:eqtype) (xs:list a) = swap (length xs)
unfold let swaps_for (#a:eqtype) (xs:list a) = list (swap_for xs)
let rec append_swaps (#a:eqtype) (xs:list a) (ss1 ss2:swaps_for xs) : Lemma
(ensures apply_swaps xs (ss1 @ ss2) == apply_swaps (apply_swaps xs ss1) ss2)
(decreases ss1)
=
match ss1 with
| [] -> ()
| h::t -> append_swaps (apply_swap xs h) t ss2
let rec lift_swap_cons (#a:eqtype) (n:nat) (h:a) (xs:list a) (s:swap (length xs + n)) : Lemma
(requires n <= s)
(ensures apply_swap_aux n (h::xs) (s + 1) == h::(apply_swap_aux n xs s))
(decreases xs)
=
match xs with
| [] -> ()
| x::xt -> if n < s then lift_swap_cons (n + 1) x xt s | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Tactics.CanonCommSwaps.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | h: a -> xs: Prims.list a -> ss: FStar.Tactics.CanonCommSwaps.swaps_for xs
-> Prims.Pure (FStar.Tactics.CanonCommSwaps.swaps_for (h :: xs)) | Prims.Pure | [
""
] | [] | [
"Prims.eqtype",
"Prims.list",
"FStar.Tactics.CanonCommSwaps.swaps_for",
"Prims.Nil",
"FStar.Tactics.CanonCommSwaps.swap_for",
"Prims.Cons",
"FStar.Tactics.CanonCommSwaps.apply_swap",
"Prims.op_Addition",
"FStar.Tactics.CanonCommSwaps.lift_swaps_cons",
"Prims.unit",
"FStar.Tactics.CanonCommSwaps.lift_swap_cons",
"Prims.l_True",
"Prims.eq2",
"FStar.Tactics.CanonCommSwaps.apply_swaps"
] | [
"recursion"
] | false | false | false | false | false | let rec lift_swaps_cons (#a: eqtype) (h: a) (xs: list a) (ss: swaps_for xs)
: Pure (swaps_for (h :: xs))
(requires True)
(ensures (fun ss' -> apply_swaps (h :: xs) ss' == h :: (apply_swaps xs ss)))
(decreases ss) =
| match ss with
| [] -> []
| s :: st ->
(lift_swap_cons 0 h xs s;
(s + 1) :: (lift_swaps_cons h (apply_swap xs s) st)) | false |
FStar.Tactics.CanonCommSwaps.fst | FStar.Tactics.CanonCommSwaps.lift_swap_cons | val lift_swap_cons (#a: eqtype) (n: nat) (h: a) (xs: list a) (s: swap (length xs + n))
: Lemma (requires n <= s)
(ensures apply_swap_aux n (h :: xs) (s + 1) == h :: (apply_swap_aux n xs s))
(decreases xs) | val lift_swap_cons (#a: eqtype) (n: nat) (h: a) (xs: list a) (s: swap (length xs + n))
: Lemma (requires n <= s)
(ensures apply_swap_aux n (h :: xs) (s + 1) == h :: (apply_swap_aux n xs s))
(decreases xs) | let rec lift_swap_cons (#a:eqtype) (n:nat) (h:a) (xs:list a) (s:swap (length xs + n)) : Lemma
(requires n <= s)
(ensures apply_swap_aux n (h::xs) (s + 1) == h::(apply_swap_aux n xs s))
(decreases xs)
=
match xs with
| [] -> ()
| x::xt -> if n < s then lift_swap_cons (n + 1) x xt s | {
"file_name": "ulib/FStar.Tactics.CanonCommSwaps.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 56,
"end_line": 73,
"start_col": 0,
"start_line": 66
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.CanonCommSwaps
open FStar.List.Tot
let swap (n:nat) :Type = x:nat{x < n-1}
let rec apply_swap_aux (#a:Type) (n:nat) (xs:list a) (s:swap (length xs + n)) :
Pure (list a) (requires True)
(ensures (fun zs -> length zs == length xs)) (decreases xs) =
match xs with
| [] | [_] -> xs
| x1 :: x2 :: xs' -> if n = (s <: nat)
then x2 :: x1 :: xs'
else x1 :: apply_swap_aux (n+1) (x2 :: xs') s
let apply_swap (#a:Type) = apply_swap_aux #a 0
let rec apply_swaps (#a:Type) (xs:list a) (ss:list (swap (length xs))) :
Pure (list a) (requires True)
(ensures (fun zs -> length zs == length xs)) (decreases ss) =
match ss with
| [] -> xs
| s::ss' -> apply_swaps (apply_swap xs s) ss'
let equal_counts (#a:eqtype) (xs ys:list a) : Type0 =
(forall (e:a).{:pattern (count e xs) \/ (count e ys)} count e xs == count e ys)
let extend_equal_counts (#a:eqtype) (h:a) (xs ys:list a) : Lemma
(requires equal_counts xs ys)
(ensures equal_counts (h::xs) (h::ys))
=
()
let retract_equal_counts (#a:eqtype) (h:a) (xs ys:list a) : Lemma
(requires equal_counts (h::xs) (h::ys))
(ensures equal_counts xs ys)
=
assert (forall (e:a).{:pattern (count e xs) \/ (count e ys)} count e (h::xs) == count e (h::ys))
unfold let swap_for (#a:eqtype) (xs:list a) = swap (length xs)
unfold let swaps_for (#a:eqtype) (xs:list a) = list (swap_for xs)
let rec append_swaps (#a:eqtype) (xs:list a) (ss1 ss2:swaps_for xs) : Lemma
(ensures apply_swaps xs (ss1 @ ss2) == apply_swaps (apply_swaps xs ss1) ss2)
(decreases ss1)
=
match ss1 with
| [] -> ()
| h::t -> append_swaps (apply_swap xs h) t ss2 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Tactics.CanonCommSwaps.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
n: Prims.nat ->
h: a ->
xs: Prims.list a ->
s: FStar.Tactics.CanonCommSwaps.swap (FStar.List.Tot.Base.length xs + n)
-> FStar.Pervasives.Lemma (requires n <= s)
(ensures
FStar.Tactics.CanonCommSwaps.apply_swap_aux n (h :: xs) (s + 1) ==
h :: FStar.Tactics.CanonCommSwaps.apply_swap_aux n xs s)
(decreases xs) | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"Prims.eqtype",
"Prims.nat",
"Prims.list",
"FStar.Tactics.CanonCommSwaps.swap",
"Prims.op_Addition",
"FStar.List.Tot.Base.length",
"Prims.op_LessThan",
"FStar.Tactics.CanonCommSwaps.lift_swap_cons",
"Prims.bool",
"Prims.unit",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.squash",
"Prims.eq2",
"FStar.Tactics.CanonCommSwaps.apply_swap_aux",
"Prims.Cons",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec lift_swap_cons (#a: eqtype) (n: nat) (h: a) (xs: list a) (s: swap (length xs + n))
: Lemma (requires n <= s)
(ensures apply_swap_aux n (h :: xs) (s + 1) == h :: (apply_swap_aux n xs s))
(decreases xs) =
| match xs with
| [] -> ()
| x :: xt -> if n < s then lift_swap_cons (n + 1) x xt s | false |
FStar.Tactics.CanonCommSwaps.fst | FStar.Tactics.CanonCommSwaps.equal_counts_implies_swaps | val equal_counts_implies_swaps (#a: eqtype) (xs ys: list a)
: Pure (swaps_for xs)
(requires equal_counts xs ys)
(ensures (fun ss -> ys == apply_swaps xs ss))
(decreases ys) | val equal_counts_implies_swaps (#a: eqtype) (xs ys: list a)
: Pure (swaps_for xs)
(requires equal_counts xs ys)
(ensures (fun ss -> ys == apply_swaps xs ss))
(decreases ys) | let rec equal_counts_implies_swaps (#a:eqtype) (xs ys:list a) : Pure (swaps_for xs)
(requires equal_counts xs ys)
(ensures (fun ss -> ys == apply_swaps xs ss))
(decreases ys)
=
match ys with
| [] ->
(
match xs with
| [] -> []
| x::xt ->
(
assert (count x xs >= 1);
[]
)
)
| y::yt ->
(
assert (count y ys >= 1);
assert (count y xs >= 1);
let ss0 = swap_to_front y xs in // find y in xs, swap it to the front
let xs' = apply_swaps xs ss0 in // hd xs' == y
let xt = tl xs' in // xs' == y::xt
retract_equal_counts y xt yt; // prove (equal_counts xt yt)
let ss1 = equal_counts_implies_swaps xt yt in // prove (yt == apply_swaps xt ss1)
let ss1' = lift_swaps_cons y xt ss1 in // y::yt == apply_swaps (y::xt) ss1'
// ys == apply_swaps (apply_swaps xs ss0) ss1'
append_swaps xs ss0 ss1';
ss0 @ ss1'
) | {
"file_name": "ulib/FStar.Tactics.CanonCommSwaps.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 5,
"end_line": 143,
"start_col": 0,
"start_line": 114
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.CanonCommSwaps
open FStar.List.Tot
let swap (n:nat) :Type = x:nat{x < n-1}
let rec apply_swap_aux (#a:Type) (n:nat) (xs:list a) (s:swap (length xs + n)) :
Pure (list a) (requires True)
(ensures (fun zs -> length zs == length xs)) (decreases xs) =
match xs with
| [] | [_] -> xs
| x1 :: x2 :: xs' -> if n = (s <: nat)
then x2 :: x1 :: xs'
else x1 :: apply_swap_aux (n+1) (x2 :: xs') s
let apply_swap (#a:Type) = apply_swap_aux #a 0
let rec apply_swaps (#a:Type) (xs:list a) (ss:list (swap (length xs))) :
Pure (list a) (requires True)
(ensures (fun zs -> length zs == length xs)) (decreases ss) =
match ss with
| [] -> xs
| s::ss' -> apply_swaps (apply_swap xs s) ss'
let equal_counts (#a:eqtype) (xs ys:list a) : Type0 =
(forall (e:a).{:pattern (count e xs) \/ (count e ys)} count e xs == count e ys)
let extend_equal_counts (#a:eqtype) (h:a) (xs ys:list a) : Lemma
(requires equal_counts xs ys)
(ensures equal_counts (h::xs) (h::ys))
=
()
let retract_equal_counts (#a:eqtype) (h:a) (xs ys:list a) : Lemma
(requires equal_counts (h::xs) (h::ys))
(ensures equal_counts xs ys)
=
assert (forall (e:a).{:pattern (count e xs) \/ (count e ys)} count e (h::xs) == count e (h::ys))
unfold let swap_for (#a:eqtype) (xs:list a) = swap (length xs)
unfold let swaps_for (#a:eqtype) (xs:list a) = list (swap_for xs)
let rec append_swaps (#a:eqtype) (xs:list a) (ss1 ss2:swaps_for xs) : Lemma
(ensures apply_swaps xs (ss1 @ ss2) == apply_swaps (apply_swaps xs ss1) ss2)
(decreases ss1)
=
match ss1 with
| [] -> ()
| h::t -> append_swaps (apply_swap xs h) t ss2
let rec lift_swap_cons (#a:eqtype) (n:nat) (h:a) (xs:list a) (s:swap (length xs + n)) : Lemma
(requires n <= s)
(ensures apply_swap_aux n (h::xs) (s + 1) == h::(apply_swap_aux n xs s))
(decreases xs)
=
match xs with
| [] -> ()
| x::xt -> if n < s then lift_swap_cons (n + 1) x xt s
let rec lift_swaps_cons (#a:eqtype) (h:a) (xs:list a) (ss:swaps_for xs) : Pure (swaps_for (h::xs))
(requires True)
(ensures (fun ss' ->
apply_swaps (h::xs) ss' == h::(apply_swaps xs ss)
))
(decreases ss)
=
match ss with
| [] -> []
| s::st ->
(
lift_swap_cons 0 h xs s;
(s + 1)::(lift_swaps_cons h (apply_swap xs s) st)
)
let rec swap_to_front (#a:eqtype) (h:a) (xs:list a) : Pure (swaps_for xs)
(requires count h xs >= 1)
(ensures (fun ss ->
let ys = apply_swaps xs ss in
equal_counts xs ys /\
Cons? ys /\
hd ys == h
))
=
match xs with
| [] -> []
| x::xt ->
(
if x = h then []
else
(
let ss = swap_to_front h xt in // ss turns xt into h::xt'
let ss' = lift_swaps_cons x xt ss in // ss' turns x::xt into x::h::xt'
let s:swap_for xs = 0 in
append_swaps xs ss' [s];
ss' @ [s]
)
) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Tactics.CanonCommSwaps.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | xs: Prims.list a -> ys: Prims.list a -> Prims.Pure (FStar.Tactics.CanonCommSwaps.swaps_for xs) | Prims.Pure | [
""
] | [] | [
"Prims.eqtype",
"Prims.list",
"Prims.Nil",
"FStar.Tactics.CanonCommSwaps.swap_for",
"Prims.unit",
"Prims._assert",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"FStar.List.Tot.Base.count",
"FStar.Tactics.CanonCommSwaps.swaps_for",
"FStar.List.Tot.Base.op_At",
"FStar.Tactics.CanonCommSwaps.append_swaps",
"FStar.Tactics.CanonCommSwaps.swap",
"FStar.List.Tot.Base.length",
"Prims.Cons",
"FStar.Tactics.CanonCommSwaps.lift_swaps_cons",
"FStar.Tactics.CanonCommSwaps.equal_counts_implies_swaps",
"FStar.Tactics.CanonCommSwaps.retract_equal_counts",
"FStar.List.Tot.Base.tl",
"FStar.Tactics.CanonCommSwaps.apply_swaps",
"FStar.Tactics.CanonCommSwaps.swap_to_front",
"FStar.Tactics.CanonCommSwaps.equal_counts",
"Prims.eq2"
] | [
"recursion"
] | false | false | false | false | false | let rec equal_counts_implies_swaps (#a: eqtype) (xs ys: list a)
: Pure (swaps_for xs)
(requires equal_counts xs ys)
(ensures (fun ss -> ys == apply_swaps xs ss))
(decreases ys) =
| match ys with
| [] ->
(match xs with
| [] -> []
| x :: xt ->
(assert (count x xs >= 1);
[]))
| y :: yt ->
(assert (count y ys >= 1);
assert (count y xs >= 1);
let ss0 = swap_to_front y xs in
let xs' = apply_swaps xs ss0 in
let xt = tl xs' in
retract_equal_counts y xt yt;
let ss1 = equal_counts_implies_swaps xt yt in
let ss1' = lift_swaps_cons y xt ss1 in
append_swaps xs ss0 ss1';
ss0 @ ss1') | false |
FStar.Tactics.CanonCommSwaps.fst | FStar.Tactics.CanonCommSwaps.append_swaps | val append_swaps (#a: eqtype) (xs: list a) (ss1 ss2: swaps_for xs)
: Lemma (ensures apply_swaps xs (ss1 @ ss2) == apply_swaps (apply_swaps xs ss1) ss2)
(decreases ss1) | val append_swaps (#a: eqtype) (xs: list a) (ss1 ss2: swaps_for xs)
: Lemma (ensures apply_swaps xs (ss1 @ ss2) == apply_swaps (apply_swaps xs ss1) ss2)
(decreases ss1) | let rec append_swaps (#a:eqtype) (xs:list a) (ss1 ss2:swaps_for xs) : Lemma
(ensures apply_swaps xs (ss1 @ ss2) == apply_swaps (apply_swaps xs ss1) ss2)
(decreases ss1)
=
match ss1 with
| [] -> ()
| h::t -> append_swaps (apply_swap xs h) t ss2 | {
"file_name": "ulib/FStar.Tactics.CanonCommSwaps.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 48,
"end_line": 64,
"start_col": 0,
"start_line": 58
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.CanonCommSwaps
open FStar.List.Tot
let swap (n:nat) :Type = x:nat{x < n-1}
let rec apply_swap_aux (#a:Type) (n:nat) (xs:list a) (s:swap (length xs + n)) :
Pure (list a) (requires True)
(ensures (fun zs -> length zs == length xs)) (decreases xs) =
match xs with
| [] | [_] -> xs
| x1 :: x2 :: xs' -> if n = (s <: nat)
then x2 :: x1 :: xs'
else x1 :: apply_swap_aux (n+1) (x2 :: xs') s
let apply_swap (#a:Type) = apply_swap_aux #a 0
let rec apply_swaps (#a:Type) (xs:list a) (ss:list (swap (length xs))) :
Pure (list a) (requires True)
(ensures (fun zs -> length zs == length xs)) (decreases ss) =
match ss with
| [] -> xs
| s::ss' -> apply_swaps (apply_swap xs s) ss'
let equal_counts (#a:eqtype) (xs ys:list a) : Type0 =
(forall (e:a).{:pattern (count e xs) \/ (count e ys)} count e xs == count e ys)
let extend_equal_counts (#a:eqtype) (h:a) (xs ys:list a) : Lemma
(requires equal_counts xs ys)
(ensures equal_counts (h::xs) (h::ys))
=
()
let retract_equal_counts (#a:eqtype) (h:a) (xs ys:list a) : Lemma
(requires equal_counts (h::xs) (h::ys))
(ensures equal_counts xs ys)
=
assert (forall (e:a).{:pattern (count e xs) \/ (count e ys)} count e (h::xs) == count e (h::ys))
unfold let swap_for (#a:eqtype) (xs:list a) = swap (length xs)
unfold let swaps_for (#a:eqtype) (xs:list a) = list (swap_for xs) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Tactics.CanonCommSwaps.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 |
xs: Prims.list a ->
ss1: FStar.Tactics.CanonCommSwaps.swaps_for xs ->
ss2: FStar.Tactics.CanonCommSwaps.swaps_for xs
-> FStar.Pervasives.Lemma
(ensures
FStar.Tactics.CanonCommSwaps.apply_swaps xs (ss1 @ ss2) ==
FStar.Tactics.CanonCommSwaps.apply_swaps (FStar.Tactics.CanonCommSwaps.apply_swaps xs ss1)
ss2) (decreases ss1) | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"Prims.eqtype",
"Prims.list",
"FStar.Tactics.CanonCommSwaps.swaps_for",
"FStar.Tactics.CanonCommSwaps.swap_for",
"FStar.Tactics.CanonCommSwaps.append_swaps",
"FStar.Tactics.CanonCommSwaps.apply_swap",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"FStar.Tactics.CanonCommSwaps.apply_swaps",
"FStar.List.Tot.Base.op_At",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec append_swaps (#a: eqtype) (xs: list a) (ss1 ss2: swaps_for xs)
: Lemma (ensures apply_swaps xs (ss1 @ ss2) == apply_swaps (apply_swaps xs ss1) ss2)
(decreases ss1) =
| match ss1 with
| [] -> ()
| h :: t -> append_swaps (apply_swap xs h) t ss2 | false |
Spec.SHA3.Constants.fst | Spec.SHA3.Constants.rotc_list | val rotc_list:list rotc_t | val rotc_list:list rotc_t | let rotc_list: list rotc_t =
[1ul; 3ul; 6ul; 10ul; 15ul; 21ul; 28ul; 36ul;
45ul; 55ul; 2ul; 14ul; 27ul; 41ul; 56ul; 8ul;
25ul; 43ul; 62ul; 18ul; 39ul; 61ul; 20ul; 44ul] | {
"file_name": "specs/Spec.SHA3.Constants.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 50,
"end_line": 13,
"start_col": 7,
"start_line": 10
} | module Spec.SHA3.Constants
open Lib.IntTypes
open Lib.Sequence
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let rotc_t = rotval U64 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SHA3.Constants.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA3",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA3",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.list Spec.SHA3.Constants.rotc_t | Prims.Tot | [
"total"
] | [] | [
"Prims.Cons",
"Spec.SHA3.Constants.rotc_t",
"FStar.UInt32.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | true | false | let rotc_list:list rotc_t =
| [
1ul; 3ul; 6ul; 10ul; 15ul; 21ul; 28ul; 36ul; 45ul; 55ul; 2ul; 14ul; 27ul; 41ul; 56ul; 8ul; 25ul;
43ul; 62ul; 18ul; 39ul; 61ul; 20ul; 44ul
] | false |
Spec.SHA3.Constants.fst | Spec.SHA3.Constants.keccak_rotc | val keccak_rotc:lseq rotc_t 24 | val keccak_rotc:lseq rotc_t 24 | let keccak_rotc:lseq rotc_t 24 =
assert_norm (List.Tot.length rotc_list == 24);
of_list rotc_list | {
"file_name": "specs/Spec.SHA3.Constants.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 19,
"end_line": 17,
"start_col": 0,
"start_line": 15
} | module Spec.SHA3.Constants
open Lib.IntTypes
open Lib.Sequence
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let rotc_t = rotval U64
unfold let rotc_list: list rotc_t =
[1ul; 3ul; 6ul; 10ul; 15ul; 21ul; 28ul; 36ul;
45ul; 55ul; 2ul; 14ul; 27ul; 41ul; 56ul; 8ul;
25ul; 43ul; 62ul; 18ul; 39ul; 61ul; 20ul; 44ul] | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SHA3.Constants.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA3",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA3",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq Spec.SHA3.Constants.rotc_t 24 | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.of_list",
"Spec.SHA3.Constants.rotc_t",
"Spec.SHA3.Constants.rotc_list",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length"
] | [] | false | false | false | false | false | let keccak_rotc:lseq rotc_t 24 =
| assert_norm (List.Tot.length rotc_list == 24);
of_list rotc_list | false |
FStar.Tactics.CanonCommSwaps.fst | FStar.Tactics.CanonCommSwaps.swap_to_front | val swap_to_front (#a: eqtype) (h: a) (xs: list a)
: Pure (swaps_for xs)
(requires count h xs >= 1)
(ensures
(fun ss ->
let ys = apply_swaps xs ss in
equal_counts xs ys /\ Cons? ys /\ hd ys == h)) | val swap_to_front (#a: eqtype) (h: a) (xs: list a)
: Pure (swaps_for xs)
(requires count h xs >= 1)
(ensures
(fun ss ->
let ys = apply_swaps xs ss in
equal_counts xs ys /\ Cons? ys /\ hd ys == h)) | let rec swap_to_front (#a:eqtype) (h:a) (xs:list a) : Pure (swaps_for xs)
(requires count h xs >= 1)
(ensures (fun ss ->
let ys = apply_swaps xs ss in
equal_counts xs ys /\
Cons? ys /\
hd ys == h
))
=
match xs with
| [] -> []
| x::xt ->
(
if x = h then []
else
(
let ss = swap_to_front h xt in // ss turns xt into h::xt'
let ss' = lift_swaps_cons x xt ss in // ss' turns x::xt into x::h::xt'
let s:swap_for xs = 0 in
append_swaps xs ss' [s];
ss' @ [s]
)
) | {
"file_name": "ulib/FStar.Tactics.CanonCommSwaps.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 5,
"end_line": 112,
"start_col": 0,
"start_line": 90
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.Tactics.CanonCommSwaps
open FStar.List.Tot
let swap (n:nat) :Type = x:nat{x < n-1}
let rec apply_swap_aux (#a:Type) (n:nat) (xs:list a) (s:swap (length xs + n)) :
Pure (list a) (requires True)
(ensures (fun zs -> length zs == length xs)) (decreases xs) =
match xs with
| [] | [_] -> xs
| x1 :: x2 :: xs' -> if n = (s <: nat)
then x2 :: x1 :: xs'
else x1 :: apply_swap_aux (n+1) (x2 :: xs') s
let apply_swap (#a:Type) = apply_swap_aux #a 0
let rec apply_swaps (#a:Type) (xs:list a) (ss:list (swap (length xs))) :
Pure (list a) (requires True)
(ensures (fun zs -> length zs == length xs)) (decreases ss) =
match ss with
| [] -> xs
| s::ss' -> apply_swaps (apply_swap xs s) ss'
let equal_counts (#a:eqtype) (xs ys:list a) : Type0 =
(forall (e:a).{:pattern (count e xs) \/ (count e ys)} count e xs == count e ys)
let extend_equal_counts (#a:eqtype) (h:a) (xs ys:list a) : Lemma
(requires equal_counts xs ys)
(ensures equal_counts (h::xs) (h::ys))
=
()
let retract_equal_counts (#a:eqtype) (h:a) (xs ys:list a) : Lemma
(requires equal_counts (h::xs) (h::ys))
(ensures equal_counts xs ys)
=
assert (forall (e:a).{:pattern (count e xs) \/ (count e ys)} count e (h::xs) == count e (h::ys))
unfold let swap_for (#a:eqtype) (xs:list a) = swap (length xs)
unfold let swaps_for (#a:eqtype) (xs:list a) = list (swap_for xs)
let rec append_swaps (#a:eqtype) (xs:list a) (ss1 ss2:swaps_for xs) : Lemma
(ensures apply_swaps xs (ss1 @ ss2) == apply_swaps (apply_swaps xs ss1) ss2)
(decreases ss1)
=
match ss1 with
| [] -> ()
| h::t -> append_swaps (apply_swap xs h) t ss2
let rec lift_swap_cons (#a:eqtype) (n:nat) (h:a) (xs:list a) (s:swap (length xs + n)) : Lemma
(requires n <= s)
(ensures apply_swap_aux n (h::xs) (s + 1) == h::(apply_swap_aux n xs s))
(decreases xs)
=
match xs with
| [] -> ()
| x::xt -> if n < s then lift_swap_cons (n + 1) x xt s
let rec lift_swaps_cons (#a:eqtype) (h:a) (xs:list a) (ss:swaps_for xs) : Pure (swaps_for (h::xs))
(requires True)
(ensures (fun ss' ->
apply_swaps (h::xs) ss' == h::(apply_swaps xs ss)
))
(decreases ss)
=
match ss with
| [] -> []
| s::st ->
(
lift_swap_cons 0 h xs s;
(s + 1)::(lift_swaps_cons h (apply_swap xs s) st)
) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Tactics.CanonCommSwaps.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | h: a -> xs: Prims.list a -> Prims.Pure (FStar.Tactics.CanonCommSwaps.swaps_for xs) | Prims.Pure | [] | [] | [
"Prims.eqtype",
"Prims.list",
"Prims.Nil",
"FStar.Tactics.CanonCommSwaps.swap_for",
"Prims.op_Equality",
"Prims.bool",
"FStar.List.Tot.Base.op_At",
"Prims.Cons",
"Prims.unit",
"FStar.Tactics.CanonCommSwaps.append_swaps",
"FStar.Tactics.CanonCommSwaps.swap",
"FStar.List.Tot.Base.length",
"FStar.Tactics.CanonCommSwaps.lift_swaps_cons",
"FStar.Tactics.CanonCommSwaps.swap_to_front",
"FStar.Tactics.CanonCommSwaps.swaps_for",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"FStar.List.Tot.Base.count",
"Prims.l_and",
"FStar.Tactics.CanonCommSwaps.equal_counts",
"Prims.uu___is_Cons",
"Prims.eq2",
"FStar.List.Tot.Base.hd",
"FStar.Tactics.CanonCommSwaps.apply_swaps"
] | [
"recursion"
] | false | false | false | false | false | let rec swap_to_front (#a: eqtype) (h: a) (xs: list a)
: Pure (swaps_for xs)
(requires count h xs >= 1)
(ensures
(fun ss ->
let ys = apply_swaps xs ss in
equal_counts xs ys /\ Cons? ys /\ hd ys == h)) =
| match xs with
| [] -> []
| x :: xt ->
(if x = h
then []
else
(let ss = swap_to_front h xt in
let ss' = lift_swaps_cons x xt ss in
let s:swap_for xs = 0 in
append_swaps xs ss' [s];
ss' @ [s])) | false |
Spec.SHA3.Constants.fst | Spec.SHA3.Constants.keccak_rndc | val keccak_rndc:lseq pub_uint64 24 | val keccak_rndc:lseq pub_uint64 24 | let keccak_rndc: lseq pub_uint64 24 =
assert_norm (List.Tot.length rndc_list == 24);
of_list rndc_list | {
"file_name": "specs/Spec.SHA3.Constants.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 19,
"end_line": 40,
"start_col": 0,
"start_line": 38
} | module Spec.SHA3.Constants
open Lib.IntTypes
open Lib.Sequence
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let rotc_t = rotval U64
unfold let rotc_list: list rotc_t =
[1ul; 3ul; 6ul; 10ul; 15ul; 21ul; 28ul; 36ul;
45ul; 55ul; 2ul; 14ul; 27ul; 41ul; 56ul; 8ul;
25ul; 43ul; 62ul; 18ul; 39ul; 61ul; 20ul; 44ul]
let keccak_rotc:lseq rotc_t 24 =
assert_norm (List.Tot.length rotc_list == 24);
of_list rotc_list
let piln_t = x:size_t{size_v x < 25}
unfold let piln_list: list piln_t =
[10ul; 7ul; 11ul; 17ul; 18ul; 3ul; 5ul; 16ul;
8ul; 21ul; 24ul; 4ul; 15ul; 23ul; 19ul; 13ul;
12ul; 2ul; 20ul; 14ul; 22ul; 9ul; 6ul; 1ul]
let keccak_piln: lseq piln_t 24 =
assert_norm (List.Tot.length piln_list == 24);
of_list piln_list
unfold let rndc_list: list pub_uint64 =
[0x0000000000000001uL; 0x0000000000008082uL; 0x800000000000808auL; 0x8000000080008000uL;
0x000000000000808buL; 0x0000000080000001uL; 0x8000000080008081uL; 0x8000000000008009uL;
0x000000000000008auL; 0x0000000000000088uL; 0x0000000080008009uL; 0x000000008000000auL;
0x000000008000808buL; 0x800000000000008buL; 0x8000000000008089uL; 0x8000000000008003uL;
0x8000000000008002uL; 0x8000000000000080uL; 0x000000000000800auL; 0x800000008000000auL;
0x8000000080008081uL; 0x8000000000008080uL; 0x0000000080000001uL; 0x8000000080008008uL] | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SHA3.Constants.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA3",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA3",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U64 Lib.IntTypes.PUB) 24 | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.PUB",
"Spec.SHA3.Constants.rndc_list",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length"
] | [] | false | false | false | false | false | let keccak_rndc:lseq pub_uint64 24 =
| assert_norm (List.Tot.length rndc_list == 24);
of_list rndc_list | false |
Spec.SHA3.Constants.fst | Spec.SHA3.Constants.keccak_piln | val keccak_piln:lseq piln_t 24 | val keccak_piln:lseq piln_t 24 | let keccak_piln: lseq piln_t 24 =
assert_norm (List.Tot.length piln_list == 24);
of_list piln_list | {
"file_name": "specs/Spec.SHA3.Constants.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 19,
"end_line": 28,
"start_col": 0,
"start_line": 26
} | module Spec.SHA3.Constants
open Lib.IntTypes
open Lib.Sequence
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let rotc_t = rotval U64
unfold let rotc_list: list rotc_t =
[1ul; 3ul; 6ul; 10ul; 15ul; 21ul; 28ul; 36ul;
45ul; 55ul; 2ul; 14ul; 27ul; 41ul; 56ul; 8ul;
25ul; 43ul; 62ul; 18ul; 39ul; 61ul; 20ul; 44ul]
let keccak_rotc:lseq rotc_t 24 =
assert_norm (List.Tot.length rotc_list == 24);
of_list rotc_list
let piln_t = x:size_t{size_v x < 25}
unfold let piln_list: list piln_t =
[10ul; 7ul; 11ul; 17ul; 18ul; 3ul; 5ul; 16ul;
8ul; 21ul; 24ul; 4ul; 15ul; 23ul; 19ul; 13ul;
12ul; 2ul; 20ul; 14ul; 22ul; 9ul; 6ul; 1ul] | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SHA3.Constants.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA3",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA3",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Lib.Sequence.lseq Spec.SHA3.Constants.piln_t 24 | Prims.Tot | [
"total"
] | [] | [
"Lib.Sequence.of_list",
"Spec.SHA3.Constants.piln_t",
"Spec.SHA3.Constants.piln_list",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.List.Tot.Base.length"
] | [] | false | false | false | false | false | let keccak_piln:lseq piln_t 24 =
| assert_norm (List.Tot.length piln_list == 24);
of_list piln_list | false |
Spec.Agile.HPKE.fst | Spec.Agile.HPKE.openAuth | val openAuth:
cs:ciphersuite_not_export_only
-> enc:key_dh_public_s cs
-> skR:key_dh_secret_s cs
-> info:info_s cs
-> aad:AEAD.ad (aead_alg_of cs)
-> ct:AEAD.cipher (aead_alg_of cs)
-> pkS:DH.serialized_point (kem_dh_of_cs cs) ->
Tot (option (AEAD.decrypted #(aead_alg_of cs) ct)) | val openAuth:
cs:ciphersuite_not_export_only
-> enc:key_dh_public_s cs
-> skR:key_dh_secret_s cs
-> info:info_s cs
-> aad:AEAD.ad (aead_alg_of cs)
-> ct:AEAD.cipher (aead_alg_of cs)
-> pkS:DH.serialized_point (kem_dh_of_cs cs) ->
Tot (option (AEAD.decrypted #(aead_alg_of cs) ct)) | let openAuth cs enc skR info aad ct pkS =
match setupAuthR cs enc skR info pkS with
| None -> None
| Some ctx ->
match context_open cs ctx aad ct with
| None -> None
| Some (_, pt) -> Some pt | {
"file_name": "specs/Spec.Agile.HPKE.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 29,
"end_line": 572,
"start_col": 0,
"start_line": 566
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
let pow2_61 : _:unit{pow2 61 == 2305843009213693952} = assert_norm(pow2 61 == 2305843009213693952)
let pow2_35_less_than_pow2_61 : _:unit{pow2 32 * pow2 3 <= pow2 61 - 1} = assert_norm(pow2 32 * pow2 3 <= pow2 61 - 1)
let pow2_35_less_than_pow2_125 : _:unit{pow2 32 * pow2 3 <= pow2 125 - 1} = assert_norm(pow2 32 * pow2 3 <= pow2 125 - 1)
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
/// Types
val id_kem: cs:ciphersuite -> Tot (lbytes 2)
let id_kem cs = let kem_dh, kem_hash, _, _ = cs in
match kem_dh, kem_hash with
| DH.DH_P256, Hash.SHA2_256 -> create 1 (u8 0) @| create 1 (u8 16)
| DH.DH_Curve25519, Hash.SHA2_256 -> create 1 (u8 0) @| create 1 (u8 32)
val id_kdf: cs:ciphersuite -> Tot (lbytes 2)
let id_kdf cs = let _, _, _, h = cs in
match h with
| Hash.SHA2_256 -> create 1 (u8 0) @| create 1 (u8 1)
| Hash.SHA2_384 -> create 1 (u8 0) @| create 1 (u8 2)
| Hash.SHA2_512 -> create 1 (u8 0) @| create 1 (u8 3)
val id_aead: cs:ciphersuite -> Tot (lbytes 2)
let id_aead cs = let _, _, a, _ = cs in
match a with
| Seal AEAD.AES128_GCM -> create 1 (u8 0) @| create 1 (u8 1)
| Seal AEAD.AES256_GCM -> create 1 (u8 0) @| create 1 (u8 2)
| Seal AEAD.CHACHA20_POLY1305 -> create 1 (u8 0) @| create 1 (u8 3)
| ExportOnly -> create 1 (u8 255) @| create 1 (u8 255)
val suite_id_kem: cs:ciphersuite -> Tot (lbytes size_suite_id_kem)
let suite_id_kem cs =
Seq.append label_KEM (id_kem cs)
val suite_id_hpke: cs:ciphersuite -> Tot (lbytes size_suite_id_hpke)
let suite_id_hpke cs =
Seq.append label_HPKE (id_kem cs @| id_kdf cs @| id_aead cs)
val id_of_mode: m:mode -> Tot (lbytes size_mode_identifier)
let id_of_mode m =
match m with
| Base -> create 1 (u8 0)
| PSK -> create 1 (u8 1)
| Auth -> create 1 (u8 2)
| AuthPSK -> create 1 (u8 3)
val labeled_extract:
a:hash_algorithm
-> suite_id:bytes
-> salt:bytes
-> label:bytes
-> ikm:bytes ->
Pure (lbytes (Spec.Hash.Definitions.hash_length a))
(requires
Spec.Agile.HMAC.keysized a (Seq.length salt) /\
labeled_extract_ikm_length_pred a (Seq.length suite_id + Seq.length label + Seq.length ikm))
(ensures fun _ -> True)
let labeled_extract a suite_id salt label ikm =
let labeled_ikm1 = Seq.append label_version suite_id in
let labeled_ikm2 = Seq.append labeled_ikm1 label in
let labeled_ikm3 = Seq.append labeled_ikm2 ikm in
HKDF.extract a salt labeled_ikm3
val labeled_expand:
a:hash_algorithm
-> suite_id:bytes
-> prk:bytes
-> label:bytes
-> info:bytes
-> l:size_nat ->
Pure (lbytes l)
(requires
Spec.Hash.Definitions.hash_length a <= Seq.length prk /\
Spec.Agile.HMAC.keysized a (Seq.length prk) /\
labeled_expand_info_length_pred a (Seq.length suite_id + Seq.length label + Seq.length info) /\
HKDF.expand_output_length_pred a l)
(ensures fun _ -> True)
let labeled_expand a suite_id prk label info l =
let labeled_info1 = nat_to_bytes_be 2 l in
let labeled_info2 = Seq.append labeled_info1 label_version in
let labeled_info3 = Seq.append labeled_info2 suite_id in
let labeled_info4 = Seq.append labeled_info3 label in
let labeled_info5 = Seq.append labeled_info4 info in
HKDF.expand a prk labeled_info5 l
let extract_and_expand_dh_pred (cs:ciphersuite) (dh_length:nat) =
labeled_extract_ikm_length_pred (kem_hash_of_cs cs) (size_suite_id_kem + size_label_eae_prk + dh_length)
let extract_and_expand_ctx_pred (cs:ciphersuite) (ctx_length:nat) =
labeled_expand_info_length_pred (kem_hash_of_cs cs) (size_suite_id_kem + size_label_shared_secret + ctx_length)
val extract_and_expand:
cs:ciphersuite
-> dh:bytes
-> kem_context:bytes ->
Pure (key_kem_s cs)
(requires
extract_and_expand_dh_pred cs (Seq.length dh) /\
extract_and_expand_ctx_pred cs (Seq.length kem_context))
(ensures fun _ -> True)
let extract_and_expand cs dh kem_context =
let eae_prk = labeled_extract (kem_hash_of_cs cs) (suite_id_kem cs) lbytes_empty label_eae_prk dh in
labeled_expand (kem_hash_of_cs cs) (suite_id_kem cs) eae_prk label_shared_secret kem_context (size_kem_key cs)
let deserialize_public_key cs pk = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> pk
// Extract the point coordinates by removing the first representation byte
| DH.DH_P256 -> sub pk 1 64
let serialize_public_key cs pk = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> pk
// Add the first representation byte to the point coordinates
| DH.DH_P256 -> create 1 (u8 4) @| pk
val dkp_nist_p: cs:ciphersuite -> lbytes (size_kem_kdf cs) -> counter:uint8 -> Tot (option (key_dh_secret_s cs & key_dh_public_s cs)) (decreases 255 - v counter)
let rec dkp_nist_p cs dkp_prk counter =
let counterbyte = nat_to_intseq_be #U8 #SEC 1 (v counter) in
let bytes = labeled_expand (kem_hash_of_cs cs) (suite_id_kem cs) dkp_prk label_candidate counterbyte (size_dh_key cs) in
let bytes = Lib.Sequence.map2 (logand #U8 #SEC) bytes (Seq.create (size_dh_key cs) (u8 255)) in
let sk = nat_from_intseq_be #U8 #SEC bytes in
if sk = 0 || sk >= Spec.P256.prime then
if (v counter) = 255 then None
else dkp_nist_p cs dkp_prk (counter +! (u8 1))
else
match DH.secret_to_public (kem_dh_of_cs cs) bytes with
| Some pk -> Some (bytes, serialize_public_key cs pk)
| None ->
if (v counter) = 255 then None
else dkp_nist_p cs dkp_prk (counter +! (u8 1))
let derive_key_pair cs ikm =
match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> begin
let dkp_prk = labeled_extract (kem_hash_of_cs cs) (suite_id_kem cs) lbytes_empty label_dkp_prk ikm in
let sk = labeled_expand (kem_hash_of_cs cs) (suite_id_kem cs) dkp_prk label_sk lbytes_empty (size_dh_key cs) in
match DH.secret_to_public (kem_dh_of_cs cs) sk with
| Some pk -> Some (sk, serialize_public_key cs pk)
end
| DH.DH_P256 ->
let dkp_prk = labeled_extract (kem_hash_of_cs cs) (suite_id_kem cs) lbytes_empty label_dkp_prk ikm in
dkp_nist_p cs dkp_prk (u8 0)
val prepare_dh: cs:ciphersuite -> DH.serialized_point (kem_dh_of_cs cs) -> Tot (lbytes 32)
let prepare_dh cs dh = match (kem_dh_of_cs cs) with
| DH.DH_Curve25519 -> serialize_public_key cs dh
| DH.DH_P256 -> sub dh 0 32
val encap:
cs:ciphersuite
-> skE:key_dh_secret_s cs
-> pkR:DH.serialized_point (kem_dh_of_cs cs) ->
Tot (option (key_kem_s cs & key_dh_public_s cs))
#restart-solver
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
let encap cs skE pkR =
let _ = allow_inversion Spec.Agile.DH.algorithm in
match DH.secret_to_public (kem_dh_of_cs cs) skE with
| None -> None
| Some pkE ->
let enc = serialize_public_key cs pkE in
match DH.dh (kem_dh_of_cs cs) skE pkR with
| None -> None
| Some dh ->
let pkRm = serialize_public_key cs pkR in
let kem_context = concat enc pkRm in
let dhm = prepare_dh cs dh in
assert (Seq.length kem_context = 2*size_dh_public cs);
assert (extract_and_expand_ctx_pred cs (Seq.length kem_context));
let shared_secret:key_kem_s cs = extract_and_expand cs dhm kem_context in
Some (shared_secret, enc)
val decap:
cs: ciphersuite
-> enc: key_dh_public_s cs
-> skR: key_dh_secret_s cs ->
Tot (option (key_kem_s cs))
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
let decap cs enc skR =
let _ = allow_inversion Spec.Agile.DH.algorithm in
let _ = allow_inversion Spec.Agile.Hash.hash_alg in
let pkE = deserialize_public_key cs enc in
match DH.dh (kem_dh_of_cs cs) skR pkE with
| None -> None
| Some dh ->
match DH.secret_to_public (kem_dh_of_cs cs) skR with
| None -> None
| Some pkR ->
let pkRm = serialize_public_key cs pkR in
let kem_context = concat enc pkRm in
let dhm = prepare_dh cs dh in
assert (Seq.length kem_context = 2*size_dh_public cs);
assert (extract_and_expand_ctx_pred cs (Seq.length kem_context));
let shared_secret = extract_and_expand cs dhm kem_context in
Some (shared_secret)
val auth_encap:
cs:ciphersuite
-> skE:key_dh_secret_s cs
-> pkR:DH.serialized_point (kem_dh_of_cs cs)
-> skS:key_dh_secret_s cs ->
Tot (option (key_kem_s cs & key_dh_public_s cs))
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
let auth_encap cs skE pkR skS =
let _ = allow_inversion Spec.Agile.DH.algorithm in
match DH.secret_to_public (kem_dh_of_cs cs) skE with
| None -> None
| Some pkE ->
match DH.dh (kem_dh_of_cs cs) skE pkR with
| None -> None
| Some es ->
match DH.dh (kem_dh_of_cs cs) skS pkR with
| None -> None
| Some ss ->
let esm = prepare_dh cs es in
let ssm = prepare_dh cs ss in
// TODO Do not put 32 literally
let dh = concat #uint8 #32 #32 esm ssm in
let enc = serialize_public_key cs pkE in
match DH.secret_to_public (kem_dh_of_cs cs) skS with
| None -> None
| Some pkS ->
let pkSm = serialize_public_key cs pkS in
let pkRm = serialize_public_key cs pkR in
let kem_context = concat enc (concat pkRm pkSm) in
assert (Seq.length kem_context = 3*size_dh_public cs);
assert (labeled_expand_info_length_pred (kem_hash_of_cs cs) (size_suite_id_kem + size_label_shared_secret + Seq.length kem_context));
assert (extract_and_expand_ctx_pred cs (Seq.length kem_context));
// TODO Do not put 64 literally
assert (Seq.length dh = 64);
assert (labeled_extract_ikm_length_pred (kem_hash_of_cs cs) (size_suite_id_kem + size_label_eae_prk + Seq.length dh));
assert (extract_and_expand_dh_pred cs (Seq.length dh));
let shared_secret = extract_and_expand cs dh kem_context in
Some (shared_secret, enc)
#reset-options
val auth_decap:
cs: ciphersuite
-> enc: key_dh_public_s cs
-> skR: key_dh_secret_s cs
-> pkS: DH.serialized_point (kem_dh_of_cs cs) ->
Tot (option (key_kem_s cs))
#restart-solver
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
let auth_decap cs enc skR pkS =
let _ = allow_inversion Spec.Agile.DH.algorithm in
let pkE = deserialize_public_key cs enc in
match DH.dh (kem_dh_of_cs cs) skR pkE with
| None -> None
| Some es ->
match DH.dh (kem_dh_of_cs cs) skR pkS with
| None -> None
| Some ss ->
let esm = prepare_dh cs es in
let ssm = prepare_dh cs ss in
let dh = concat #uint8 #32 #32 esm ssm in
match DH.secret_to_public (kem_dh_of_cs cs) skR with
| None -> None
| Some pkR ->
let pkRm = serialize_public_key cs pkR in
let pkSm = serialize_public_key cs pkS in
let kem_context = concat enc (concat pkRm pkSm) in
assert (Seq.length kem_context = 3*size_dh_public cs);
assert (labeled_expand_info_length_pred (kem_hash_of_cs cs) (size_suite_id_kem + size_label_shared_secret + Seq.length kem_context));
assert (extract_and_expand_ctx_pred cs (Seq.length kem_context));
assert (Seq.length dh = 64);
assert (labeled_extract_ikm_length_pred (kem_hash_of_cs cs) (size_suite_id_kem + size_label_eae_prk + Seq.length dh));
assert (extract_and_expand_dh_pred cs (Seq.length dh));
let shared_secret = extract_and_expand cs dh kem_context in
Some (shared_secret)
#reset-options
let default_psk = lbytes_empty
let default_psk_id = lbytes_empty
val build_context:
cs:ciphersuite
-> m:mode
-> psk_id_hash:lbytes (size_kdf cs)
-> info_hash:lbytes (size_kdf cs) ->
Tot (lbytes (size_ks_ctx cs))
let build_context cs m psk_id_hash info_hash =
let context = id_of_mode m in
let context = Seq.append context psk_id_hash in
let context = Seq.append context info_hash in
context
let verify_psk_inputs (cs:ciphersuite) (m:mode) (opsk:option(psk_s cs & psk_id_s cs)) : bool =
match (m, opsk) with
| Base, None -> true
| PSK, Some _ -> true
| Auth, None -> true
| AuthPSK, Some _ -> true
| _, _ -> false
// key and nonce are zero-length if AEAD is Export-Only
let encryption_context (cs:ciphersuite) = key_aead_s cs & nonce_aead_s cs & seq_aead_s cs & exporter_secret_s cs
val key_schedule:
cs:ciphersuite
-> m:mode
-> shared_secret:key_kem_s cs
-> info:info_s cs
-> opsk:option (psk_s cs & psk_id_s cs) ->
Pure (encryption_context cs)
(requires verify_psk_inputs cs m opsk)
(ensures fun _ -> True)
#set-options "--z3rlimit 500 --fuel 0 --ifuel 2"
let key_schedule_core
(cs:ciphersuite)
(m:mode)
(shared_secret:key_kem_s cs)
(info:info_s cs)
(opsk:option (psk_s cs & psk_id_s cs))
: (lbytes (size_ks_ctx cs) & exporter_secret_s cs & (lbytes (Spec.Hash.Definitions.hash_length (hash_of_cs cs)))) =
let (psk, psk_id) =
match opsk with
| None -> (default_psk, default_psk_id)
| Some (psk, psk_id) -> (psk, psk_id)
in
let psk_id_hash = labeled_extract (hash_of_cs cs) (suite_id_hpke cs) lbytes_empty label_psk_id_hash psk_id in
let info_hash = labeled_extract (hash_of_cs cs) (suite_id_hpke cs) lbytes_empty label_info_hash info in
let context = build_context cs m psk_id_hash info_hash in
let secret = labeled_extract (hash_of_cs cs) (suite_id_hpke cs) shared_secret label_secret psk in
let exporter_secret = labeled_expand (hash_of_cs cs) (suite_id_hpke cs) secret label_exp context (size_kdf cs) in
context, exporter_secret, secret
let key_schedule_end
(cs:ciphersuite)
(m:mode)
(context:lbytes (size_ks_ctx cs))
(exporter_secret:exporter_secret_s cs)
(secret:(lbytes (Spec.Hash.Definitions.hash_length (hash_of_cs cs))))
: encryption_context cs
=
if is_valid_not_export_only_ciphersuite cs then (
let key = labeled_expand (hash_of_cs cs) (suite_id_hpke cs) secret label_key context (size_aead_key cs) in
let base_nonce = labeled_expand (hash_of_cs cs) (suite_id_hpke cs) secret label_base_nonce context (size_aead_nonce cs) in
(key, base_nonce, 0, exporter_secret)
) else (
(* if AEAD is Export-Only, then skip computation of key and base_nonce *)
assert (size_aead_key cs = 0);
assert (size_aead_nonce cs = 0);
(lbytes_empty, lbytes_empty, 0, exporter_secret))
let key_schedule cs m shared_secret info opsk =
let context, exporter_secret, secret = key_schedule_core cs m shared_secret info opsk in
key_schedule_end cs m context exporter_secret secret
let key_of_ctx (cs:ciphersuite) (ctx:encryption_context cs) =
let key, _, _, _ = ctx in key
let base_nonce_of_ctx (cs:ciphersuite) (ctx:encryption_context cs) =
let _, base_nonce, _, _ = ctx in base_nonce
let seq_of_ctx (cs:ciphersuite) (ctx:encryption_context cs) =
let _, _, seq, _ = ctx in seq
let exp_sec_of_ctx (cs:ciphersuite) (ctx:encryption_context cs) =
let _, _, _, exp_sec = ctx in exp_sec
let set_seq (cs:ciphersuite) (ctx:encryption_context cs) (seq:seq_aead_s cs) =
let key, base_nonce, _, exp_sec = ctx in
(key, base_nonce, seq, exp_sec)
///
/// Encryption Context
///
let context_export cs ctx exp_ctx l =
let exp_sec = exp_sec_of_ctx cs ctx in
labeled_expand (hash_of_cs cs) (suite_id_hpke cs) exp_sec label_sec exp_ctx l
let context_compute_nonce cs ctx seq =
let base_nonce = base_nonce_of_ctx cs ctx in
let enc_seq = nat_to_bytes_be (size_aead_nonce cs) seq in
Spec.Loops.seq_map2 logxor enc_seq base_nonce
let context_increment_seq cs ctx =
let seq = seq_of_ctx cs ctx in
if seq = max_seq cs then None else
Some (set_seq cs ctx (seq + 1))
let context_seal cs ctx aad pt =
let key = key_of_ctx cs ctx in
let seq = seq_of_ctx cs ctx in
let nonce = context_compute_nonce cs ctx seq in
let ct = AEAD.encrypt key nonce aad pt in
match context_increment_seq cs ctx with
| None -> None
| Some new_ctx -> Some (new_ctx, ct)
let context_open cs ctx aad ct =
let key = key_of_ctx cs ctx in
let seq = seq_of_ctx cs ctx in
let nonce = context_compute_nonce cs ctx seq in
match AEAD.decrypt key nonce aad ct with
| None -> None
| Some pt ->
match context_increment_seq cs ctx with
| None -> None
| Some new_ctx -> Some (new_ctx, pt)
///
/// Base Mode
///
let setupBaseS cs skE pkR info =
match encap cs skE pkR with
| None -> None
| Some (shared_secret, enc) ->
let enc_ctx = key_schedule cs Base shared_secret info None in
Some (enc, enc_ctx)
let setupBaseR cs enc skR info =
let pkR = DH.secret_to_public (kem_dh_of_cs cs) skR in
let shared_secret = decap cs enc skR in
match pkR, shared_secret with
| Some pkR, Some shared_secret ->
Some (key_schedule cs Base shared_secret info None)
| _ -> None
let sealBase cs skE pkR info aad pt =
match setupBaseS cs skE pkR info with
| None -> None
| Some (enc, ctx) ->
match context_seal cs ctx aad pt with
| None -> None
| Some (_, ct) -> Some (enc, ct)
let openBase cs enc skR info aad ct =
match setupBaseR cs enc skR info with
| None -> None
| Some ctx ->
match context_open cs ctx aad ct with
| None -> None
| Some (_, pt) -> Some pt
let sendExportBase cs skE pkR info exp_ctx l =
match setupBaseS cs skE pkR info with
| None -> None
| Some (enc, ctx) ->
Some (enc, context_export cs ctx exp_ctx l)
let receiveExportBase cs enc skR info exp_ctx l =
match setupBaseR cs enc skR info with
| None -> None
| Some ctx ->
Some (context_export cs ctx exp_ctx l)
///
/// PSK mode
///
let setupPSKS cs skE pkR info psk psk_id =
match encap cs skE pkR with
| None -> None
| Some (shared_secret, enc) ->
assert (verify_psk_inputs cs PSK (Some (psk, psk_id)));
let enc_ctx = key_schedule cs PSK shared_secret info (Some (psk, psk_id)) in
Some (enc, enc_ctx)
let setupPSKR cs enc skR info psk psk_id =
let pkR = DH.secret_to_public (kem_dh_of_cs cs) skR in
let shared_secret = decap cs enc skR in
match pkR, shared_secret with
| Some pkR, Some shared_secret ->
Some (key_schedule cs PSK shared_secret info (Some (psk, psk_id)))
| _ -> None
let sealPSK cs skE pkR info aad pt psk psk_id =
match setupPSKS cs skE pkR info psk psk_id with
| None -> None
| Some (enc, ctx) ->
match context_seal cs ctx aad pt with
| None -> None
| Some (_, ct) -> Some (enc, ct)
#restart-solver
let openPSK cs enc skR info aad ct psk psk_id =
match setupPSKR cs enc skR info psk psk_id with
| None -> None
| Some ctx ->
match context_open cs ctx aad ct with
| None -> None
| Some (_, pt) -> Some pt
let sendExportPSK cs skE pkR info exp_ctx l psk psk_id =
match setupPSKS cs skE pkR info psk psk_id with
| None -> None
| Some (enc, ctx) ->
Some (enc, context_export cs ctx exp_ctx l)
let receiveExportPSK cs enc skR info exp_ctx l psk psk_id =
match setupPSKR cs enc skR info psk psk_id with
| None -> None
| Some ctx ->
Some (context_export cs ctx exp_ctx l)
///
/// Auth mode
///
let setupAuthS cs skE pkR info skS =
match auth_encap cs skE pkR skS with
| None -> None
| Some (shared_secret, enc) ->
let enc_ctx = key_schedule cs Auth shared_secret info None in
Some (enc, enc_ctx)
let setupAuthR cs enc skR info pkS =
let pkR = DH.secret_to_public (kem_dh_of_cs cs) skR in
let shared_secret = auth_decap cs enc skR pkS in
match pkR, shared_secret with
| Some pkR, Some shared_secret ->
Some (key_schedule cs Auth shared_secret info None)
| _ -> None
let sealAuth cs skE pkR info aad pt skS =
match setupAuthS cs skE pkR info skS with
| None -> None
| Some (enc, ctx) ->
match context_seal cs ctx aad pt with
| None -> None
| Some (_, ct) -> Some (enc, ct) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HMAC.fsti.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Spec.Agile.HPKE.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 500,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
cs: Spec.Agile.HPKE.ciphersuite_not_export_only ->
enc: Spec.Agile.HPKE.key_dh_public_s cs ->
skR: Spec.Agile.HPKE.key_dh_secret_s cs ->
info: Spec.Agile.HPKE.info_s cs ->
aad: Spec.Agile.AEAD.ad (Spec.Agile.HPKE.aead_alg_of cs) ->
ct: Spec.Agile.AEAD.cipher (Spec.Agile.HPKE.aead_alg_of cs) ->
pkS: Spec.Agile.DH.serialized_point (Spec.Agile.HPKE.kem_dh_of_cs cs)
-> FStar.Pervasives.Native.option (Spec.Agile.AEAD.decrypted ct) | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.ciphersuite_not_export_only",
"Spec.Agile.HPKE.key_dh_public_s",
"Spec.Agile.HPKE.key_dh_secret_s",
"Spec.Agile.HPKE.info_s",
"Spec.Agile.AEAD.ad",
"Spec.Agile.HPKE.aead_alg_of",
"Spec.Agile.AEAD.cipher",
"Spec.Agile.DH.serialized_point",
"Spec.Agile.HPKE.kem_dh_of_cs",
"Spec.Agile.HPKE.setupAuthR",
"FStar.Pervasives.Native.None",
"Spec.Agile.AEAD.decrypted",
"Spec.Agile.HPKE.encryption_context",
"Spec.Agile.HPKE.context_open",
"Spec.Agile.AEAD.plain",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | false | false | let openAuth cs enc skR info aad ct pkS =
| match setupAuthR cs enc skR info pkS with
| None -> None
| Some ctx ->
match context_open cs ctx aad ct with
| None -> None
| Some (_, pt) -> Some pt | false |
Spec.SHA3.Constants.fst | Spec.SHA3.Constants.piln_list | val piln_list:list piln_t | val piln_list:list piln_t | let piln_list: list piln_t =
[10ul; 7ul; 11ul; 17ul; 18ul; 3ul; 5ul; 16ul;
8ul; 21ul; 24ul; 4ul; 15ul; 23ul; 19ul; 13ul;
12ul; 2ul; 20ul; 14ul; 22ul; 9ul; 6ul; 1ul] | {
"file_name": "specs/Spec.SHA3.Constants.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 46,
"end_line": 24,
"start_col": 7,
"start_line": 21
} | module Spec.SHA3.Constants
open Lib.IntTypes
open Lib.Sequence
#reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
let rotc_t = rotval U64
unfold let rotc_list: list rotc_t =
[1ul; 3ul; 6ul; 10ul; 15ul; 21ul; 28ul; 36ul;
45ul; 55ul; 2ul; 14ul; 27ul; 41ul; 56ul; 8ul;
25ul; 43ul; 62ul; 18ul; 39ul; 61ul; 20ul; 44ul]
let keccak_rotc:lseq rotc_t 24 =
assert_norm (List.Tot.length rotc_list == 24);
of_list rotc_list
let piln_t = x:size_t{size_v x < 25} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.SHA3.Constants.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA3",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA3",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.list Spec.SHA3.Constants.piln_t | Prims.Tot | [
"total"
] | [] | [
"Prims.Cons",
"Spec.SHA3.Constants.piln_t",
"FStar.UInt32.__uint_to_t",
"Prims.Nil"
] | [] | false | false | false | true | false | let piln_list:list piln_t =
| [
10ul; 7ul; 11ul; 17ul; 18ul; 3ul; 5ul; 16ul; 8ul; 21ul; 24ul; 4ul; 15ul; 23ul; 19ul; 13ul; 12ul;
2ul; 20ul; 14ul; 22ul; 9ul; 6ul; 1ul
] | false |
Spec.Agile.HPKE.fst | Spec.Agile.HPKE.openPSK | val openPSK:
cs:ciphersuite_not_export_only
-> enc:key_dh_public_s cs
-> skR:key_dh_secret_s cs
-> info:info_s cs
-> aad:AEAD.ad (aead_alg_of cs)
-> ct:AEAD.cipher (aead_alg_of cs)
-> psk:psk_s cs
-> psk_id:psk_id_s cs ->
Tot (option (AEAD.decrypted #(aead_alg_of cs) ct)) | val openPSK:
cs:ciphersuite_not_export_only
-> enc:key_dh_public_s cs
-> skR:key_dh_secret_s cs
-> info:info_s cs
-> aad:AEAD.ad (aead_alg_of cs)
-> ct:AEAD.cipher (aead_alg_of cs)
-> psk:psk_s cs
-> psk_id:psk_id_s cs ->
Tot (option (AEAD.decrypted #(aead_alg_of cs) ct)) | let openPSK cs enc skR info aad ct psk psk_id =
match setupPSKR cs enc skR info psk psk_id with
| None -> None
| Some ctx ->
match context_open cs ctx aad ct with
| None -> None
| Some (_, pt) -> Some pt | {
"file_name": "specs/Spec.Agile.HPKE.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 29,
"end_line": 525,
"start_col": 0,
"start_line": 519
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
let pow2_61 : _:unit{pow2 61 == 2305843009213693952} = assert_norm(pow2 61 == 2305843009213693952)
let pow2_35_less_than_pow2_61 : _:unit{pow2 32 * pow2 3 <= pow2 61 - 1} = assert_norm(pow2 32 * pow2 3 <= pow2 61 - 1)
let pow2_35_less_than_pow2_125 : _:unit{pow2 32 * pow2 3 <= pow2 125 - 1} = assert_norm(pow2 32 * pow2 3 <= pow2 125 - 1)
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
/// Types
val id_kem: cs:ciphersuite -> Tot (lbytes 2)
let id_kem cs = let kem_dh, kem_hash, _, _ = cs in
match kem_dh, kem_hash with
| DH.DH_P256, Hash.SHA2_256 -> create 1 (u8 0) @| create 1 (u8 16)
| DH.DH_Curve25519, Hash.SHA2_256 -> create 1 (u8 0) @| create 1 (u8 32)
val id_kdf: cs:ciphersuite -> Tot (lbytes 2)
let id_kdf cs = let _, _, _, h = cs in
match h with
| Hash.SHA2_256 -> create 1 (u8 0) @| create 1 (u8 1)
| Hash.SHA2_384 -> create 1 (u8 0) @| create 1 (u8 2)
| Hash.SHA2_512 -> create 1 (u8 0) @| create 1 (u8 3)
val id_aead: cs:ciphersuite -> Tot (lbytes 2)
let id_aead cs = let _, _, a, _ = cs in
match a with
| Seal AEAD.AES128_GCM -> create 1 (u8 0) @| create 1 (u8 1)
| Seal AEAD.AES256_GCM -> create 1 (u8 0) @| create 1 (u8 2)
| Seal AEAD.CHACHA20_POLY1305 -> create 1 (u8 0) @| create 1 (u8 3)
| ExportOnly -> create 1 (u8 255) @| create 1 (u8 255)
val suite_id_kem: cs:ciphersuite -> Tot (lbytes size_suite_id_kem)
let suite_id_kem cs =
Seq.append label_KEM (id_kem cs)
val suite_id_hpke: cs:ciphersuite -> Tot (lbytes size_suite_id_hpke)
let suite_id_hpke cs =
Seq.append label_HPKE (id_kem cs @| id_kdf cs @| id_aead cs)
val id_of_mode: m:mode -> Tot (lbytes size_mode_identifier)
let id_of_mode m =
match m with
| Base -> create 1 (u8 0)
| PSK -> create 1 (u8 1)
| Auth -> create 1 (u8 2)
| AuthPSK -> create 1 (u8 3)
val labeled_extract:
a:hash_algorithm
-> suite_id:bytes
-> salt:bytes
-> label:bytes
-> ikm:bytes ->
Pure (lbytes (Spec.Hash.Definitions.hash_length a))
(requires
Spec.Agile.HMAC.keysized a (Seq.length salt) /\
labeled_extract_ikm_length_pred a (Seq.length suite_id + Seq.length label + Seq.length ikm))
(ensures fun _ -> True)
let labeled_extract a suite_id salt label ikm =
let labeled_ikm1 = Seq.append label_version suite_id in
let labeled_ikm2 = Seq.append labeled_ikm1 label in
let labeled_ikm3 = Seq.append labeled_ikm2 ikm in
HKDF.extract a salt labeled_ikm3
val labeled_expand:
a:hash_algorithm
-> suite_id:bytes
-> prk:bytes
-> label:bytes
-> info:bytes
-> l:size_nat ->
Pure (lbytes l)
(requires
Spec.Hash.Definitions.hash_length a <= Seq.length prk /\
Spec.Agile.HMAC.keysized a (Seq.length prk) /\
labeled_expand_info_length_pred a (Seq.length suite_id + Seq.length label + Seq.length info) /\
HKDF.expand_output_length_pred a l)
(ensures fun _ -> True)
let labeled_expand a suite_id prk label info l =
let labeled_info1 = nat_to_bytes_be 2 l in
let labeled_info2 = Seq.append labeled_info1 label_version in
let labeled_info3 = Seq.append labeled_info2 suite_id in
let labeled_info4 = Seq.append labeled_info3 label in
let labeled_info5 = Seq.append labeled_info4 info in
HKDF.expand a prk labeled_info5 l
let extract_and_expand_dh_pred (cs:ciphersuite) (dh_length:nat) =
labeled_extract_ikm_length_pred (kem_hash_of_cs cs) (size_suite_id_kem + size_label_eae_prk + dh_length)
let extract_and_expand_ctx_pred (cs:ciphersuite) (ctx_length:nat) =
labeled_expand_info_length_pred (kem_hash_of_cs cs) (size_suite_id_kem + size_label_shared_secret + ctx_length)
val extract_and_expand:
cs:ciphersuite
-> dh:bytes
-> kem_context:bytes ->
Pure (key_kem_s cs)
(requires
extract_and_expand_dh_pred cs (Seq.length dh) /\
extract_and_expand_ctx_pred cs (Seq.length kem_context))
(ensures fun _ -> True)
let extract_and_expand cs dh kem_context =
let eae_prk = labeled_extract (kem_hash_of_cs cs) (suite_id_kem cs) lbytes_empty label_eae_prk dh in
labeled_expand (kem_hash_of_cs cs) (suite_id_kem cs) eae_prk label_shared_secret kem_context (size_kem_key cs)
let deserialize_public_key cs pk = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> pk
// Extract the point coordinates by removing the first representation byte
| DH.DH_P256 -> sub pk 1 64
let serialize_public_key cs pk = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> pk
// Add the first representation byte to the point coordinates
| DH.DH_P256 -> create 1 (u8 4) @| pk
val dkp_nist_p: cs:ciphersuite -> lbytes (size_kem_kdf cs) -> counter:uint8 -> Tot (option (key_dh_secret_s cs & key_dh_public_s cs)) (decreases 255 - v counter)
let rec dkp_nist_p cs dkp_prk counter =
let counterbyte = nat_to_intseq_be #U8 #SEC 1 (v counter) in
let bytes = labeled_expand (kem_hash_of_cs cs) (suite_id_kem cs) dkp_prk label_candidate counterbyte (size_dh_key cs) in
let bytes = Lib.Sequence.map2 (logand #U8 #SEC) bytes (Seq.create (size_dh_key cs) (u8 255)) in
let sk = nat_from_intseq_be #U8 #SEC bytes in
if sk = 0 || sk >= Spec.P256.prime then
if (v counter) = 255 then None
else dkp_nist_p cs dkp_prk (counter +! (u8 1))
else
match DH.secret_to_public (kem_dh_of_cs cs) bytes with
| Some pk -> Some (bytes, serialize_public_key cs pk)
| None ->
if (v counter) = 255 then None
else dkp_nist_p cs dkp_prk (counter +! (u8 1))
let derive_key_pair cs ikm =
match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> begin
let dkp_prk = labeled_extract (kem_hash_of_cs cs) (suite_id_kem cs) lbytes_empty label_dkp_prk ikm in
let sk = labeled_expand (kem_hash_of_cs cs) (suite_id_kem cs) dkp_prk label_sk lbytes_empty (size_dh_key cs) in
match DH.secret_to_public (kem_dh_of_cs cs) sk with
| Some pk -> Some (sk, serialize_public_key cs pk)
end
| DH.DH_P256 ->
let dkp_prk = labeled_extract (kem_hash_of_cs cs) (suite_id_kem cs) lbytes_empty label_dkp_prk ikm in
dkp_nist_p cs dkp_prk (u8 0)
val prepare_dh: cs:ciphersuite -> DH.serialized_point (kem_dh_of_cs cs) -> Tot (lbytes 32)
let prepare_dh cs dh = match (kem_dh_of_cs cs) with
| DH.DH_Curve25519 -> serialize_public_key cs dh
| DH.DH_P256 -> sub dh 0 32
val encap:
cs:ciphersuite
-> skE:key_dh_secret_s cs
-> pkR:DH.serialized_point (kem_dh_of_cs cs) ->
Tot (option (key_kem_s cs & key_dh_public_s cs))
#restart-solver
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
let encap cs skE pkR =
let _ = allow_inversion Spec.Agile.DH.algorithm in
match DH.secret_to_public (kem_dh_of_cs cs) skE with
| None -> None
| Some pkE ->
let enc = serialize_public_key cs pkE in
match DH.dh (kem_dh_of_cs cs) skE pkR with
| None -> None
| Some dh ->
let pkRm = serialize_public_key cs pkR in
let kem_context = concat enc pkRm in
let dhm = prepare_dh cs dh in
assert (Seq.length kem_context = 2*size_dh_public cs);
assert (extract_and_expand_ctx_pred cs (Seq.length kem_context));
let shared_secret:key_kem_s cs = extract_and_expand cs dhm kem_context in
Some (shared_secret, enc)
val decap:
cs: ciphersuite
-> enc: key_dh_public_s cs
-> skR: key_dh_secret_s cs ->
Tot (option (key_kem_s cs))
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
let decap cs enc skR =
let _ = allow_inversion Spec.Agile.DH.algorithm in
let _ = allow_inversion Spec.Agile.Hash.hash_alg in
let pkE = deserialize_public_key cs enc in
match DH.dh (kem_dh_of_cs cs) skR pkE with
| None -> None
| Some dh ->
match DH.secret_to_public (kem_dh_of_cs cs) skR with
| None -> None
| Some pkR ->
let pkRm = serialize_public_key cs pkR in
let kem_context = concat enc pkRm in
let dhm = prepare_dh cs dh in
assert (Seq.length kem_context = 2*size_dh_public cs);
assert (extract_and_expand_ctx_pred cs (Seq.length kem_context));
let shared_secret = extract_and_expand cs dhm kem_context in
Some (shared_secret)
val auth_encap:
cs:ciphersuite
-> skE:key_dh_secret_s cs
-> pkR:DH.serialized_point (kem_dh_of_cs cs)
-> skS:key_dh_secret_s cs ->
Tot (option (key_kem_s cs & key_dh_public_s cs))
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
let auth_encap cs skE pkR skS =
let _ = allow_inversion Spec.Agile.DH.algorithm in
match DH.secret_to_public (kem_dh_of_cs cs) skE with
| None -> None
| Some pkE ->
match DH.dh (kem_dh_of_cs cs) skE pkR with
| None -> None
| Some es ->
match DH.dh (kem_dh_of_cs cs) skS pkR with
| None -> None
| Some ss ->
let esm = prepare_dh cs es in
let ssm = prepare_dh cs ss in
// TODO Do not put 32 literally
let dh = concat #uint8 #32 #32 esm ssm in
let enc = serialize_public_key cs pkE in
match DH.secret_to_public (kem_dh_of_cs cs) skS with
| None -> None
| Some pkS ->
let pkSm = serialize_public_key cs pkS in
let pkRm = serialize_public_key cs pkR in
let kem_context = concat enc (concat pkRm pkSm) in
assert (Seq.length kem_context = 3*size_dh_public cs);
assert (labeled_expand_info_length_pred (kem_hash_of_cs cs) (size_suite_id_kem + size_label_shared_secret + Seq.length kem_context));
assert (extract_and_expand_ctx_pred cs (Seq.length kem_context));
// TODO Do not put 64 literally
assert (Seq.length dh = 64);
assert (labeled_extract_ikm_length_pred (kem_hash_of_cs cs) (size_suite_id_kem + size_label_eae_prk + Seq.length dh));
assert (extract_and_expand_dh_pred cs (Seq.length dh));
let shared_secret = extract_and_expand cs dh kem_context in
Some (shared_secret, enc)
#reset-options
val auth_decap:
cs: ciphersuite
-> enc: key_dh_public_s cs
-> skR: key_dh_secret_s cs
-> pkS: DH.serialized_point (kem_dh_of_cs cs) ->
Tot (option (key_kem_s cs))
#restart-solver
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
let auth_decap cs enc skR pkS =
let _ = allow_inversion Spec.Agile.DH.algorithm in
let pkE = deserialize_public_key cs enc in
match DH.dh (kem_dh_of_cs cs) skR pkE with
| None -> None
| Some es ->
match DH.dh (kem_dh_of_cs cs) skR pkS with
| None -> None
| Some ss ->
let esm = prepare_dh cs es in
let ssm = prepare_dh cs ss in
let dh = concat #uint8 #32 #32 esm ssm in
match DH.secret_to_public (kem_dh_of_cs cs) skR with
| None -> None
| Some pkR ->
let pkRm = serialize_public_key cs pkR in
let pkSm = serialize_public_key cs pkS in
let kem_context = concat enc (concat pkRm pkSm) in
assert (Seq.length kem_context = 3*size_dh_public cs);
assert (labeled_expand_info_length_pred (kem_hash_of_cs cs) (size_suite_id_kem + size_label_shared_secret + Seq.length kem_context));
assert (extract_and_expand_ctx_pred cs (Seq.length kem_context));
assert (Seq.length dh = 64);
assert (labeled_extract_ikm_length_pred (kem_hash_of_cs cs) (size_suite_id_kem + size_label_eae_prk + Seq.length dh));
assert (extract_and_expand_dh_pred cs (Seq.length dh));
let shared_secret = extract_and_expand cs dh kem_context in
Some (shared_secret)
#reset-options
let default_psk = lbytes_empty
let default_psk_id = lbytes_empty
val build_context:
cs:ciphersuite
-> m:mode
-> psk_id_hash:lbytes (size_kdf cs)
-> info_hash:lbytes (size_kdf cs) ->
Tot (lbytes (size_ks_ctx cs))
let build_context cs m psk_id_hash info_hash =
let context = id_of_mode m in
let context = Seq.append context psk_id_hash in
let context = Seq.append context info_hash in
context
let verify_psk_inputs (cs:ciphersuite) (m:mode) (opsk:option(psk_s cs & psk_id_s cs)) : bool =
match (m, opsk) with
| Base, None -> true
| PSK, Some _ -> true
| Auth, None -> true
| AuthPSK, Some _ -> true
| _, _ -> false
// key and nonce are zero-length if AEAD is Export-Only
let encryption_context (cs:ciphersuite) = key_aead_s cs & nonce_aead_s cs & seq_aead_s cs & exporter_secret_s cs
val key_schedule:
cs:ciphersuite
-> m:mode
-> shared_secret:key_kem_s cs
-> info:info_s cs
-> opsk:option (psk_s cs & psk_id_s cs) ->
Pure (encryption_context cs)
(requires verify_psk_inputs cs m opsk)
(ensures fun _ -> True)
#set-options "--z3rlimit 500 --fuel 0 --ifuel 2"
let key_schedule_core
(cs:ciphersuite)
(m:mode)
(shared_secret:key_kem_s cs)
(info:info_s cs)
(opsk:option (psk_s cs & psk_id_s cs))
: (lbytes (size_ks_ctx cs) & exporter_secret_s cs & (lbytes (Spec.Hash.Definitions.hash_length (hash_of_cs cs)))) =
let (psk, psk_id) =
match opsk with
| None -> (default_psk, default_psk_id)
| Some (psk, psk_id) -> (psk, psk_id)
in
let psk_id_hash = labeled_extract (hash_of_cs cs) (suite_id_hpke cs) lbytes_empty label_psk_id_hash psk_id in
let info_hash = labeled_extract (hash_of_cs cs) (suite_id_hpke cs) lbytes_empty label_info_hash info in
let context = build_context cs m psk_id_hash info_hash in
let secret = labeled_extract (hash_of_cs cs) (suite_id_hpke cs) shared_secret label_secret psk in
let exporter_secret = labeled_expand (hash_of_cs cs) (suite_id_hpke cs) secret label_exp context (size_kdf cs) in
context, exporter_secret, secret
let key_schedule_end
(cs:ciphersuite)
(m:mode)
(context:lbytes (size_ks_ctx cs))
(exporter_secret:exporter_secret_s cs)
(secret:(lbytes (Spec.Hash.Definitions.hash_length (hash_of_cs cs))))
: encryption_context cs
=
if is_valid_not_export_only_ciphersuite cs then (
let key = labeled_expand (hash_of_cs cs) (suite_id_hpke cs) secret label_key context (size_aead_key cs) in
let base_nonce = labeled_expand (hash_of_cs cs) (suite_id_hpke cs) secret label_base_nonce context (size_aead_nonce cs) in
(key, base_nonce, 0, exporter_secret)
) else (
(* if AEAD is Export-Only, then skip computation of key and base_nonce *)
assert (size_aead_key cs = 0);
assert (size_aead_nonce cs = 0);
(lbytes_empty, lbytes_empty, 0, exporter_secret))
let key_schedule cs m shared_secret info opsk =
let context, exporter_secret, secret = key_schedule_core cs m shared_secret info opsk in
key_schedule_end cs m context exporter_secret secret
let key_of_ctx (cs:ciphersuite) (ctx:encryption_context cs) =
let key, _, _, _ = ctx in key
let base_nonce_of_ctx (cs:ciphersuite) (ctx:encryption_context cs) =
let _, base_nonce, _, _ = ctx in base_nonce
let seq_of_ctx (cs:ciphersuite) (ctx:encryption_context cs) =
let _, _, seq, _ = ctx in seq
let exp_sec_of_ctx (cs:ciphersuite) (ctx:encryption_context cs) =
let _, _, _, exp_sec = ctx in exp_sec
let set_seq (cs:ciphersuite) (ctx:encryption_context cs) (seq:seq_aead_s cs) =
let key, base_nonce, _, exp_sec = ctx in
(key, base_nonce, seq, exp_sec)
///
/// Encryption Context
///
let context_export cs ctx exp_ctx l =
let exp_sec = exp_sec_of_ctx cs ctx in
labeled_expand (hash_of_cs cs) (suite_id_hpke cs) exp_sec label_sec exp_ctx l
let context_compute_nonce cs ctx seq =
let base_nonce = base_nonce_of_ctx cs ctx in
let enc_seq = nat_to_bytes_be (size_aead_nonce cs) seq in
Spec.Loops.seq_map2 logxor enc_seq base_nonce
let context_increment_seq cs ctx =
let seq = seq_of_ctx cs ctx in
if seq = max_seq cs then None else
Some (set_seq cs ctx (seq + 1))
let context_seal cs ctx aad pt =
let key = key_of_ctx cs ctx in
let seq = seq_of_ctx cs ctx in
let nonce = context_compute_nonce cs ctx seq in
let ct = AEAD.encrypt key nonce aad pt in
match context_increment_seq cs ctx with
| None -> None
| Some new_ctx -> Some (new_ctx, ct)
let context_open cs ctx aad ct =
let key = key_of_ctx cs ctx in
let seq = seq_of_ctx cs ctx in
let nonce = context_compute_nonce cs ctx seq in
match AEAD.decrypt key nonce aad ct with
| None -> None
| Some pt ->
match context_increment_seq cs ctx with
| None -> None
| Some new_ctx -> Some (new_ctx, pt)
///
/// Base Mode
///
let setupBaseS cs skE pkR info =
match encap cs skE pkR with
| None -> None
| Some (shared_secret, enc) ->
let enc_ctx = key_schedule cs Base shared_secret info None in
Some (enc, enc_ctx)
let setupBaseR cs enc skR info =
let pkR = DH.secret_to_public (kem_dh_of_cs cs) skR in
let shared_secret = decap cs enc skR in
match pkR, shared_secret with
| Some pkR, Some shared_secret ->
Some (key_schedule cs Base shared_secret info None)
| _ -> None
let sealBase cs skE pkR info aad pt =
match setupBaseS cs skE pkR info with
| None -> None
| Some (enc, ctx) ->
match context_seal cs ctx aad pt with
| None -> None
| Some (_, ct) -> Some (enc, ct)
let openBase cs enc skR info aad ct =
match setupBaseR cs enc skR info with
| None -> None
| Some ctx ->
match context_open cs ctx aad ct with
| None -> None
| Some (_, pt) -> Some pt
let sendExportBase cs skE pkR info exp_ctx l =
match setupBaseS cs skE pkR info with
| None -> None
| Some (enc, ctx) ->
Some (enc, context_export cs ctx exp_ctx l)
let receiveExportBase cs enc skR info exp_ctx l =
match setupBaseR cs enc skR info with
| None -> None
| Some ctx ->
Some (context_export cs ctx exp_ctx l)
///
/// PSK mode
///
let setupPSKS cs skE pkR info psk psk_id =
match encap cs skE pkR with
| None -> None
| Some (shared_secret, enc) ->
assert (verify_psk_inputs cs PSK (Some (psk, psk_id)));
let enc_ctx = key_schedule cs PSK shared_secret info (Some (psk, psk_id)) in
Some (enc, enc_ctx)
let setupPSKR cs enc skR info psk psk_id =
let pkR = DH.secret_to_public (kem_dh_of_cs cs) skR in
let shared_secret = decap cs enc skR in
match pkR, shared_secret with
| Some pkR, Some shared_secret ->
Some (key_schedule cs PSK shared_secret info (Some (psk, psk_id)))
| _ -> None
let sealPSK cs skE pkR info aad pt psk psk_id =
match setupPSKS cs skE pkR info psk psk_id with
| None -> None
| Some (enc, ctx) ->
match context_seal cs ctx aad pt with
| None -> None
| Some (_, ct) -> Some (enc, ct) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HMAC.fsti.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Spec.Agile.HPKE.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 500,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
cs: Spec.Agile.HPKE.ciphersuite_not_export_only ->
enc: Spec.Agile.HPKE.key_dh_public_s cs ->
skR: Spec.Agile.HPKE.key_dh_secret_s cs ->
info: Spec.Agile.HPKE.info_s cs ->
aad: Spec.Agile.AEAD.ad (Spec.Agile.HPKE.aead_alg_of cs) ->
ct: Spec.Agile.AEAD.cipher (Spec.Agile.HPKE.aead_alg_of cs) ->
psk: Spec.Agile.HPKE.psk_s cs ->
psk_id: Spec.Agile.HPKE.psk_id_s cs
-> FStar.Pervasives.Native.option (Spec.Agile.AEAD.decrypted ct) | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.ciphersuite_not_export_only",
"Spec.Agile.HPKE.key_dh_public_s",
"Spec.Agile.HPKE.key_dh_secret_s",
"Spec.Agile.HPKE.info_s",
"Spec.Agile.AEAD.ad",
"Spec.Agile.HPKE.aead_alg_of",
"Spec.Agile.AEAD.cipher",
"Spec.Agile.HPKE.psk_s",
"Spec.Agile.HPKE.psk_id_s",
"Spec.Agile.HPKE.setupPSKR",
"FStar.Pervasives.Native.None",
"Spec.Agile.AEAD.decrypted",
"Spec.Agile.HPKE.encryption_context",
"Spec.Agile.HPKE.context_open",
"Spec.Agile.AEAD.plain",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | false | false | let openPSK cs enc skR info aad ct psk psk_id =
| match setupPSKR cs enc skR info psk psk_id with
| None -> None
| Some ctx ->
match context_open cs ctx aad ct with
| None -> None
| Some (_, pt) -> Some pt | false |
Spec.SHA1.fst | Spec.SHA1.step3_body' | val step3_body' : mi: Spec.SHA1.word_block ->
st: Spec.Hash.Definitions.words_state Spec.Hash.Definitions.SHA1 ->
t: Lib.IntTypes.size_t{Lib.IntTypes.v t < 80} ->
wt: Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA1 {wt == Spec.SHA1.w mi t}
-> Spec.Hash.Definitions.words_state Spec.Hash.Definitions.SHA1 | let step3_body' = step3_body'_aux | {
"file_name": "specs/Spec.SHA1.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 33,
"end_line": 171,
"start_col": 0,
"start_line": 171
} | module Spec.SHA1
open Lib.IntTypes
module H = Spec.Hash.Definitions
module Seq = FStar.Seq
open Spec.Hash.Definitions
(* Source: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf *)
(* Section 5.3.1 *)
inline_for_extraction
let init_as_list : list uint32 = [
u32 0x67452301;
u32 0xefcdab89;
u32 0x98badcfe;
u32 0x10325476;
u32 0xc3d2e1f0;
]
let init : words_state SHA1 = Seq.seq_of_list init_as_list
(* Section 6.1.2 Step 1: message schedule *)
let rec w' (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: nat {t <= 79}) : GTot (word SHA1) (decreases (t)) =
if t < 16
then Seq.index mi (t)
else (w' mi (t - 3) ^. w' mi (t - 8) ^. w' mi (t - 14) ^. w' mi (t - 16)) <<<. 1ul
let w (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: size_t {v t <= 79}) : GTot (word SHA1) = w' mi (v t)
let compute_w_post
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
: GTot Type0
= (n <= 80 /\ (
forall (i: nat) . i < n ==> Seq.index res i == w' mi i
))
let compute_w_post_intro
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
(u: squash (n <= 80))
(f: (i: nat) -> Lemma
(requires (i < n))
(ensures (i < n /\ Seq.index res i == w' mi i)))
: Lemma
(compute_w_post mi n res)
= Classical.forall_intro (Classical.move_requires f)
inline_for_extraction
let compute_w_n'
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(w: ((i: nat {i < n}) -> Tot (y: word SHA1 {y == w' mi i})))
: Tot (y: word SHA1 {y == w' mi n})
= let r =
if n < 16
then Seq.index mi n
else (w (n - 3) ^. w (n - 8) ^. w (n - 14) ^. w (n - 16)) <<<. 1ul
in
r
inline_for_extraction
let compute_w_n
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(accu: Seq.lseq (word SHA1) n)
: Pure (word SHA1)
(requires (compute_w_post mi n accu))
(ensures (fun y -> n <= 79 /\ y == w' mi n))
= [@inline_let]
let w (i: nat {i < n}) : Tot (y: word SHA1 {y == w' mi i}) = Seq.index accu i in
compute_w_n' mi n w
inline_for_extraction
let compute_w_next
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) (n + 1))
(requires (compute_w_post mi n accu))
(ensures (fun accu' -> compute_w_post mi (n + 1) accu'))
= let wn = compute_w_n mi n accu in
let accu' = Seq.snoc accu wn in
assert (n + 1 <= 80);
let g
(i: nat)
: Lemma
(requires (i < n + 1))
(ensures (i < n + 1 /\ Seq.index accu' i == w' mi i))
= if i = n
then ()
else ()
in
compute_w_post_intro mi (n + 1) accu' () g;
accu'
let rec compute_w
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) 80)
(requires (compute_w_post mi n accu))
(ensures (fun res -> compute_w_post mi 80 res))
(decreases (80 - n))
= assert (n <= 80); // this assert is necessary for Z3 to prove that n <= 79 in the else branch
if n = 80
then accu
else compute_w mi (n + 1) (compute_w_next mi n accu)
(* Section 4.1.1: logical functions *)
inline_for_extraction
let f (t: size_t {v t <= 79}) (x y z: word SHA1) : Tot (word SHA1) =
if t <. 20ul
then
(x &. y) ^. (~. x &. z)
else if 39ul <. t && t <. 60ul
then
(x &. y) ^. (x &. z) ^. (y &. z)
else
x ^. y ^. z
(* Section 4.2.1 *)
inline_for_extraction
let k (t: size_t { v t <= 79 } ) : Tot (word SHA1) =
if t <. 20ul
then u32 0x5a827999
else if t <. 40ul
then u32 0x6ed9eba1
else if t <. 60ul
then u32 0x8f1bbcdc
else u32 0xca62c1d6
(* Section 6.1.2 Step 3 *)
let word_block = Seq.lseq (word SHA1) (block_word_length SHA1)
let step3_body'_aux
(mi: word_block)
(st: words_state SHA1)
(t: size_t {v t < 80})
(wt: word SHA1 { wt == w mi t } )
: Tot (words_state SHA1)
= let sta = Seq.index st 0 in
let stb = Seq.index st 1 in
let stc = Seq.index st 2 in
let std = Seq.index st 3 in
let ste = Seq.index st 4 in
let _T = (sta <<<. 5ul) +. f t stb stc std +. ste +. k t +. wt in
let e = std in
let d = stc in
let c = stb <<<. 30ul in
let b = sta in
let a = _T in
let l : list uint32 = [
a;
b;
c;
d;
e;
] in
assert_norm (List.Tot.length l = 5);
Seq.seq_of_list l | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Spec.SHA1.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "Spec.Hash.Definitions",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
mi: Spec.SHA1.word_block ->
st: Spec.Hash.Definitions.words_state Spec.Hash.Definitions.SHA1 ->
t: Lib.IntTypes.size_t{Lib.IntTypes.v t < 80} ->
wt: Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA1 {wt == Spec.SHA1.w mi t}
-> Spec.Hash.Definitions.words_state Spec.Hash.Definitions.SHA1 | Prims.Tot | [
"total"
] | [] | [
"Spec.SHA1.step3_body'_aux"
] | [] | false | false | false | false | false | let step3_body' =
| step3_body'_aux | false |
|
Spec.SHA1.fst | Spec.SHA1.f | val f (t: size_t{v t <= 79}) (x y z: word SHA1) : Tot (word SHA1) | val f (t: size_t{v t <= 79}) (x y z: word SHA1) : Tot (word SHA1) | let f (t: size_t {v t <= 79}) (x y z: word SHA1) : Tot (word SHA1) =
if t <. 20ul
then
(x &. y) ^. (~. x &. z)
else if 39ul <. t && t <. 60ul
then
(x &. y) ^. (x &. z) ^. (y &. z)
else
x ^. y ^. z | {
"file_name": "specs/Spec.SHA1.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 15,
"end_line": 125,
"start_col": 0,
"start_line": 117
} | module Spec.SHA1
open Lib.IntTypes
module H = Spec.Hash.Definitions
module Seq = FStar.Seq
open Spec.Hash.Definitions
(* Source: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf *)
(* Section 5.3.1 *)
inline_for_extraction
let init_as_list : list uint32 = [
u32 0x67452301;
u32 0xefcdab89;
u32 0x98badcfe;
u32 0x10325476;
u32 0xc3d2e1f0;
]
let init : words_state SHA1 = Seq.seq_of_list init_as_list
(* Section 6.1.2 Step 1: message schedule *)
let rec w' (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: nat {t <= 79}) : GTot (word SHA1) (decreases (t)) =
if t < 16
then Seq.index mi (t)
else (w' mi (t - 3) ^. w' mi (t - 8) ^. w' mi (t - 14) ^. w' mi (t - 16)) <<<. 1ul
let w (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: size_t {v t <= 79}) : GTot (word SHA1) = w' mi (v t)
let compute_w_post
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
: GTot Type0
= (n <= 80 /\ (
forall (i: nat) . i < n ==> Seq.index res i == w' mi i
))
let compute_w_post_intro
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
(u: squash (n <= 80))
(f: (i: nat) -> Lemma
(requires (i < n))
(ensures (i < n /\ Seq.index res i == w' mi i)))
: Lemma
(compute_w_post mi n res)
= Classical.forall_intro (Classical.move_requires f)
inline_for_extraction
let compute_w_n'
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(w: ((i: nat {i < n}) -> Tot (y: word SHA1 {y == w' mi i})))
: Tot (y: word SHA1 {y == w' mi n})
= let r =
if n < 16
then Seq.index mi n
else (w (n - 3) ^. w (n - 8) ^. w (n - 14) ^. w (n - 16)) <<<. 1ul
in
r
inline_for_extraction
let compute_w_n
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(accu: Seq.lseq (word SHA1) n)
: Pure (word SHA1)
(requires (compute_w_post mi n accu))
(ensures (fun y -> n <= 79 /\ y == w' mi n))
= [@inline_let]
let w (i: nat {i < n}) : Tot (y: word SHA1 {y == w' mi i}) = Seq.index accu i in
compute_w_n' mi n w
inline_for_extraction
let compute_w_next
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) (n + 1))
(requires (compute_w_post mi n accu))
(ensures (fun accu' -> compute_w_post mi (n + 1) accu'))
= let wn = compute_w_n mi n accu in
let accu' = Seq.snoc accu wn in
assert (n + 1 <= 80);
let g
(i: nat)
: Lemma
(requires (i < n + 1))
(ensures (i < n + 1 /\ Seq.index accu' i == w' mi i))
= if i = n
then ()
else ()
in
compute_w_post_intro mi (n + 1) accu' () g;
accu'
let rec compute_w
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) 80)
(requires (compute_w_post mi n accu))
(ensures (fun res -> compute_w_post mi 80 res))
(decreases (80 - n))
= assert (n <= 80); // this assert is necessary for Z3 to prove that n <= 79 in the else branch
if n = 80
then accu
else compute_w mi (n + 1) (compute_w_next mi n accu)
(* Section 4.1.1: logical functions *) | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Spec.SHA1.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "Spec.Hash.Definitions",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
t: Lib.IntTypes.size_t{Lib.IntTypes.v t <= 79} ->
x: Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA1 ->
y: Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA1 ->
z: Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA1
-> Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA1 | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.SHA1",
"Lib.IntTypes.op_Less_Dot",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.op_Hat_Dot",
"Spec.Hash.Definitions.word_t",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Amp_Dot",
"Lib.IntTypes.op_Tilde_Dot",
"Prims.bool",
"Prims.op_AmpAmp"
] | [] | false | false | false | false | false | let f (t: size_t{v t <= 79}) (x y z: word SHA1) : Tot (word SHA1) =
| if t <. 20ul
then (x &. y) ^. (~.x &. z)
else if 39ul <. t && t <. 60ul then (x &. y) ^. (x &. z) ^. (y &. z) else x ^. y ^. z | false |
Steel.ST.SeqMatch.fst | Steel.ST.SeqMatch.seq_seq_match_item_match_option_init | val seq_seq_match_item_match_option_init
(#opened: _)
(#t1 #t2: Type)
(p: (t1 -> t2 -> vprop))
(s: Seq.seq t1)
: STGhostT unit
opened
emp
(fun _ ->
seq_seq_match (item_match_option p) s (Seq.create (Seq.length s) None) 0 (Seq.length s))
(decreases (Seq.length s)) | val seq_seq_match_item_match_option_init
(#opened: _)
(#t1 #t2: Type)
(p: (t1 -> t2 -> vprop))
(s: Seq.seq t1)
: STGhostT unit
opened
emp
(fun _ ->
seq_seq_match (item_match_option p) s (Seq.create (Seq.length s) None) 0 (Seq.length s))
(decreases (Seq.length s)) | let rec seq_seq_match_item_match_option_init
(#opened: _)
(#t1 #t2: Type)
(p: t1 -> t2 -> vprop)
(s: Seq.seq t1)
: STGhostT unit opened
emp
(fun _ -> seq_seq_match (item_match_option p) s (Seq.create (Seq.length s) None) 0 (Seq.length s))
(decreases (Seq.length s))
= if Seq.length s = 0
then
on_range_empty (seq_seq_match_item (item_match_option p) s (Seq.create (Seq.length s) None)) 0 (Seq.length s)
else begin
seq_seq_match_item_match_option_init p (Seq.tail s);
on_range_weaken_and_shift
(seq_seq_match_item (item_match_option p) (Seq.tail s) (Seq.create (Seq.length (Seq.tail s)) None))
(seq_seq_match_item (item_match_option p) s (Seq.create (Seq.length s) None))
1
0
(Seq.length (Seq.tail s))
(fun k ->
rewrite
(seq_seq_match_item (item_match_option p) (Seq.tail s) (Seq.create (Seq.length (Seq.tail s)) None) k)
(seq_seq_match_item (item_match_option p) s (Seq.create (Seq.length s) None) (k + 1))
)
1
(Seq.length s);
rewrite
emp
(seq_seq_match_item (item_match_option p) s (Seq.create (Seq.length s) None) 0);
on_range_cons
(seq_seq_match_item (item_match_option p) s (Seq.create (Seq.length s) None))
0
1
(Seq.length s)
end | {
"file_name": "lib/steel/Steel.ST.SeqMatch.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 5,
"end_line": 686,
"start_col": 0,
"start_line": 651
} | module Steel.ST.SeqMatch
include Steel.ST.OnRange
open Steel.ST.GenElim
module Seq = FStar.Seq
module SZ = FStar.SizeT
(* `seq_list_match` describes how to match a sequence of low-level
values (the low-level contents of an array) with a list of high-level
values. `seq_list_match` is carefully designed to be usable within
(mutually) recursive definitions of matching functions on the type of
high-level values. *)
[@@__reduce__]
let seq_list_match_nil0
(#t: Type)
(c: Seq.seq t)
: Tot vprop
= pure (c `Seq.equal` Seq.empty)
[@@__reduce__]
let seq_list_match_cons0
(#t #t': Type)
(c: Seq.seq t)
(l: list t' { Cons? l })
(item_match: (t -> (v': t' { v' << l }) -> vprop))
(seq_list_match: (Seq.seq t -> (v': list t') -> (raw_data_item_match: (t -> (v'': t' { v'' << v' }) -> vprop) { v' << l }) ->
vprop))
: Tot vprop
= exists_ (fun (c1: t) -> exists_ (fun (c2: Seq.seq t) ->
item_match c1 (List.Tot.hd l) `star`
seq_list_match c2 (List.Tot.tl l) item_match `star`
pure (c `Seq.equal` Seq.cons c1 c2)
))
let rec seq_list_match
(#t #t': Type)
(c: Seq.seq t)
(v: list t')
(item_match: (t -> (v': t' { v' << v }) -> vprop))
: Tot vprop
(decreases v)
= if Nil? v
then seq_list_match_nil0 c
else seq_list_match_cons0 c v item_match seq_list_match
let seq_list_match_cons_eq
(#t #t': Type)
(c: Seq.seq t)
(v: list t')
(item_match: (t -> (v': t' { v' << v }) -> vprop))
: Lemma
(requires (Cons? v))
(ensures (
seq_list_match c v item_match ==
seq_list_match_cons0 c v item_match seq_list_match
))
= let a :: q = v in
assert_norm (seq_list_match c (a :: q) item_match ==
seq_list_match_cons0 c (a :: q) item_match seq_list_match
)
let seq_list_match_nil
(#opened: _)
(#t #t': Type)
(c: Seq.seq t)
(v: list t')
(item_match: (t -> (v': t' { v' << v }) -> vprop))
: STGhost unit opened
emp
(fun _ -> seq_list_match c v item_match)
(c `Seq.equal` Seq.empty /\
Nil? v)
(fun _ -> True)
= noop ();
rewrite
(seq_list_match_nil0 c)
(seq_list_match c v item_match)
let list_cons_precedes
(#t: Type)
(a: t)
(q: list t)
: Lemma
((a << a :: q) /\ (q << a :: q))
[SMTPat (a :: q)]
= assert (List.Tot.hd (a :: q) << (a :: q));
assert (List.Tot.tl (a :: q) << (a :: q))
let seq_list_match_cons_intro
(#opened: _)
(#t #t': Type)
(a: t)
(a' : t')
(c: Seq.seq t)
(v: list t')
(item_match: (t -> (v': t' { v' << a' :: v }) -> vprop))
: STGhostT unit opened
(item_match a a' `star` seq_list_match c v item_match)
(fun _ -> seq_list_match (Seq.cons a c) (a' :: v) item_match)
= seq_list_match_cons_eq (Seq.cons a c) (a' :: v) item_match;
noop ();
rewrite
(seq_list_match_cons0 (Seq.cons a c) (a' :: v) item_match seq_list_match)
(seq_list_match (Seq.cons a c) (a' :: v) item_match)
let seq_list_match_cons_elim
(#opened: _)
(#t #t': Type)
(c: Seq.seq t)
(v: list t' { Cons? v \/ Seq.length c > 0 })
(item_match: (t -> (v': t' { v' << v }) -> vprop))
: STGhostT (squash (Cons? v /\ Seq.length c > 0)) opened
(seq_list_match c v item_match)
(fun _ -> item_match (Seq.head c) (List.Tot.hd v) `star`
seq_list_match (Seq.tail c) (List.Tot.tl v) item_match)
= if Nil? v
then begin
rewrite
(seq_list_match c v item_match)
(seq_list_match_nil0 c);
let _ = gen_elim () in
assert False;
rewrite // by contradiction
emp
(item_match (Seq.head c) (List.Tot.hd v) `star`
seq_list_match (Seq.tail c) (List.Tot.tl v) item_match)
end else begin
seq_list_match_cons_eq c v item_match;
noop ();
rewrite
(seq_list_match c v item_match)
(seq_list_match_cons0 c v item_match seq_list_match);
let _ = gen_elim () in
let prf : squash (Cons? v /\ Seq.length c > 0) = () in
let c1 = vpattern (fun c1 -> item_match c1 (List.Tot.hd v)) in
let c2 = vpattern (fun c2 -> seq_list_match c2 (List.Tot.tl v) item_match) in
Seq.lemma_cons_inj c1 (Seq.head c) c2 (Seq.tail c);
vpattern_rewrite (fun c1 -> item_match c1 (List.Tot.hd v)) (Seq.head c);
vpattern_rewrite (fun c2 -> seq_list_match c2 (List.Tot.tl v) item_match) (Seq.tail c);
prf
end
// this one cannot be proven with seq_seq_match because of the << refinement in the type of item_match
let rec seq_list_match_weaken
(#opened: _)
(#t #t': Type)
(c: Seq.seq t)
(v: list t')
(item_match1 item_match2: (t -> (v': t' { v' << v }) -> vprop))
(prf: (
(#opened: _) ->
(c': t) ->
(v': t' { v' << v }) ->
STGhostT unit opened
(item_match1 c' v')
(fun _ -> item_match2 c' v')
))
: STGhostT unit opened
(seq_list_match c v item_match1)
(fun _ -> seq_list_match c v item_match2)
(decreases v)
= if Nil? v
then
rewrite (seq_list_match c v item_match1) (seq_list_match c v item_match2)
else begin
let _ : squash (Cons? v) = () in
seq_list_match_cons_eq c v item_match1;
seq_list_match_cons_eq c v item_match2;
rewrite
(seq_list_match c v item_match1)
(seq_list_match_cons0 c v item_match1 seq_list_match);
let _ = gen_elim () in
prf _ _;
seq_list_match_weaken _ (List.Tot.tl v) item_match1 item_match2 prf;
rewrite
(seq_list_match_cons0 c v item_match2 seq_list_match)
(seq_list_match c v item_match2)
end
(* `seq_seq_match` describes how to match a sequence of low-level
values (the low-level contents of an array) with a sequence of high-level
values. Contrary to `seq_list_match`, `seq_seq_match` is not meant to be usable within
(mutually) recursive definitions of matching functions on the type of
high-level values, because no lemma ensures that `Seq.index s i << s` *)
let seq_seq_match_item
(#t1 #t2: Type)
(p: t1 -> t2 -> vprop)
(c: Seq.seq t1)
(l: Seq.seq t2)
(i: nat)
: Tot vprop
= if i < Seq.length c && i < Seq.length l
then
p (Seq.index c i) (Seq.index l i)
else
pure (squash False)
let seq_seq_match_item_tail
(#t1 #t2: Type)
(p: t1 -> t2 -> vprop)
(c: Seq.seq t1)
(l: Seq.seq t2)
(delta: nat)
(i: nat)
: Lemma
(requires (
i + delta <= Seq.length c /\
i + delta <= Seq.length l
))
(ensures (
seq_seq_match_item p (Seq.slice c delta (Seq.length c)) (Seq.slice l delta (Seq.length l)) i ==
seq_seq_match_item p c l (i + delta)
))
= ()
[@@__reduce__]
let seq_seq_match
(#t1 #t2: Type)
(p: t1 -> t2 -> vprop)
(c: Seq.seq t1)
(l: Seq.seq t2)
(i j: nat)
: Tot vprop
= on_range (seq_seq_match_item p c l) i j
let seq_seq_match_length
(#opened: _)
(#t1 #t2: Type)
(p: t1 -> t2 -> vprop)
(s1: Seq.seq t1)
(s2: Seq.seq t2)
(i j: nat)
: STGhost unit opened
(seq_seq_match p s1 s2 i j)
(fun _ -> seq_seq_match p s1 s2 i j)
True
(fun _ -> i <= j /\ (i == j \/ (j <= Seq.length s1 /\ j <= Seq.length s2)))
= on_range_le (seq_seq_match_item p s1 s2) i j;
if i = j
then noop ()
else begin
let j' = j - 1 in
if j' < Seq.length s1 && j' < Seq.length s2
then noop ()
else begin
on_range_unsnoc
(seq_seq_match_item p s1 s2)
i j' j;
rewrite
(seq_seq_match_item p _ _ _)
(pure (squash False));
let _ = gen_elim () in
rewrite
(seq_seq_match p s1 s2 i j')
(seq_seq_match p s1 s2 i j) // by contradiction
end
end
let seq_seq_match_weaken
(#opened: _)
(#t1 #t2: Type)
(p p': t1 -> t2 -> vprop)
(w: ((x1: t1) -> (x2: t2) -> STGhostT unit opened
(p x1 x2) (fun _ -> p' x1 x2)
))
(c1 c1': Seq.seq t1)
(c2 c2': Seq.seq t2)
(i j: nat)
: STGhost unit opened
(seq_seq_match p c1 c2 i j)
(fun _ -> seq_seq_match p' c1' c2' i j)
(i <= j /\ (i == j \/ (
j <= Seq.length c1 /\ j <= Seq.length c2 /\
j <= Seq.length c1' /\ j <= Seq.length c2' /\
Seq.slice c1 i j `Seq.equal` Seq.slice c1' i j /\
Seq.slice c2 i j `Seq.equal` Seq.slice c2' i j
)))
(fun _ -> True)
=
on_range_weaken
(seq_seq_match_item p c1 c2)
(seq_seq_match_item p' c1' c2')
i j
(fun k ->
rewrite (seq_seq_match_item p c1 c2 k) (p (Seq.index (Seq.slice c1 i j) (k - i)) (Seq.index (Seq.slice c2 i j) (k - i)));
w _ _;
rewrite (p' _ _) (seq_seq_match_item p' c1' c2' k)
)
let seq_seq_match_weaken_with_implies
(#opened: _)
(#t1 #t2: Type)
(p: t1 -> t2 -> vprop)
(c1 c1': Seq.seq t1)
(c2 c2': Seq.seq t2)
(i j: nat)
: STGhost unit opened
(seq_seq_match p c1 c2 i j)
(fun _ -> seq_seq_match p c1' c2' i j `star`
(seq_seq_match p c1' c2' i j `implies_` seq_seq_match p c1 c2 i j)
)
(i <= j /\ (i == j \/ (
j <= Seq.length c1 /\ j <= Seq.length c2 /\
j <= Seq.length c1' /\ j <= Seq.length c2' /\
Seq.slice c1 i j `Seq.equal` Seq.slice c1' i j /\
Seq.slice c2 i j `Seq.equal` Seq.slice c2' i j
)))
(fun _ -> True)
= seq_seq_match_weaken
p p (fun _ _ -> noop ())
c1 c1'
c2 c2'
i j;
intro_implies
(seq_seq_match p c1' c2' i j)
(seq_seq_match p c1 c2 i j)
emp
(fun _ ->
seq_seq_match_weaken
p p (fun _ _ -> noop ())
c1' c1
c2' c2
i j
)
(* Going between `seq_list_match` and `seq_seq_match` *)
let seq_seq_match_tail_elim
(#t1 #t2: Type)
(#opened: _)
(p: t1 -> t2 -> vprop)
(c: Seq.seq t1)
(l: Seq.seq (t2))
(delta: nat {
delta <= Seq.length c /\
delta <= Seq.length l
})
(i j: nat)
: STGhostT unit opened
(seq_seq_match p (Seq.slice c delta (Seq.length c)) (Seq.slice l delta (Seq.length l)) i j)
(fun _ -> seq_seq_match p c l (i + delta) (j + delta))
= on_range_le (seq_seq_match_item p _ _) _ _;
on_range_weaken_and_shift
(seq_seq_match_item p (Seq.slice c delta (Seq.length c)) (Seq.slice l delta (Seq.length l)))
(seq_seq_match_item p c l)
delta
i j
(fun k ->
if k < Seq.length c - delta && k < Seq.length l - delta
then begin
seq_seq_match_item_tail p c l delta k;
rewrite
(seq_seq_match_item p (Seq.slice c delta (Seq.length c)) (Seq.slice l delta (Seq.length l)) k)
(seq_seq_match_item p c l (k + delta))
end else begin
rewrite
(seq_seq_match_item p (Seq.slice c delta (Seq.length c)) (Seq.slice l delta (Seq.length l)) k)
(pure (squash False));
let _ = gen_elim () in
rewrite
emp
(seq_seq_match_item p c l (k + delta)) // by contradiction
end
)
(i + delta) (j + delta)
let seq_seq_match_tail_intro
(#t1 #t2: Type)
(#opened: _)
(p: t1 -> t2 -> vprop)
(c: Seq.seq t1)
(l: Seq.seq t2)
(delta: nat {
delta <= Seq.length c /\
delta <= Seq.length l
})
(i: nat {
delta <= i
})
(j: nat)
: STGhostT (squash (i <= j)) opened
(seq_seq_match p c l i j)
(fun _ -> seq_seq_match p (Seq.slice c delta (Seq.length c)) (Seq.slice l delta (Seq.length l)) (i - delta) (j - delta))
= on_range_le (seq_seq_match_item p _ _) _ _;
on_range_weaken_and_shift
(seq_seq_match_item p c l)
(seq_seq_match_item p (Seq.slice c delta (Seq.length c)) (Seq.slice l delta (Seq.length l)))
(0 - delta)
i j
(fun k ->
if k < Seq.length c && k < Seq.length l
then begin
seq_seq_match_item_tail p c l delta (k - delta);
rewrite
(seq_seq_match_item p c l k)
(seq_seq_match_item p (Seq.slice c delta (Seq.length c)) (Seq.slice l delta (Seq.length l)) (k + (0 - delta)))
end else begin
rewrite
(seq_seq_match_item p c l k)
(pure (squash False));
let _ = gen_elim () in
rewrite
emp
(seq_seq_match_item p (Seq.slice c delta (Seq.length c)) (Seq.slice l delta (Seq.length l)) (k + (0 - delta))) // by contradiction
end
)
(i - delta) (j - delta)
let rec seq_seq_match_seq_list_match
(#opened: _)
(#t1 #t2: Type)
(p: t1 -> t2 -> vprop)
(c: Seq.seq t1)
(l: list t2)
: STGhost unit opened
(seq_seq_match p c (Seq.seq_of_list l) 0 (List.Tot.length l))
(fun _ -> seq_list_match c l p)
(Seq.length c == List.Tot.length l)
(fun _ -> True)
(decreases l)
= match l with
| [] ->
drop (seq_seq_match p _ _ _ _);
rewrite
(seq_list_match_nil0 c)
(seq_list_match c l p)
| a :: q ->
Seq.lemma_seq_of_list_induction (a :: q);
seq_list_match_cons_eq c l p;
on_range_uncons
(seq_seq_match_item p _ _)
_ 1 _;
rewrite
(seq_seq_match_item p _ _ _)
(p (Seq.head c) (List.Tot.hd l));
let _ = seq_seq_match_tail_intro
p _ _ 1 _ _
in
rewrite
(seq_seq_match p _ _ _ _)
(seq_seq_match p (Seq.tail c) (Seq.seq_of_list (List.Tot.tl l)) 0 (List.Tot.length (List.Tot.tl l)));
seq_seq_match_seq_list_match p _ (List.Tot.tl l);
rewrite
(seq_list_match_cons0 c l p seq_list_match)
(seq_list_match c l p)
let rec seq_list_match_seq_seq_match
(#opened: _)
(#t1 #t2: Type)
(p: t1 -> t2 -> vprop)
(c: Seq.seq t1)
(l: list t2)
: STGhost unit opened
(seq_list_match c l p)
(fun _ -> seq_seq_match p c (Seq.seq_of_list l) 0 (List.Tot.length l))
True
(fun _ -> Seq.length c == List.Tot.length l)
(decreases l)
= match l with
| [] ->
rewrite
(seq_list_match c l p)
(seq_list_match_nil0 c);
let _ = gen_elim () in
on_range_empty
(seq_seq_match_item p c (Seq.seq_of_list l))
0
(List.Tot.length l)
| a :: q ->
let _l_nonempty : squash (Cons? l) = () in
Seq.lemma_seq_of_list_induction (a :: q);
seq_list_match_cons_eq c l p;
noop ();
rewrite
(seq_list_match c l p)
(seq_list_match_cons0 c l p seq_list_match);
let _ = gen_elim () in
let a' = vpattern (fun a' -> p a' _) in
let c' = vpattern (fun c' -> seq_list_match c' _ _) in
Seq.lemma_cons_inj (Seq.head c) a' (Seq.tail c) c';
assert (a' == Seq.head c);
assert (c' == Seq.tail c);
noop ();
seq_list_match_seq_seq_match p _ _;
rewrite
(seq_seq_match p _ _ _ _)
(seq_seq_match p (Seq.slice c 1 (Seq.length c)) (Seq.slice (Seq.seq_of_list l) 1 (Seq.length (Seq.seq_of_list l))) 0 (List.Tot.length (List.Tot.tl l)));
let _ = seq_seq_match_tail_elim
p c (Seq.seq_of_list l) 1 0 (List.Tot.length (List.Tot.tl l))
in
rewrite
(seq_seq_match p _ _ _ _)
(seq_seq_match p c (Seq.seq_of_list l) 1 (List.Tot.length l));
rewrite
(p _ _)
(seq_seq_match_item p c (Seq.seq_of_list l) 0);
on_range_cons
(seq_seq_match_item p _ _)
0 1 (List.Tot.length l)
let seq_seq_match_seq_list_match_with_implies
(#opened: _)
(#t1 #t2: Type)
(p: t1 -> t2 -> vprop)
(c: Seq.seq t1)
(l: list t2)
: STGhost unit opened
(seq_seq_match p c (Seq.seq_of_list l) 0 (List.Tot.length l))
(fun _ -> seq_list_match c l p `star` (seq_list_match c l p `implies_` seq_seq_match p c (Seq.seq_of_list l) 0 (List.Tot.length l)))
(Seq.length c == List.Tot.length l)
(fun _ -> True)
= seq_seq_match_seq_list_match p c l;
intro_implies
(seq_list_match c l p)
(seq_seq_match p c (Seq.seq_of_list l) 0 (List.Tot.length l))
emp
(fun _ -> seq_list_match_seq_seq_match p c l)
let seq_list_match_seq_seq_match_with_implies
(#opened: _)
(#t1 #t2: Type)
(p: t1 -> t2 -> vprop)
(c: Seq.seq t1)
(l: list t2)
: STGhost unit opened
(seq_list_match c l p)
(fun _ -> seq_seq_match p c (Seq.seq_of_list l) 0 (List.Tot.length l) `star` (seq_seq_match p c (Seq.seq_of_list l) 0 (List.Tot.length l) `implies_` seq_list_match c l p))
True
(fun _ -> Seq.length c == List.Tot.length l)
= seq_list_match_seq_seq_match p c l;
intro_implies
(seq_seq_match p c (Seq.seq_of_list l) 0 (List.Tot.length l))
(seq_list_match c l p)
emp
(fun _ -> seq_seq_match_seq_list_match p c l)
let seq_list_match_length
(#opened: _)
(#t1 #t2: Type)
(p: t1 -> t2 -> vprop)
(c: Seq.seq t1)
(l: list t2)
: STGhost unit opened
(seq_list_match c l p)
(fun _ -> seq_list_match c l p)
True
(fun _ -> Seq.length c == List.Tot.length l)
= seq_list_match_seq_seq_match_with_implies p c l;
seq_seq_match_length p _ _ _ _;
elim_implies
(seq_seq_match p _ _ _ _)
(seq_list_match c l p)
let seq_list_match_index
(#opened: _)
(#t1 #t2: Type)
(p: t1 -> t2 -> vprop)
(s1: Seq.seq t1)
(s2: list t2)
(i: nat)
: STGhost (squash (i < Seq.length s1 /\ List.Tot.length s2 == Seq.length s1)) opened
(seq_list_match s1 s2 p)
(fun _ ->
p (Seq.index s1 i) (List.Tot.index s2 i) `star`
(p (Seq.index s1 i) (List.Tot.index s2 i) `implies_`
seq_list_match s1 s2 p)
)
(i < Seq.length s1 \/ i < List.Tot.length s2)
(fun _ -> True)
= seq_list_match_seq_seq_match_with_implies p s1 s2;
let res : squash (i < Seq.length s1 /\ List.Tot.length s2 == Seq.length s1) = () in
on_range_focus (seq_seq_match_item p s1 (Seq.seq_of_list s2)) 0 i (List.Tot.length s2);
rewrite_with_implies
(seq_seq_match_item p _ _ _)
(p (Seq.index s1 i) (List.Tot.index s2 i));
implies_trans
(p (Seq.index s1 i) (List.Tot.index s2 i))
(seq_seq_match_item p _ _ _)
(seq_seq_match p s1 (Seq.seq_of_list s2) 0 (List.Tot.length s2));
implies_trans
(p (Seq.index s1 i) (List.Tot.index s2 i))
(seq_seq_match p s1 (Seq.seq_of_list s2) 0 (List.Tot.length s2))
(seq_list_match s1 s2 p);
res
(* Random array access
Since `seq_list_match` is defined recursively on the list of
high-level values, it is used naturally left-to-right. By contrast,
in practice, an application may populate an array in a different
order, or even out-of-order. `seq_seq_match` supports that scenario
better, as we show below.
*)
let seq_map (#t1 #t2: Type) (f: t1 -> t2) (s: Seq.seq t1) : Tot (Seq.seq t2) =
Seq.init (Seq.length s) (fun i -> f (Seq.index s i))
let item_match_option
(#t1 #t2: Type)
(p: t1 -> t2 -> vprop)
(x1: t1)
(x2: option t2)
: Tot vprop
= match x2 with
| None -> emp
| Some x2' -> p x1 x2'
let seq_seq_match_item_match_option_elim
(#opened: _)
(#t1 #t2: Type)
(p: t1 -> t2 -> vprop)
(s1: Seq.seq t1)
(s2: Seq.seq t2)
(i j: nat)
: STGhostT unit opened
(seq_seq_match (item_match_option p) s1 (seq_map Some s2) i j)
(fun _ -> seq_seq_match p s1 s2 i j)
= on_range_weaken
(seq_seq_match_item (item_match_option p) s1 (seq_map Some s2))
(seq_seq_match_item p s1 s2)
i j
(fun k ->
rewrite
(seq_seq_match_item (item_match_option p) s1 (seq_map Some s2) k)
(seq_seq_match_item p s1 s2 k)
)
let seq_seq_match_item_match_option_intro
(#opened: _)
(#t1 #t2: Type)
(p: t1 -> t2 -> vprop)
(s1: Seq.seq t1)
(s2: Seq.seq t2)
(i j: nat)
: STGhostT unit opened
(seq_seq_match p s1 s2 i j)
(fun _ -> seq_seq_match (item_match_option p) s1 (seq_map Some s2) i j)
= on_range_weaken
(seq_seq_match_item p s1 s2)
(seq_seq_match_item (item_match_option p) s1 (seq_map Some s2))
i j
(fun k ->
rewrite
(seq_seq_match_item p s1 s2 k)
(seq_seq_match_item (item_match_option p) s1 (seq_map Some s2) k)
) | {
"checked_file": "/",
"dependencies": [
"Steel.ST.OnRange.fsti.checked",
"Steel.ST.GenElim.fsti.checked",
"prims.fst.checked",
"FStar.SizeT.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Steel.ST.SeqMatch.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "SZ"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.OnRange",
"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: (_: t1 -> _: t2 -> Steel.Effect.Common.vprop) -> s: FStar.Seq.Base.seq t1
-> Steel.ST.Effect.Ghost.STGhostT Prims.unit | Steel.ST.Effect.Ghost.STGhostT | [
""
] | [] | [
"Steel.Memory.inames",
"Steel.Effect.Common.vprop",
"FStar.Seq.Base.seq",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"Steel.ST.OnRange.on_range_empty",
"Steel.ST.SeqMatch.seq_seq_match_item",
"FStar.Pervasives.Native.option",
"Steel.ST.SeqMatch.item_match_option",
"FStar.Seq.Base.create",
"FStar.Pervasives.Native.None",
"Prims.unit",
"Prims.bool",
"Steel.ST.OnRange.on_range_cons",
"Steel.ST.Util.rewrite",
"Steel.Effect.Common.emp",
"Steel.ST.OnRange.on_range_weaken_and_shift",
"FStar.Seq.Properties.tail",
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.op_Addition",
"Steel.ST.SeqMatch.seq_seq_match_item_match_option_init",
"Steel.ST.SeqMatch.seq_seq_match"
] | [
"recursion"
] | false | true | false | false | false | let rec seq_seq_match_item_match_option_init
(#opened: _)
(#t1 #t2: Type)
(p: (t1 -> t2 -> vprop))
(s: Seq.seq t1)
: STGhostT unit
opened
emp
(fun _ ->
seq_seq_match (item_match_option p) s (Seq.create (Seq.length s) None) 0 (Seq.length s))
(decreases (Seq.length s)) =
| if Seq.length s = 0
then
on_range_empty (seq_seq_match_item (item_match_option p) s (Seq.create (Seq.length s) None))
0
(Seq.length s)
else
(seq_seq_match_item_match_option_init p (Seq.tail s);
on_range_weaken_and_shift (seq_seq_match_item (item_match_option p)
(Seq.tail s)
(Seq.create (Seq.length (Seq.tail s)) None))
(seq_seq_match_item (item_match_option p) s (Seq.create (Seq.length s) None))
1
0
(Seq.length (Seq.tail s))
(fun k ->
rewrite (seq_seq_match_item (item_match_option p)
(Seq.tail s)
(Seq.create (Seq.length (Seq.tail s)) None)
k)
(seq_seq_match_item (item_match_option p) s (Seq.create (Seq.length s) None) (k + 1)))
1
(Seq.length s);
rewrite emp (seq_seq_match_item (item_match_option p) s (Seq.create (Seq.length s) None) 0);
on_range_cons (seq_seq_match_item (item_match_option p) s (Seq.create (Seq.length s) None))
0
1
(Seq.length s)) | false |
Spec.SHA1.fst | Spec.SHA1.step4 | val step4 : mi: Spec.SHA1.word_block -> h: Spec.Hash.Definitions.words_state Spec.Hash.Definitions.SHA1
-> Spec.Hash.Definitions.words_state Spec.Hash.Definitions.SHA1 | let step4 = step4_aux | {
"file_name": "specs/Spec.SHA1.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 21,
"end_line": 227,
"start_col": 0,
"start_line": 227
} | module Spec.SHA1
open Lib.IntTypes
module H = Spec.Hash.Definitions
module Seq = FStar.Seq
open Spec.Hash.Definitions
(* Source: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf *)
(* Section 5.3.1 *)
inline_for_extraction
let init_as_list : list uint32 = [
u32 0x67452301;
u32 0xefcdab89;
u32 0x98badcfe;
u32 0x10325476;
u32 0xc3d2e1f0;
]
let init : words_state SHA1 = Seq.seq_of_list init_as_list
(* Section 6.1.2 Step 1: message schedule *)
let rec w' (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: nat {t <= 79}) : GTot (word SHA1) (decreases (t)) =
if t < 16
then Seq.index mi (t)
else (w' mi (t - 3) ^. w' mi (t - 8) ^. w' mi (t - 14) ^. w' mi (t - 16)) <<<. 1ul
let w (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: size_t {v t <= 79}) : GTot (word SHA1) = w' mi (v t)
let compute_w_post
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
: GTot Type0
= (n <= 80 /\ (
forall (i: nat) . i < n ==> Seq.index res i == w' mi i
))
let compute_w_post_intro
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
(u: squash (n <= 80))
(f: (i: nat) -> Lemma
(requires (i < n))
(ensures (i < n /\ Seq.index res i == w' mi i)))
: Lemma
(compute_w_post mi n res)
= Classical.forall_intro (Classical.move_requires f)
inline_for_extraction
let compute_w_n'
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(w: ((i: nat {i < n}) -> Tot (y: word SHA1 {y == w' mi i})))
: Tot (y: word SHA1 {y == w' mi n})
= let r =
if n < 16
then Seq.index mi n
else (w (n - 3) ^. w (n - 8) ^. w (n - 14) ^. w (n - 16)) <<<. 1ul
in
r
inline_for_extraction
let compute_w_n
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(accu: Seq.lseq (word SHA1) n)
: Pure (word SHA1)
(requires (compute_w_post mi n accu))
(ensures (fun y -> n <= 79 /\ y == w' mi n))
= [@inline_let]
let w (i: nat {i < n}) : Tot (y: word SHA1 {y == w' mi i}) = Seq.index accu i in
compute_w_n' mi n w
inline_for_extraction
let compute_w_next
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) (n + 1))
(requires (compute_w_post mi n accu))
(ensures (fun accu' -> compute_w_post mi (n + 1) accu'))
= let wn = compute_w_n mi n accu in
let accu' = Seq.snoc accu wn in
assert (n + 1 <= 80);
let g
(i: nat)
: Lemma
(requires (i < n + 1))
(ensures (i < n + 1 /\ Seq.index accu' i == w' mi i))
= if i = n
then ()
else ()
in
compute_w_post_intro mi (n + 1) accu' () g;
accu'
let rec compute_w
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) 80)
(requires (compute_w_post mi n accu))
(ensures (fun res -> compute_w_post mi 80 res))
(decreases (80 - n))
= assert (n <= 80); // this assert is necessary for Z3 to prove that n <= 79 in the else branch
if n = 80
then accu
else compute_w mi (n + 1) (compute_w_next mi n accu)
(* Section 4.1.1: logical functions *)
inline_for_extraction
let f (t: size_t {v t <= 79}) (x y z: word SHA1) : Tot (word SHA1) =
if t <. 20ul
then
(x &. y) ^. (~. x &. z)
else if 39ul <. t && t <. 60ul
then
(x &. y) ^. (x &. z) ^. (y &. z)
else
x ^. y ^. z
(* Section 4.2.1 *)
inline_for_extraction
let k (t: size_t { v t <= 79 } ) : Tot (word SHA1) =
if t <. 20ul
then u32 0x5a827999
else if t <. 40ul
then u32 0x6ed9eba1
else if t <. 60ul
then u32 0x8f1bbcdc
else u32 0xca62c1d6
(* Section 6.1.2 Step 3 *)
let word_block = Seq.lseq (word SHA1) (block_word_length SHA1)
let step3_body'_aux
(mi: word_block)
(st: words_state SHA1)
(t: size_t {v t < 80})
(wt: word SHA1 { wt == w mi t } )
: Tot (words_state SHA1)
= let sta = Seq.index st 0 in
let stb = Seq.index st 1 in
let stc = Seq.index st 2 in
let std = Seq.index st 3 in
let ste = Seq.index st 4 in
let _T = (sta <<<. 5ul) +. f t stb stc std +. ste +. k t +. wt in
let e = std in
let d = stc in
let c = stb <<<. 30ul in
let b = sta in
let a = _T in
let l : list uint32 = [
a;
b;
c;
d;
e;
] in
assert_norm (List.Tot.length l = 5);
Seq.seq_of_list l
[@"opaque_to_smt"]
let step3_body' = step3_body'_aux
#reset-options "--z3rlimit 50"
[@unifier_hint_injective]
inline_for_extraction
let step3_body_w_t
(mi: word_block)
: Tot Type
= (t: nat { t < 80 }) -> Tot (wt: word SHA1 { wt == w' mi t } )
let step3_body
(mi: word_block)
(w: step3_body_w_t mi)
(st: words_state SHA1)
(t: nat {t < 80})
: Tot (words_state SHA1)
= step3_body' mi st (size t) (w t)
inline_for_extraction
let index_compute_w
(mi: word_block)
(cwt: Seq.lseq (word SHA1) 80 { compute_w_post mi 80 cwt } )
: Tot (step3_body_w_t mi)
= fun (t: nat {t < 80}) -> (Seq.index cwt t <: (wt: word SHA1 { wt == w' mi t }))
let step3_aux
(mi: word_block)
(h: words_state SHA1)
: Tot (words_state SHA1)
= let cwt = compute_w mi 0 Seq.empty in
Spec.Loops.repeat_range 0 80 (step3_body mi (index_compute_w mi cwt)) h
[@"opaque_to_smt"]
let step3 = step3_aux
(* Section 6.1.2 Step 4 *)
let step4_aux
(mi: word_block)
(h: words_state SHA1)
: Tot (words_state SHA1) =
let st = step3 mi h in
let sta = Seq.index st 0 in
let stb = Seq.index st 1 in
let stc = Seq.index st 2 in
let std = Seq.index st 3 in
let ste = Seq.index st 4 in
Seq.seq_of_list [
sta +. Seq.index h 0;
stb +. Seq.index h 1;
stc +. Seq.index h 2;
std +. Seq.index h 3;
ste +. Seq.index h 4;
] | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Spec.SHA1.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "Spec.Hash.Definitions",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | mi: Spec.SHA1.word_block -> h: Spec.Hash.Definitions.words_state Spec.Hash.Definitions.SHA1
-> Spec.Hash.Definitions.words_state Spec.Hash.Definitions.SHA1 | Prims.Tot | [
"total"
] | [] | [
"Spec.SHA1.step4_aux"
] | [] | false | false | false | true | false | let step4 =
| step4_aux | false |
|
Spec.SHA1.fst | Spec.SHA1.step3 | val step3 : mi: Spec.SHA1.word_block -> h: Spec.Hash.Definitions.words_state Spec.Hash.Definitions.SHA1
-> Spec.Hash.Definitions.words_state Spec.Hash.Definitions.SHA1 | let step3 = step3_aux | {
"file_name": "specs/Spec.SHA1.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 21,
"end_line": 204,
"start_col": 0,
"start_line": 204
} | module Spec.SHA1
open Lib.IntTypes
module H = Spec.Hash.Definitions
module Seq = FStar.Seq
open Spec.Hash.Definitions
(* Source: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf *)
(* Section 5.3.1 *)
inline_for_extraction
let init_as_list : list uint32 = [
u32 0x67452301;
u32 0xefcdab89;
u32 0x98badcfe;
u32 0x10325476;
u32 0xc3d2e1f0;
]
let init : words_state SHA1 = Seq.seq_of_list init_as_list
(* Section 6.1.2 Step 1: message schedule *)
let rec w' (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: nat {t <= 79}) : GTot (word SHA1) (decreases (t)) =
if t < 16
then Seq.index mi (t)
else (w' mi (t - 3) ^. w' mi (t - 8) ^. w' mi (t - 14) ^. w' mi (t - 16)) <<<. 1ul
let w (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: size_t {v t <= 79}) : GTot (word SHA1) = w' mi (v t)
let compute_w_post
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
: GTot Type0
= (n <= 80 /\ (
forall (i: nat) . i < n ==> Seq.index res i == w' mi i
))
let compute_w_post_intro
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
(u: squash (n <= 80))
(f: (i: nat) -> Lemma
(requires (i < n))
(ensures (i < n /\ Seq.index res i == w' mi i)))
: Lemma
(compute_w_post mi n res)
= Classical.forall_intro (Classical.move_requires f)
inline_for_extraction
let compute_w_n'
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(w: ((i: nat {i < n}) -> Tot (y: word SHA1 {y == w' mi i})))
: Tot (y: word SHA1 {y == w' mi n})
= let r =
if n < 16
then Seq.index mi n
else (w (n - 3) ^. w (n - 8) ^. w (n - 14) ^. w (n - 16)) <<<. 1ul
in
r
inline_for_extraction
let compute_w_n
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(accu: Seq.lseq (word SHA1) n)
: Pure (word SHA1)
(requires (compute_w_post mi n accu))
(ensures (fun y -> n <= 79 /\ y == w' mi n))
= [@inline_let]
let w (i: nat {i < n}) : Tot (y: word SHA1 {y == w' mi i}) = Seq.index accu i in
compute_w_n' mi n w
inline_for_extraction
let compute_w_next
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) (n + 1))
(requires (compute_w_post mi n accu))
(ensures (fun accu' -> compute_w_post mi (n + 1) accu'))
= let wn = compute_w_n mi n accu in
let accu' = Seq.snoc accu wn in
assert (n + 1 <= 80);
let g
(i: nat)
: Lemma
(requires (i < n + 1))
(ensures (i < n + 1 /\ Seq.index accu' i == w' mi i))
= if i = n
then ()
else ()
in
compute_w_post_intro mi (n + 1) accu' () g;
accu'
let rec compute_w
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) 80)
(requires (compute_w_post mi n accu))
(ensures (fun res -> compute_w_post mi 80 res))
(decreases (80 - n))
= assert (n <= 80); // this assert is necessary for Z3 to prove that n <= 79 in the else branch
if n = 80
then accu
else compute_w mi (n + 1) (compute_w_next mi n accu)
(* Section 4.1.1: logical functions *)
inline_for_extraction
let f (t: size_t {v t <= 79}) (x y z: word SHA1) : Tot (word SHA1) =
if t <. 20ul
then
(x &. y) ^. (~. x &. z)
else if 39ul <. t && t <. 60ul
then
(x &. y) ^. (x &. z) ^. (y &. z)
else
x ^. y ^. z
(* Section 4.2.1 *)
inline_for_extraction
let k (t: size_t { v t <= 79 } ) : Tot (word SHA1) =
if t <. 20ul
then u32 0x5a827999
else if t <. 40ul
then u32 0x6ed9eba1
else if t <. 60ul
then u32 0x8f1bbcdc
else u32 0xca62c1d6
(* Section 6.1.2 Step 3 *)
let word_block = Seq.lseq (word SHA1) (block_word_length SHA1)
let step3_body'_aux
(mi: word_block)
(st: words_state SHA1)
(t: size_t {v t < 80})
(wt: word SHA1 { wt == w mi t } )
: Tot (words_state SHA1)
= let sta = Seq.index st 0 in
let stb = Seq.index st 1 in
let stc = Seq.index st 2 in
let std = Seq.index st 3 in
let ste = Seq.index st 4 in
let _T = (sta <<<. 5ul) +. f t stb stc std +. ste +. k t +. wt in
let e = std in
let d = stc in
let c = stb <<<. 30ul in
let b = sta in
let a = _T in
let l : list uint32 = [
a;
b;
c;
d;
e;
] in
assert_norm (List.Tot.length l = 5);
Seq.seq_of_list l
[@"opaque_to_smt"]
let step3_body' = step3_body'_aux
#reset-options "--z3rlimit 50"
[@unifier_hint_injective]
inline_for_extraction
let step3_body_w_t
(mi: word_block)
: Tot Type
= (t: nat { t < 80 }) -> Tot (wt: word SHA1 { wt == w' mi t } )
let step3_body
(mi: word_block)
(w: step3_body_w_t mi)
(st: words_state SHA1)
(t: nat {t < 80})
: Tot (words_state SHA1)
= step3_body' mi st (size t) (w t)
inline_for_extraction
let index_compute_w
(mi: word_block)
(cwt: Seq.lseq (word SHA1) 80 { compute_w_post mi 80 cwt } )
: Tot (step3_body_w_t mi)
= fun (t: nat {t < 80}) -> (Seq.index cwt t <: (wt: word SHA1 { wt == w' mi t }))
let step3_aux
(mi: word_block)
(h: words_state SHA1)
: Tot (words_state SHA1)
= let cwt = compute_w mi 0 Seq.empty in
Spec.Loops.repeat_range 0 80 (step3_body mi (index_compute_w mi cwt)) h | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Spec.SHA1.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "Spec.Hash.Definitions",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | mi: Spec.SHA1.word_block -> h: Spec.Hash.Definitions.words_state Spec.Hash.Definitions.SHA1
-> Spec.Hash.Definitions.words_state Spec.Hash.Definitions.SHA1 | Prims.Tot | [
"total"
] | [] | [
"Spec.SHA1.step3_aux"
] | [] | false | false | false | true | false | let step3 =
| step3_aux | false |
|
Spec.SHA1.fst | Spec.SHA1.w | val w (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: size_t{v t <= 79}) : GTot (word SHA1) | val w (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: size_t{v t <= 79}) : GTot (word SHA1) | let w (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: size_t {v t <= 79}) : GTot (word SHA1) = w' mi (v t) | {
"file_name": "specs/Spec.SHA1.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 114,
"end_line": 30,
"start_col": 0,
"start_line": 30
} | module Spec.SHA1
open Lib.IntTypes
module H = Spec.Hash.Definitions
module Seq = FStar.Seq
open Spec.Hash.Definitions
(* Source: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf *)
(* Section 5.3.1 *)
inline_for_extraction
let init_as_list : list uint32 = [
u32 0x67452301;
u32 0xefcdab89;
u32 0x98badcfe;
u32 0x10325476;
u32 0xc3d2e1f0;
]
let init : words_state SHA1 = Seq.seq_of_list init_as_list
(* Section 6.1.2 Step 1: message schedule *)
let rec w' (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: nat {t <= 79}) : GTot (word SHA1) (decreases (t)) =
if t < 16
then Seq.index mi (t)
else (w' mi (t - 3) ^. w' mi (t - 8) ^. w' mi (t - 14) ^. w' mi (t - 16)) <<<. 1ul | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Spec.SHA1.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "Spec.Hash.Definitions",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
mi:
FStar.Seq.Properties.lseq (Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA1)
(Spec.Hash.Definitions.block_word_length Spec.Hash.Definitions.SHA1) ->
t: Lib.IntTypes.size_t{Lib.IntTypes.v t <= 79}
-> Prims.GTot (Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA1) | Prims.GTot | [
"sometrivial"
] | [] | [
"FStar.Seq.Properties.lseq",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.SHA1",
"Spec.Hash.Definitions.block_word_length",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Spec.SHA1.w'"
] | [] | false | false | false | false | false | let w (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: size_t{v t <= 79}) : GTot (word SHA1) =
| w' mi (v t) | false |
Spec.SHA1.fst | Spec.SHA1.update | val update: update_t SHA1 | val update: update_t SHA1 | let update = update_aux | {
"file_name": "specs/Spec.SHA1.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 23,
"end_line": 242,
"start_col": 0,
"start_line": 242
} | module Spec.SHA1
open Lib.IntTypes
module H = Spec.Hash.Definitions
module Seq = FStar.Seq
open Spec.Hash.Definitions
(* Source: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf *)
(* Section 5.3.1 *)
inline_for_extraction
let init_as_list : list uint32 = [
u32 0x67452301;
u32 0xefcdab89;
u32 0x98badcfe;
u32 0x10325476;
u32 0xc3d2e1f0;
]
let init : words_state SHA1 = Seq.seq_of_list init_as_list
(* Section 6.1.2 Step 1: message schedule *)
let rec w' (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: nat {t <= 79}) : GTot (word SHA1) (decreases (t)) =
if t < 16
then Seq.index mi (t)
else (w' mi (t - 3) ^. w' mi (t - 8) ^. w' mi (t - 14) ^. w' mi (t - 16)) <<<. 1ul
let w (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: size_t {v t <= 79}) : GTot (word SHA1) = w' mi (v t)
let compute_w_post
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
: GTot Type0
= (n <= 80 /\ (
forall (i: nat) . i < n ==> Seq.index res i == w' mi i
))
let compute_w_post_intro
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
(u: squash (n <= 80))
(f: (i: nat) -> Lemma
(requires (i < n))
(ensures (i < n /\ Seq.index res i == w' mi i)))
: Lemma
(compute_w_post mi n res)
= Classical.forall_intro (Classical.move_requires f)
inline_for_extraction
let compute_w_n'
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(w: ((i: nat {i < n}) -> Tot (y: word SHA1 {y == w' mi i})))
: Tot (y: word SHA1 {y == w' mi n})
= let r =
if n < 16
then Seq.index mi n
else (w (n - 3) ^. w (n - 8) ^. w (n - 14) ^. w (n - 16)) <<<. 1ul
in
r
inline_for_extraction
let compute_w_n
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(accu: Seq.lseq (word SHA1) n)
: Pure (word SHA1)
(requires (compute_w_post mi n accu))
(ensures (fun y -> n <= 79 /\ y == w' mi n))
= [@inline_let]
let w (i: nat {i < n}) : Tot (y: word SHA1 {y == w' mi i}) = Seq.index accu i in
compute_w_n' mi n w
inline_for_extraction
let compute_w_next
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) (n + 1))
(requires (compute_w_post mi n accu))
(ensures (fun accu' -> compute_w_post mi (n + 1) accu'))
= let wn = compute_w_n mi n accu in
let accu' = Seq.snoc accu wn in
assert (n + 1 <= 80);
let g
(i: nat)
: Lemma
(requires (i < n + 1))
(ensures (i < n + 1 /\ Seq.index accu' i == w' mi i))
= if i = n
then ()
else ()
in
compute_w_post_intro mi (n + 1) accu' () g;
accu'
let rec compute_w
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) 80)
(requires (compute_w_post mi n accu))
(ensures (fun res -> compute_w_post mi 80 res))
(decreases (80 - n))
= assert (n <= 80); // this assert is necessary for Z3 to prove that n <= 79 in the else branch
if n = 80
then accu
else compute_w mi (n + 1) (compute_w_next mi n accu)
(* Section 4.1.1: logical functions *)
inline_for_extraction
let f (t: size_t {v t <= 79}) (x y z: word SHA1) : Tot (word SHA1) =
if t <. 20ul
then
(x &. y) ^. (~. x &. z)
else if 39ul <. t && t <. 60ul
then
(x &. y) ^. (x &. z) ^. (y &. z)
else
x ^. y ^. z
(* Section 4.2.1 *)
inline_for_extraction
let k (t: size_t { v t <= 79 } ) : Tot (word SHA1) =
if t <. 20ul
then u32 0x5a827999
else if t <. 40ul
then u32 0x6ed9eba1
else if t <. 60ul
then u32 0x8f1bbcdc
else u32 0xca62c1d6
(* Section 6.1.2 Step 3 *)
let word_block = Seq.lseq (word SHA1) (block_word_length SHA1)
let step3_body'_aux
(mi: word_block)
(st: words_state SHA1)
(t: size_t {v t < 80})
(wt: word SHA1 { wt == w mi t } )
: Tot (words_state SHA1)
= let sta = Seq.index st 0 in
let stb = Seq.index st 1 in
let stc = Seq.index st 2 in
let std = Seq.index st 3 in
let ste = Seq.index st 4 in
let _T = (sta <<<. 5ul) +. f t stb stc std +. ste +. k t +. wt in
let e = std in
let d = stc in
let c = stb <<<. 30ul in
let b = sta in
let a = _T in
let l : list uint32 = [
a;
b;
c;
d;
e;
] in
assert_norm (List.Tot.length l = 5);
Seq.seq_of_list l
[@"opaque_to_smt"]
let step3_body' = step3_body'_aux
#reset-options "--z3rlimit 50"
[@unifier_hint_injective]
inline_for_extraction
let step3_body_w_t
(mi: word_block)
: Tot Type
= (t: nat { t < 80 }) -> Tot (wt: word SHA1 { wt == w' mi t } )
let step3_body
(mi: word_block)
(w: step3_body_w_t mi)
(st: words_state SHA1)
(t: nat {t < 80})
: Tot (words_state SHA1)
= step3_body' mi st (size t) (w t)
inline_for_extraction
let index_compute_w
(mi: word_block)
(cwt: Seq.lseq (word SHA1) 80 { compute_w_post mi 80 cwt } )
: Tot (step3_body_w_t mi)
= fun (t: nat {t < 80}) -> (Seq.index cwt t <: (wt: word SHA1 { wt == w' mi t }))
let step3_aux
(mi: word_block)
(h: words_state SHA1)
: Tot (words_state SHA1)
= let cwt = compute_w mi 0 Seq.empty in
Spec.Loops.repeat_range 0 80 (step3_body mi (index_compute_w mi cwt)) h
[@"opaque_to_smt"]
let step3 = step3_aux
(* Section 6.1.2 Step 4 *)
let step4_aux
(mi: word_block)
(h: words_state SHA1)
: Tot (words_state SHA1) =
let st = step3 mi h in
let sta = Seq.index st 0 in
let stb = Seq.index st 1 in
let stc = Seq.index st 2 in
let std = Seq.index st 3 in
let ste = Seq.index st 4 in
Seq.seq_of_list [
sta +. Seq.index h 0;
stb +. Seq.index h 1;
stc +. Seq.index h 2;
std +. Seq.index h 3;
ste +. Seq.index h 4;
]
[@"opaque_to_smt"]
let step4 = step4_aux
(* Section 3.1 al. 2: words and bytes, big-endian *)
let words_of_bytes_block
(l: bytes { Seq.length l == block_length SHA1 } )
: Tot word_block
= words_of_bytes SHA1 #((block_word_length SHA1)) l
(* Section 6.1.2: outer loop body *)
let update_aux (h:words_state SHA1) l : (words_state SHA1) =
let mi = words_of_bytes_block l in
step4 mi h | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Spec.SHA1.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "Spec.Hash.Definitions",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Spec.Hash.Definitions.update_t Spec.Hash.Definitions.SHA1 | Prims.Tot | [
"total"
] | [] | [
"Spec.SHA1.update_aux"
] | [] | false | false | false | true | false | let update =
| update_aux | false |
Spec.SHA1.fst | Spec.SHA1.word_block | val word_block : Type0 | let word_block = Seq.lseq (word SHA1) (block_word_length SHA1) | {
"file_name": "specs/Spec.SHA1.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 62,
"end_line": 141,
"start_col": 0,
"start_line": 141
} | module Spec.SHA1
open Lib.IntTypes
module H = Spec.Hash.Definitions
module Seq = FStar.Seq
open Spec.Hash.Definitions
(* Source: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf *)
(* Section 5.3.1 *)
inline_for_extraction
let init_as_list : list uint32 = [
u32 0x67452301;
u32 0xefcdab89;
u32 0x98badcfe;
u32 0x10325476;
u32 0xc3d2e1f0;
]
let init : words_state SHA1 = Seq.seq_of_list init_as_list
(* Section 6.1.2 Step 1: message schedule *)
let rec w' (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: nat {t <= 79}) : GTot (word SHA1) (decreases (t)) =
if t < 16
then Seq.index mi (t)
else (w' mi (t - 3) ^. w' mi (t - 8) ^. w' mi (t - 14) ^. w' mi (t - 16)) <<<. 1ul
let w (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: size_t {v t <= 79}) : GTot (word SHA1) = w' mi (v t)
let compute_w_post
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
: GTot Type0
= (n <= 80 /\ (
forall (i: nat) . i < n ==> Seq.index res i == w' mi i
))
let compute_w_post_intro
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
(u: squash (n <= 80))
(f: (i: nat) -> Lemma
(requires (i < n))
(ensures (i < n /\ Seq.index res i == w' mi i)))
: Lemma
(compute_w_post mi n res)
= Classical.forall_intro (Classical.move_requires f)
inline_for_extraction
let compute_w_n'
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(w: ((i: nat {i < n}) -> Tot (y: word SHA1 {y == w' mi i})))
: Tot (y: word SHA1 {y == w' mi n})
= let r =
if n < 16
then Seq.index mi n
else (w (n - 3) ^. w (n - 8) ^. w (n - 14) ^. w (n - 16)) <<<. 1ul
in
r
inline_for_extraction
let compute_w_n
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(accu: Seq.lseq (word SHA1) n)
: Pure (word SHA1)
(requires (compute_w_post mi n accu))
(ensures (fun y -> n <= 79 /\ y == w' mi n))
= [@inline_let]
let w (i: nat {i < n}) : Tot (y: word SHA1 {y == w' mi i}) = Seq.index accu i in
compute_w_n' mi n w
inline_for_extraction
let compute_w_next
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) (n + 1))
(requires (compute_w_post mi n accu))
(ensures (fun accu' -> compute_w_post mi (n + 1) accu'))
= let wn = compute_w_n mi n accu in
let accu' = Seq.snoc accu wn in
assert (n + 1 <= 80);
let g
(i: nat)
: Lemma
(requires (i < n + 1))
(ensures (i < n + 1 /\ Seq.index accu' i == w' mi i))
= if i = n
then ()
else ()
in
compute_w_post_intro mi (n + 1) accu' () g;
accu'
let rec compute_w
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) 80)
(requires (compute_w_post mi n accu))
(ensures (fun res -> compute_w_post mi 80 res))
(decreases (80 - n))
= assert (n <= 80); // this assert is necessary for Z3 to prove that n <= 79 in the else branch
if n = 80
then accu
else compute_w mi (n + 1) (compute_w_next mi n accu)
(* Section 4.1.1: logical functions *)
inline_for_extraction
let f (t: size_t {v t <= 79}) (x y z: word SHA1) : Tot (word SHA1) =
if t <. 20ul
then
(x &. y) ^. (~. x &. z)
else if 39ul <. t && t <. 60ul
then
(x &. y) ^. (x &. z) ^. (y &. z)
else
x ^. y ^. z
(* Section 4.2.1 *)
inline_for_extraction
let k (t: size_t { v t <= 79 } ) : Tot (word SHA1) =
if t <. 20ul
then u32 0x5a827999
else if t <. 40ul
then u32 0x6ed9eba1
else if t <. 60ul
then u32 0x8f1bbcdc
else u32 0xca62c1d6
(* Section 6.1.2 Step 3 *) | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Spec.SHA1.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "Spec.Hash.Definitions",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"FStar.Seq.Properties.lseq",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.SHA1",
"Spec.Hash.Definitions.block_word_length"
] | [] | false | false | false | true | true | let word_block =
| Seq.lseq (word SHA1) (block_word_length SHA1) | false |
|
Spec.SHA1.fst | Spec.SHA1.init | val init: init_t SHA1 | val init: init_t SHA1 | let init : words_state SHA1 = Seq.seq_of_list init_as_list | {
"file_name": "specs/Spec.SHA1.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 58,
"end_line": 21,
"start_col": 0,
"start_line": 21
} | module Spec.SHA1
open Lib.IntTypes
module H = Spec.Hash.Definitions
module Seq = FStar.Seq
open Spec.Hash.Definitions
(* Source: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf *)
(* Section 5.3.1 *)
inline_for_extraction
let init_as_list : list uint32 = [
u32 0x67452301;
u32 0xefcdab89;
u32 0x98badcfe;
u32 0x10325476;
u32 0xc3d2e1f0;
] | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Spec.SHA1.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "Spec.Hash.Definitions",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Spec.Hash.Definitions.init_t Spec.Hash.Definitions.SHA1 | Prims.Tot | [
"total"
] | [] | [
"FStar.Seq.Base.seq_of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.SEC",
"Spec.SHA1.init_as_list",
"Spec.Hash.Definitions.words_state",
"Spec.Hash.Definitions.SHA1"
] | [] | false | false | false | true | false | let init:words_state SHA1 =
| Seq.seq_of_list init_as_list | false |
Spec.Agile.HPKE.fst | Spec.Agile.HPKE.openAuthPSK | val openAuthPSK:
cs:ciphersuite_not_export_only
-> enc:key_dh_public_s cs
-> skR:key_dh_secret_s cs
-> info:info_s cs
-> aad:AEAD.ad (aead_alg_of cs)
-> ct:AEAD.cipher (aead_alg_of cs)
-> psk:psk_s cs
-> psk_id:psk_id_s cs
-> pkS:DH.serialized_point (kem_dh_of_cs cs) ->
Tot (option (AEAD.decrypted #(aead_alg_of cs) ct)) | val openAuthPSK:
cs:ciphersuite_not_export_only
-> enc:key_dh_public_s cs
-> skR:key_dh_secret_s cs
-> info:info_s cs
-> aad:AEAD.ad (aead_alg_of cs)
-> ct:AEAD.cipher (aead_alg_of cs)
-> psk:psk_s cs
-> psk_id:psk_id_s cs
-> pkS:DH.serialized_point (kem_dh_of_cs cs) ->
Tot (option (AEAD.decrypted #(aead_alg_of cs) ct)) | let openAuthPSK cs enc skR info aad ct psk psk_id pkS =
match setupAuthPSKR cs enc skR info psk psk_id pkS with
| None -> None
| Some ctx ->
match context_open cs ctx aad ct with
| None -> None
| Some (_, pt) -> Some pt | {
"file_name": "specs/Spec.Agile.HPKE.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 29,
"end_line": 619,
"start_col": 0,
"start_line": 613
} | module Spec.Agile.HPKE
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
module HKDF = Spec.Agile.HKDF
let pow2_61 : _:unit{pow2 61 == 2305843009213693952} = assert_norm(pow2 61 == 2305843009213693952)
let pow2_35_less_than_pow2_61 : _:unit{pow2 32 * pow2 3 <= pow2 61 - 1} = assert_norm(pow2 32 * pow2 3 <= pow2 61 - 1)
let pow2_35_less_than_pow2_125 : _:unit{pow2 32 * pow2 3 <= pow2 125 - 1} = assert_norm(pow2 32 * pow2 3 <= pow2 125 - 1)
#set-options "--z3rlimit 20 --fuel 0 --ifuel 1"
/// Types
val id_kem: cs:ciphersuite -> Tot (lbytes 2)
let id_kem cs = let kem_dh, kem_hash, _, _ = cs in
match kem_dh, kem_hash with
| DH.DH_P256, Hash.SHA2_256 -> create 1 (u8 0) @| create 1 (u8 16)
| DH.DH_Curve25519, Hash.SHA2_256 -> create 1 (u8 0) @| create 1 (u8 32)
val id_kdf: cs:ciphersuite -> Tot (lbytes 2)
let id_kdf cs = let _, _, _, h = cs in
match h with
| Hash.SHA2_256 -> create 1 (u8 0) @| create 1 (u8 1)
| Hash.SHA2_384 -> create 1 (u8 0) @| create 1 (u8 2)
| Hash.SHA2_512 -> create 1 (u8 0) @| create 1 (u8 3)
val id_aead: cs:ciphersuite -> Tot (lbytes 2)
let id_aead cs = let _, _, a, _ = cs in
match a with
| Seal AEAD.AES128_GCM -> create 1 (u8 0) @| create 1 (u8 1)
| Seal AEAD.AES256_GCM -> create 1 (u8 0) @| create 1 (u8 2)
| Seal AEAD.CHACHA20_POLY1305 -> create 1 (u8 0) @| create 1 (u8 3)
| ExportOnly -> create 1 (u8 255) @| create 1 (u8 255)
val suite_id_kem: cs:ciphersuite -> Tot (lbytes size_suite_id_kem)
let suite_id_kem cs =
Seq.append label_KEM (id_kem cs)
val suite_id_hpke: cs:ciphersuite -> Tot (lbytes size_suite_id_hpke)
let suite_id_hpke cs =
Seq.append label_HPKE (id_kem cs @| id_kdf cs @| id_aead cs)
val id_of_mode: m:mode -> Tot (lbytes size_mode_identifier)
let id_of_mode m =
match m with
| Base -> create 1 (u8 0)
| PSK -> create 1 (u8 1)
| Auth -> create 1 (u8 2)
| AuthPSK -> create 1 (u8 3)
val labeled_extract:
a:hash_algorithm
-> suite_id:bytes
-> salt:bytes
-> label:bytes
-> ikm:bytes ->
Pure (lbytes (Spec.Hash.Definitions.hash_length a))
(requires
Spec.Agile.HMAC.keysized a (Seq.length salt) /\
labeled_extract_ikm_length_pred a (Seq.length suite_id + Seq.length label + Seq.length ikm))
(ensures fun _ -> True)
let labeled_extract a suite_id salt label ikm =
let labeled_ikm1 = Seq.append label_version suite_id in
let labeled_ikm2 = Seq.append labeled_ikm1 label in
let labeled_ikm3 = Seq.append labeled_ikm2 ikm in
HKDF.extract a salt labeled_ikm3
val labeled_expand:
a:hash_algorithm
-> suite_id:bytes
-> prk:bytes
-> label:bytes
-> info:bytes
-> l:size_nat ->
Pure (lbytes l)
(requires
Spec.Hash.Definitions.hash_length a <= Seq.length prk /\
Spec.Agile.HMAC.keysized a (Seq.length prk) /\
labeled_expand_info_length_pred a (Seq.length suite_id + Seq.length label + Seq.length info) /\
HKDF.expand_output_length_pred a l)
(ensures fun _ -> True)
let labeled_expand a suite_id prk label info l =
let labeled_info1 = nat_to_bytes_be 2 l in
let labeled_info2 = Seq.append labeled_info1 label_version in
let labeled_info3 = Seq.append labeled_info2 suite_id in
let labeled_info4 = Seq.append labeled_info3 label in
let labeled_info5 = Seq.append labeled_info4 info in
HKDF.expand a prk labeled_info5 l
let extract_and_expand_dh_pred (cs:ciphersuite) (dh_length:nat) =
labeled_extract_ikm_length_pred (kem_hash_of_cs cs) (size_suite_id_kem + size_label_eae_prk + dh_length)
let extract_and_expand_ctx_pred (cs:ciphersuite) (ctx_length:nat) =
labeled_expand_info_length_pred (kem_hash_of_cs cs) (size_suite_id_kem + size_label_shared_secret + ctx_length)
val extract_and_expand:
cs:ciphersuite
-> dh:bytes
-> kem_context:bytes ->
Pure (key_kem_s cs)
(requires
extract_and_expand_dh_pred cs (Seq.length dh) /\
extract_and_expand_ctx_pred cs (Seq.length kem_context))
(ensures fun _ -> True)
let extract_and_expand cs dh kem_context =
let eae_prk = labeled_extract (kem_hash_of_cs cs) (suite_id_kem cs) lbytes_empty label_eae_prk dh in
labeled_expand (kem_hash_of_cs cs) (suite_id_kem cs) eae_prk label_shared_secret kem_context (size_kem_key cs)
let deserialize_public_key cs pk = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> pk
// Extract the point coordinates by removing the first representation byte
| DH.DH_P256 -> sub pk 1 64
let serialize_public_key cs pk = match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> pk
// Add the first representation byte to the point coordinates
| DH.DH_P256 -> create 1 (u8 4) @| pk
val dkp_nist_p: cs:ciphersuite -> lbytes (size_kem_kdf cs) -> counter:uint8 -> Tot (option (key_dh_secret_s cs & key_dh_public_s cs)) (decreases 255 - v counter)
let rec dkp_nist_p cs dkp_prk counter =
let counterbyte = nat_to_intseq_be #U8 #SEC 1 (v counter) in
let bytes = labeled_expand (kem_hash_of_cs cs) (suite_id_kem cs) dkp_prk label_candidate counterbyte (size_dh_key cs) in
let bytes = Lib.Sequence.map2 (logand #U8 #SEC) bytes (Seq.create (size_dh_key cs) (u8 255)) in
let sk = nat_from_intseq_be #U8 #SEC bytes in
if sk = 0 || sk >= Spec.P256.prime then
if (v counter) = 255 then None
else dkp_nist_p cs dkp_prk (counter +! (u8 1))
else
match DH.secret_to_public (kem_dh_of_cs cs) bytes with
| Some pk -> Some (bytes, serialize_public_key cs pk)
| None ->
if (v counter) = 255 then None
else dkp_nist_p cs dkp_prk (counter +! (u8 1))
let derive_key_pair cs ikm =
match kem_dh_of_cs cs with
| DH.DH_Curve25519 -> begin
let dkp_prk = labeled_extract (kem_hash_of_cs cs) (suite_id_kem cs) lbytes_empty label_dkp_prk ikm in
let sk = labeled_expand (kem_hash_of_cs cs) (suite_id_kem cs) dkp_prk label_sk lbytes_empty (size_dh_key cs) in
match DH.secret_to_public (kem_dh_of_cs cs) sk with
| Some pk -> Some (sk, serialize_public_key cs pk)
end
| DH.DH_P256 ->
let dkp_prk = labeled_extract (kem_hash_of_cs cs) (suite_id_kem cs) lbytes_empty label_dkp_prk ikm in
dkp_nist_p cs dkp_prk (u8 0)
val prepare_dh: cs:ciphersuite -> DH.serialized_point (kem_dh_of_cs cs) -> Tot (lbytes 32)
let prepare_dh cs dh = match (kem_dh_of_cs cs) with
| DH.DH_Curve25519 -> serialize_public_key cs dh
| DH.DH_P256 -> sub dh 0 32
val encap:
cs:ciphersuite
-> skE:key_dh_secret_s cs
-> pkR:DH.serialized_point (kem_dh_of_cs cs) ->
Tot (option (key_kem_s cs & key_dh_public_s cs))
#restart-solver
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
let encap cs skE pkR =
let _ = allow_inversion Spec.Agile.DH.algorithm in
match DH.secret_to_public (kem_dh_of_cs cs) skE with
| None -> None
| Some pkE ->
let enc = serialize_public_key cs pkE in
match DH.dh (kem_dh_of_cs cs) skE pkR with
| None -> None
| Some dh ->
let pkRm = serialize_public_key cs pkR in
let kem_context = concat enc pkRm in
let dhm = prepare_dh cs dh in
assert (Seq.length kem_context = 2*size_dh_public cs);
assert (extract_and_expand_ctx_pred cs (Seq.length kem_context));
let shared_secret:key_kem_s cs = extract_and_expand cs dhm kem_context in
Some (shared_secret, enc)
val decap:
cs: ciphersuite
-> enc: key_dh_public_s cs
-> skR: key_dh_secret_s cs ->
Tot (option (key_kem_s cs))
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
let decap cs enc skR =
let _ = allow_inversion Spec.Agile.DH.algorithm in
let _ = allow_inversion Spec.Agile.Hash.hash_alg in
let pkE = deserialize_public_key cs enc in
match DH.dh (kem_dh_of_cs cs) skR pkE with
| None -> None
| Some dh ->
match DH.secret_to_public (kem_dh_of_cs cs) skR with
| None -> None
| Some pkR ->
let pkRm = serialize_public_key cs pkR in
let kem_context = concat enc pkRm in
let dhm = prepare_dh cs dh in
assert (Seq.length kem_context = 2*size_dh_public cs);
assert (extract_and_expand_ctx_pred cs (Seq.length kem_context));
let shared_secret = extract_and_expand cs dhm kem_context in
Some (shared_secret)
val auth_encap:
cs:ciphersuite
-> skE:key_dh_secret_s cs
-> pkR:DH.serialized_point (kem_dh_of_cs cs)
-> skS:key_dh_secret_s cs ->
Tot (option (key_kem_s cs & key_dh_public_s cs))
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
let auth_encap cs skE pkR skS =
let _ = allow_inversion Spec.Agile.DH.algorithm in
match DH.secret_to_public (kem_dh_of_cs cs) skE with
| None -> None
| Some pkE ->
match DH.dh (kem_dh_of_cs cs) skE pkR with
| None -> None
| Some es ->
match DH.dh (kem_dh_of_cs cs) skS pkR with
| None -> None
| Some ss ->
let esm = prepare_dh cs es in
let ssm = prepare_dh cs ss in
// TODO Do not put 32 literally
let dh = concat #uint8 #32 #32 esm ssm in
let enc = serialize_public_key cs pkE in
match DH.secret_to_public (kem_dh_of_cs cs) skS with
| None -> None
| Some pkS ->
let pkSm = serialize_public_key cs pkS in
let pkRm = serialize_public_key cs pkR in
let kem_context = concat enc (concat pkRm pkSm) in
assert (Seq.length kem_context = 3*size_dh_public cs);
assert (labeled_expand_info_length_pred (kem_hash_of_cs cs) (size_suite_id_kem + size_label_shared_secret + Seq.length kem_context));
assert (extract_and_expand_ctx_pred cs (Seq.length kem_context));
// TODO Do not put 64 literally
assert (Seq.length dh = 64);
assert (labeled_extract_ikm_length_pred (kem_hash_of_cs cs) (size_suite_id_kem + size_label_eae_prk + Seq.length dh));
assert (extract_and_expand_dh_pred cs (Seq.length dh));
let shared_secret = extract_and_expand cs dh kem_context in
Some (shared_secret, enc)
#reset-options
val auth_decap:
cs: ciphersuite
-> enc: key_dh_public_s cs
-> skR: key_dh_secret_s cs
-> pkS: DH.serialized_point (kem_dh_of_cs cs) ->
Tot (option (key_kem_s cs))
#restart-solver
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
let auth_decap cs enc skR pkS =
let _ = allow_inversion Spec.Agile.DH.algorithm in
let pkE = deserialize_public_key cs enc in
match DH.dh (kem_dh_of_cs cs) skR pkE with
| None -> None
| Some es ->
match DH.dh (kem_dh_of_cs cs) skR pkS with
| None -> None
| Some ss ->
let esm = prepare_dh cs es in
let ssm = prepare_dh cs ss in
let dh = concat #uint8 #32 #32 esm ssm in
match DH.secret_to_public (kem_dh_of_cs cs) skR with
| None -> None
| Some pkR ->
let pkRm = serialize_public_key cs pkR in
let pkSm = serialize_public_key cs pkS in
let kem_context = concat enc (concat pkRm pkSm) in
assert (Seq.length kem_context = 3*size_dh_public cs);
assert (labeled_expand_info_length_pred (kem_hash_of_cs cs) (size_suite_id_kem + size_label_shared_secret + Seq.length kem_context));
assert (extract_and_expand_ctx_pred cs (Seq.length kem_context));
assert (Seq.length dh = 64);
assert (labeled_extract_ikm_length_pred (kem_hash_of_cs cs) (size_suite_id_kem + size_label_eae_prk + Seq.length dh));
assert (extract_and_expand_dh_pred cs (Seq.length dh));
let shared_secret = extract_and_expand cs dh kem_context in
Some (shared_secret)
#reset-options
let default_psk = lbytes_empty
let default_psk_id = lbytes_empty
val build_context:
cs:ciphersuite
-> m:mode
-> psk_id_hash:lbytes (size_kdf cs)
-> info_hash:lbytes (size_kdf cs) ->
Tot (lbytes (size_ks_ctx cs))
let build_context cs m psk_id_hash info_hash =
let context = id_of_mode m in
let context = Seq.append context psk_id_hash in
let context = Seq.append context info_hash in
context
let verify_psk_inputs (cs:ciphersuite) (m:mode) (opsk:option(psk_s cs & psk_id_s cs)) : bool =
match (m, opsk) with
| Base, None -> true
| PSK, Some _ -> true
| Auth, None -> true
| AuthPSK, Some _ -> true
| _, _ -> false
// key and nonce are zero-length if AEAD is Export-Only
let encryption_context (cs:ciphersuite) = key_aead_s cs & nonce_aead_s cs & seq_aead_s cs & exporter_secret_s cs
val key_schedule:
cs:ciphersuite
-> m:mode
-> shared_secret:key_kem_s cs
-> info:info_s cs
-> opsk:option (psk_s cs & psk_id_s cs) ->
Pure (encryption_context cs)
(requires verify_psk_inputs cs m opsk)
(ensures fun _ -> True)
#set-options "--z3rlimit 500 --fuel 0 --ifuel 2"
let key_schedule_core
(cs:ciphersuite)
(m:mode)
(shared_secret:key_kem_s cs)
(info:info_s cs)
(opsk:option (psk_s cs & psk_id_s cs))
: (lbytes (size_ks_ctx cs) & exporter_secret_s cs & (lbytes (Spec.Hash.Definitions.hash_length (hash_of_cs cs)))) =
let (psk, psk_id) =
match opsk with
| None -> (default_psk, default_psk_id)
| Some (psk, psk_id) -> (psk, psk_id)
in
let psk_id_hash = labeled_extract (hash_of_cs cs) (suite_id_hpke cs) lbytes_empty label_psk_id_hash psk_id in
let info_hash = labeled_extract (hash_of_cs cs) (suite_id_hpke cs) lbytes_empty label_info_hash info in
let context = build_context cs m psk_id_hash info_hash in
let secret = labeled_extract (hash_of_cs cs) (suite_id_hpke cs) shared_secret label_secret psk in
let exporter_secret = labeled_expand (hash_of_cs cs) (suite_id_hpke cs) secret label_exp context (size_kdf cs) in
context, exporter_secret, secret
let key_schedule_end
(cs:ciphersuite)
(m:mode)
(context:lbytes (size_ks_ctx cs))
(exporter_secret:exporter_secret_s cs)
(secret:(lbytes (Spec.Hash.Definitions.hash_length (hash_of_cs cs))))
: encryption_context cs
=
if is_valid_not_export_only_ciphersuite cs then (
let key = labeled_expand (hash_of_cs cs) (suite_id_hpke cs) secret label_key context (size_aead_key cs) in
let base_nonce = labeled_expand (hash_of_cs cs) (suite_id_hpke cs) secret label_base_nonce context (size_aead_nonce cs) in
(key, base_nonce, 0, exporter_secret)
) else (
(* if AEAD is Export-Only, then skip computation of key and base_nonce *)
assert (size_aead_key cs = 0);
assert (size_aead_nonce cs = 0);
(lbytes_empty, lbytes_empty, 0, exporter_secret))
let key_schedule cs m shared_secret info opsk =
let context, exporter_secret, secret = key_schedule_core cs m shared_secret info opsk in
key_schedule_end cs m context exporter_secret secret
let key_of_ctx (cs:ciphersuite) (ctx:encryption_context cs) =
let key, _, _, _ = ctx in key
let base_nonce_of_ctx (cs:ciphersuite) (ctx:encryption_context cs) =
let _, base_nonce, _, _ = ctx in base_nonce
let seq_of_ctx (cs:ciphersuite) (ctx:encryption_context cs) =
let _, _, seq, _ = ctx in seq
let exp_sec_of_ctx (cs:ciphersuite) (ctx:encryption_context cs) =
let _, _, _, exp_sec = ctx in exp_sec
let set_seq (cs:ciphersuite) (ctx:encryption_context cs) (seq:seq_aead_s cs) =
let key, base_nonce, _, exp_sec = ctx in
(key, base_nonce, seq, exp_sec)
///
/// Encryption Context
///
let context_export cs ctx exp_ctx l =
let exp_sec = exp_sec_of_ctx cs ctx in
labeled_expand (hash_of_cs cs) (suite_id_hpke cs) exp_sec label_sec exp_ctx l
let context_compute_nonce cs ctx seq =
let base_nonce = base_nonce_of_ctx cs ctx in
let enc_seq = nat_to_bytes_be (size_aead_nonce cs) seq in
Spec.Loops.seq_map2 logxor enc_seq base_nonce
let context_increment_seq cs ctx =
let seq = seq_of_ctx cs ctx in
if seq = max_seq cs then None else
Some (set_seq cs ctx (seq + 1))
let context_seal cs ctx aad pt =
let key = key_of_ctx cs ctx in
let seq = seq_of_ctx cs ctx in
let nonce = context_compute_nonce cs ctx seq in
let ct = AEAD.encrypt key nonce aad pt in
match context_increment_seq cs ctx with
| None -> None
| Some new_ctx -> Some (new_ctx, ct)
let context_open cs ctx aad ct =
let key = key_of_ctx cs ctx in
let seq = seq_of_ctx cs ctx in
let nonce = context_compute_nonce cs ctx seq in
match AEAD.decrypt key nonce aad ct with
| None -> None
| Some pt ->
match context_increment_seq cs ctx with
| None -> None
| Some new_ctx -> Some (new_ctx, pt)
///
/// Base Mode
///
let setupBaseS cs skE pkR info =
match encap cs skE pkR with
| None -> None
| Some (shared_secret, enc) ->
let enc_ctx = key_schedule cs Base shared_secret info None in
Some (enc, enc_ctx)
let setupBaseR cs enc skR info =
let pkR = DH.secret_to_public (kem_dh_of_cs cs) skR in
let shared_secret = decap cs enc skR in
match pkR, shared_secret with
| Some pkR, Some shared_secret ->
Some (key_schedule cs Base shared_secret info None)
| _ -> None
let sealBase cs skE pkR info aad pt =
match setupBaseS cs skE pkR info with
| None -> None
| Some (enc, ctx) ->
match context_seal cs ctx aad pt with
| None -> None
| Some (_, ct) -> Some (enc, ct)
let openBase cs enc skR info aad ct =
match setupBaseR cs enc skR info with
| None -> None
| Some ctx ->
match context_open cs ctx aad ct with
| None -> None
| Some (_, pt) -> Some pt
let sendExportBase cs skE pkR info exp_ctx l =
match setupBaseS cs skE pkR info with
| None -> None
| Some (enc, ctx) ->
Some (enc, context_export cs ctx exp_ctx l)
let receiveExportBase cs enc skR info exp_ctx l =
match setupBaseR cs enc skR info with
| None -> None
| Some ctx ->
Some (context_export cs ctx exp_ctx l)
///
/// PSK mode
///
let setupPSKS cs skE pkR info psk psk_id =
match encap cs skE pkR with
| None -> None
| Some (shared_secret, enc) ->
assert (verify_psk_inputs cs PSK (Some (psk, psk_id)));
let enc_ctx = key_schedule cs PSK shared_secret info (Some (psk, psk_id)) in
Some (enc, enc_ctx)
let setupPSKR cs enc skR info psk psk_id =
let pkR = DH.secret_to_public (kem_dh_of_cs cs) skR in
let shared_secret = decap cs enc skR in
match pkR, shared_secret with
| Some pkR, Some shared_secret ->
Some (key_schedule cs PSK shared_secret info (Some (psk, psk_id)))
| _ -> None
let sealPSK cs skE pkR info aad pt psk psk_id =
match setupPSKS cs skE pkR info psk psk_id with
| None -> None
| Some (enc, ctx) ->
match context_seal cs ctx aad pt with
| None -> None
| Some (_, ct) -> Some (enc, ct)
#restart-solver
let openPSK cs enc skR info aad ct psk psk_id =
match setupPSKR cs enc skR info psk psk_id with
| None -> None
| Some ctx ->
match context_open cs ctx aad ct with
| None -> None
| Some (_, pt) -> Some pt
let sendExportPSK cs skE pkR info exp_ctx l psk psk_id =
match setupPSKS cs skE pkR info psk psk_id with
| None -> None
| Some (enc, ctx) ->
Some (enc, context_export cs ctx exp_ctx l)
let receiveExportPSK cs enc skR info exp_ctx l psk psk_id =
match setupPSKR cs enc skR info psk psk_id with
| None -> None
| Some ctx ->
Some (context_export cs ctx exp_ctx l)
///
/// Auth mode
///
let setupAuthS cs skE pkR info skS =
match auth_encap cs skE pkR skS with
| None -> None
| Some (shared_secret, enc) ->
let enc_ctx = key_schedule cs Auth shared_secret info None in
Some (enc, enc_ctx)
let setupAuthR cs enc skR info pkS =
let pkR = DH.secret_to_public (kem_dh_of_cs cs) skR in
let shared_secret = auth_decap cs enc skR pkS in
match pkR, shared_secret with
| Some pkR, Some shared_secret ->
Some (key_schedule cs Auth shared_secret info None)
| _ -> None
let sealAuth cs skE pkR info aad pt skS =
match setupAuthS cs skE pkR info skS with
| None -> None
| Some (enc, ctx) ->
match context_seal cs ctx aad pt with
| None -> None
| Some (_, ct) -> Some (enc, ct)
let openAuth cs enc skR info aad ct pkS =
match setupAuthR cs enc skR info pkS with
| None -> None
| Some ctx ->
match context_open cs ctx aad ct with
| None -> None
| Some (_, pt) -> Some pt
let sendExportAuth cs skE pkR info exp_ctx l skS =
match setupAuthS cs skE pkR info skS with
| None -> None
| Some (enc, ctx) ->
Some (enc, context_export cs ctx exp_ctx l)
let receiveExportAuth cs enc skR info exp_ctx l pkS =
match setupAuthR cs enc skR info pkS with
| None -> None
| Some ctx ->
Some (context_export cs ctx exp_ctx l)
///
/// AuthPSK mode
///
let setupAuthPSKS cs skE pkR info psk psk_id skS =
match auth_encap cs skE pkR skS with
| None -> None
| Some (shared_secret, enc) ->
let enc_ctx = key_schedule cs AuthPSK shared_secret info (Some (psk, psk_id)) in
Some (enc, enc_ctx)
let setupAuthPSKR cs enc skR info psk psk_id pkS =
let pkR = DH.secret_to_public (kem_dh_of_cs cs) skR in
let shared_secret = auth_decap cs enc skR pkS in
match pkR, shared_secret with
| Some pkR, Some shared_secret ->
Some (key_schedule cs AuthPSK shared_secret info (Some (psk, psk_id)))
| _ -> None
let sealAuthPSK cs skE pkR info aad pt psk psk_id skS =
match setupAuthPSKS cs skE pkR info psk psk_id skS with
| None -> None
| Some (enc, ctx) ->
match context_seal cs ctx aad pt with
| None -> None
| Some (_, ct) -> Some (enc, ct) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.HMAC.fsti.checked",
"Spec.Agile.HKDF.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Spec.Agile.HPKE.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Agile.HKDF",
"short_module": "HKDF"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 2,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 500,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
cs: Spec.Agile.HPKE.ciphersuite_not_export_only ->
enc: Spec.Agile.HPKE.key_dh_public_s cs ->
skR: Spec.Agile.HPKE.key_dh_secret_s cs ->
info: Spec.Agile.HPKE.info_s cs ->
aad: Spec.Agile.AEAD.ad (Spec.Agile.HPKE.aead_alg_of cs) ->
ct: Spec.Agile.AEAD.cipher (Spec.Agile.HPKE.aead_alg_of cs) ->
psk: Spec.Agile.HPKE.psk_s cs ->
psk_id: Spec.Agile.HPKE.psk_id_s cs ->
pkS: Spec.Agile.DH.serialized_point (Spec.Agile.HPKE.kem_dh_of_cs cs)
-> FStar.Pervasives.Native.option (Spec.Agile.AEAD.decrypted ct) | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.HPKE.ciphersuite_not_export_only",
"Spec.Agile.HPKE.key_dh_public_s",
"Spec.Agile.HPKE.key_dh_secret_s",
"Spec.Agile.HPKE.info_s",
"Spec.Agile.AEAD.ad",
"Spec.Agile.HPKE.aead_alg_of",
"Spec.Agile.AEAD.cipher",
"Spec.Agile.HPKE.psk_s",
"Spec.Agile.HPKE.psk_id_s",
"Spec.Agile.DH.serialized_point",
"Spec.Agile.HPKE.kem_dh_of_cs",
"Spec.Agile.HPKE.setupAuthPSKR",
"FStar.Pervasives.Native.None",
"Spec.Agile.AEAD.decrypted",
"Spec.Agile.HPKE.encryption_context",
"Spec.Agile.HPKE.context_open",
"Spec.Agile.AEAD.plain",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | false | false | let openAuthPSK cs enc skR info aad ct psk psk_id pkS =
| match setupAuthPSKR cs enc skR info psk psk_id pkS with
| None -> None
| Some ctx ->
match context_open cs ctx aad ct with
| None -> None
| Some (_, pt) -> Some pt | false |
Spec.SHA1.fst | Spec.SHA1.index_compute_w | val index_compute_w (mi: word_block) (cwt: Seq.lseq (word SHA1) 80 {compute_w_post mi 80 cwt})
: Tot (step3_body_w_t mi) | val index_compute_w (mi: word_block) (cwt: Seq.lseq (word SHA1) 80 {compute_w_post mi 80 cwt})
: Tot (step3_body_w_t mi) | let index_compute_w
(mi: word_block)
(cwt: Seq.lseq (word SHA1) 80 { compute_w_post mi 80 cwt } )
: Tot (step3_body_w_t mi)
= fun (t: nat {t < 80}) -> (Seq.index cwt t <: (wt: word SHA1 { wt == w' mi t })) | {
"file_name": "specs/Spec.SHA1.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 81,
"end_line": 194,
"start_col": 0,
"start_line": 190
} | module Spec.SHA1
open Lib.IntTypes
module H = Spec.Hash.Definitions
module Seq = FStar.Seq
open Spec.Hash.Definitions
(* Source: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf *)
(* Section 5.3.1 *)
inline_for_extraction
let init_as_list : list uint32 = [
u32 0x67452301;
u32 0xefcdab89;
u32 0x98badcfe;
u32 0x10325476;
u32 0xc3d2e1f0;
]
let init : words_state SHA1 = Seq.seq_of_list init_as_list
(* Section 6.1.2 Step 1: message schedule *)
let rec w' (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: nat {t <= 79}) : GTot (word SHA1) (decreases (t)) =
if t < 16
then Seq.index mi (t)
else (w' mi (t - 3) ^. w' mi (t - 8) ^. w' mi (t - 14) ^. w' mi (t - 16)) <<<. 1ul
let w (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: size_t {v t <= 79}) : GTot (word SHA1) = w' mi (v t)
let compute_w_post
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
: GTot Type0
= (n <= 80 /\ (
forall (i: nat) . i < n ==> Seq.index res i == w' mi i
))
let compute_w_post_intro
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
(u: squash (n <= 80))
(f: (i: nat) -> Lemma
(requires (i < n))
(ensures (i < n /\ Seq.index res i == w' mi i)))
: Lemma
(compute_w_post mi n res)
= Classical.forall_intro (Classical.move_requires f)
inline_for_extraction
let compute_w_n'
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(w: ((i: nat {i < n}) -> Tot (y: word SHA1 {y == w' mi i})))
: Tot (y: word SHA1 {y == w' mi n})
= let r =
if n < 16
then Seq.index mi n
else (w (n - 3) ^. w (n - 8) ^. w (n - 14) ^. w (n - 16)) <<<. 1ul
in
r
inline_for_extraction
let compute_w_n
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(accu: Seq.lseq (word SHA1) n)
: Pure (word SHA1)
(requires (compute_w_post mi n accu))
(ensures (fun y -> n <= 79 /\ y == w' mi n))
= [@inline_let]
let w (i: nat {i < n}) : Tot (y: word SHA1 {y == w' mi i}) = Seq.index accu i in
compute_w_n' mi n w
inline_for_extraction
let compute_w_next
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) (n + 1))
(requires (compute_w_post mi n accu))
(ensures (fun accu' -> compute_w_post mi (n + 1) accu'))
= let wn = compute_w_n mi n accu in
let accu' = Seq.snoc accu wn in
assert (n + 1 <= 80);
let g
(i: nat)
: Lemma
(requires (i < n + 1))
(ensures (i < n + 1 /\ Seq.index accu' i == w' mi i))
= if i = n
then ()
else ()
in
compute_w_post_intro mi (n + 1) accu' () g;
accu'
let rec compute_w
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) 80)
(requires (compute_w_post mi n accu))
(ensures (fun res -> compute_w_post mi 80 res))
(decreases (80 - n))
= assert (n <= 80); // this assert is necessary for Z3 to prove that n <= 79 in the else branch
if n = 80
then accu
else compute_w mi (n + 1) (compute_w_next mi n accu)
(* Section 4.1.1: logical functions *)
inline_for_extraction
let f (t: size_t {v t <= 79}) (x y z: word SHA1) : Tot (word SHA1) =
if t <. 20ul
then
(x &. y) ^. (~. x &. z)
else if 39ul <. t && t <. 60ul
then
(x &. y) ^. (x &. z) ^. (y &. z)
else
x ^. y ^. z
(* Section 4.2.1 *)
inline_for_extraction
let k (t: size_t { v t <= 79 } ) : Tot (word SHA1) =
if t <. 20ul
then u32 0x5a827999
else if t <. 40ul
then u32 0x6ed9eba1
else if t <. 60ul
then u32 0x8f1bbcdc
else u32 0xca62c1d6
(* Section 6.1.2 Step 3 *)
let word_block = Seq.lseq (word SHA1) (block_word_length SHA1)
let step3_body'_aux
(mi: word_block)
(st: words_state SHA1)
(t: size_t {v t < 80})
(wt: word SHA1 { wt == w mi t } )
: Tot (words_state SHA1)
= let sta = Seq.index st 0 in
let stb = Seq.index st 1 in
let stc = Seq.index st 2 in
let std = Seq.index st 3 in
let ste = Seq.index st 4 in
let _T = (sta <<<. 5ul) +. f t stb stc std +. ste +. k t +. wt in
let e = std in
let d = stc in
let c = stb <<<. 30ul in
let b = sta in
let a = _T in
let l : list uint32 = [
a;
b;
c;
d;
e;
] in
assert_norm (List.Tot.length l = 5);
Seq.seq_of_list l
[@"opaque_to_smt"]
let step3_body' = step3_body'_aux
#reset-options "--z3rlimit 50"
[@unifier_hint_injective]
inline_for_extraction
let step3_body_w_t
(mi: word_block)
: Tot Type
= (t: nat { t < 80 }) -> Tot (wt: word SHA1 { wt == w' mi t } )
let step3_body
(mi: word_block)
(w: step3_body_w_t mi)
(st: words_state SHA1)
(t: nat {t < 80})
: Tot (words_state SHA1)
= step3_body' mi st (size t) (w t) | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Spec.SHA1.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "Spec.Hash.Definitions",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
mi: Spec.SHA1.word_block ->
cwt:
FStar.Seq.Properties.lseq (Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA1) 80
{Spec.SHA1.compute_w_post mi 80 cwt}
-> Spec.SHA1.step3_body_w_t mi | Prims.Tot | [
"total"
] | [] | [
"Spec.SHA1.word_block",
"FStar.Seq.Properties.lseq",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.SHA1",
"Spec.SHA1.compute_w_post",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.index",
"Prims.eq2",
"Spec.SHA1.w'",
"Spec.SHA1.step3_body_w_t"
] | [] | false | false | false | false | false | let index_compute_w (mi: word_block) (cwt: Seq.lseq (word SHA1) 80 {compute_w_post mi 80 cwt})
: Tot (step3_body_w_t mi) =
| fun (t: nat{t < 80}) -> (Seq.index cwt t <: (wt: word SHA1 {wt == w' mi t})) | false |
Spec.SHA1.fst | Spec.SHA1.step4_aux | val step4_aux (mi: word_block) (h: words_state SHA1) : Tot (words_state SHA1) | val step4_aux (mi: word_block) (h: words_state SHA1) : Tot (words_state SHA1) | let step4_aux
(mi: word_block)
(h: words_state SHA1)
: Tot (words_state SHA1) =
let st = step3 mi h in
let sta = Seq.index st 0 in
let stb = Seq.index st 1 in
let stc = Seq.index st 2 in
let std = Seq.index st 3 in
let ste = Seq.index st 4 in
Seq.seq_of_list [
sta +. Seq.index h 0;
stb +. Seq.index h 1;
stc +. Seq.index h 2;
std +. Seq.index h 3;
ste +. Seq.index h 4;
] | {
"file_name": "specs/Spec.SHA1.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 224,
"start_col": 0,
"start_line": 208
} | module Spec.SHA1
open Lib.IntTypes
module H = Spec.Hash.Definitions
module Seq = FStar.Seq
open Spec.Hash.Definitions
(* Source: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf *)
(* Section 5.3.1 *)
inline_for_extraction
let init_as_list : list uint32 = [
u32 0x67452301;
u32 0xefcdab89;
u32 0x98badcfe;
u32 0x10325476;
u32 0xc3d2e1f0;
]
let init : words_state SHA1 = Seq.seq_of_list init_as_list
(* Section 6.1.2 Step 1: message schedule *)
let rec w' (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: nat {t <= 79}) : GTot (word SHA1) (decreases (t)) =
if t < 16
then Seq.index mi (t)
else (w' mi (t - 3) ^. w' mi (t - 8) ^. w' mi (t - 14) ^. w' mi (t - 16)) <<<. 1ul
let w (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: size_t {v t <= 79}) : GTot (word SHA1) = w' mi (v t)
let compute_w_post
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
: GTot Type0
= (n <= 80 /\ (
forall (i: nat) . i < n ==> Seq.index res i == w' mi i
))
let compute_w_post_intro
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
(u: squash (n <= 80))
(f: (i: nat) -> Lemma
(requires (i < n))
(ensures (i < n /\ Seq.index res i == w' mi i)))
: Lemma
(compute_w_post mi n res)
= Classical.forall_intro (Classical.move_requires f)
inline_for_extraction
let compute_w_n'
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(w: ((i: nat {i < n}) -> Tot (y: word SHA1 {y == w' mi i})))
: Tot (y: word SHA1 {y == w' mi n})
= let r =
if n < 16
then Seq.index mi n
else (w (n - 3) ^. w (n - 8) ^. w (n - 14) ^. w (n - 16)) <<<. 1ul
in
r
inline_for_extraction
let compute_w_n
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(accu: Seq.lseq (word SHA1) n)
: Pure (word SHA1)
(requires (compute_w_post mi n accu))
(ensures (fun y -> n <= 79 /\ y == w' mi n))
= [@inline_let]
let w (i: nat {i < n}) : Tot (y: word SHA1 {y == w' mi i}) = Seq.index accu i in
compute_w_n' mi n w
inline_for_extraction
let compute_w_next
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) (n + 1))
(requires (compute_w_post mi n accu))
(ensures (fun accu' -> compute_w_post mi (n + 1) accu'))
= let wn = compute_w_n mi n accu in
let accu' = Seq.snoc accu wn in
assert (n + 1 <= 80);
let g
(i: nat)
: Lemma
(requires (i < n + 1))
(ensures (i < n + 1 /\ Seq.index accu' i == w' mi i))
= if i = n
then ()
else ()
in
compute_w_post_intro mi (n + 1) accu' () g;
accu'
let rec compute_w
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) 80)
(requires (compute_w_post mi n accu))
(ensures (fun res -> compute_w_post mi 80 res))
(decreases (80 - n))
= assert (n <= 80); // this assert is necessary for Z3 to prove that n <= 79 in the else branch
if n = 80
then accu
else compute_w mi (n + 1) (compute_w_next mi n accu)
(* Section 4.1.1: logical functions *)
inline_for_extraction
let f (t: size_t {v t <= 79}) (x y z: word SHA1) : Tot (word SHA1) =
if t <. 20ul
then
(x &. y) ^. (~. x &. z)
else if 39ul <. t && t <. 60ul
then
(x &. y) ^. (x &. z) ^. (y &. z)
else
x ^. y ^. z
(* Section 4.2.1 *)
inline_for_extraction
let k (t: size_t { v t <= 79 } ) : Tot (word SHA1) =
if t <. 20ul
then u32 0x5a827999
else if t <. 40ul
then u32 0x6ed9eba1
else if t <. 60ul
then u32 0x8f1bbcdc
else u32 0xca62c1d6
(* Section 6.1.2 Step 3 *)
let word_block = Seq.lseq (word SHA1) (block_word_length SHA1)
let step3_body'_aux
(mi: word_block)
(st: words_state SHA1)
(t: size_t {v t < 80})
(wt: word SHA1 { wt == w mi t } )
: Tot (words_state SHA1)
= let sta = Seq.index st 0 in
let stb = Seq.index st 1 in
let stc = Seq.index st 2 in
let std = Seq.index st 3 in
let ste = Seq.index st 4 in
let _T = (sta <<<. 5ul) +. f t stb stc std +. ste +. k t +. wt in
let e = std in
let d = stc in
let c = stb <<<. 30ul in
let b = sta in
let a = _T in
let l : list uint32 = [
a;
b;
c;
d;
e;
] in
assert_norm (List.Tot.length l = 5);
Seq.seq_of_list l
[@"opaque_to_smt"]
let step3_body' = step3_body'_aux
#reset-options "--z3rlimit 50"
[@unifier_hint_injective]
inline_for_extraction
let step3_body_w_t
(mi: word_block)
: Tot Type
= (t: nat { t < 80 }) -> Tot (wt: word SHA1 { wt == w' mi t } )
let step3_body
(mi: word_block)
(w: step3_body_w_t mi)
(st: words_state SHA1)
(t: nat {t < 80})
: Tot (words_state SHA1)
= step3_body' mi st (size t) (w t)
inline_for_extraction
let index_compute_w
(mi: word_block)
(cwt: Seq.lseq (word SHA1) 80 { compute_w_post mi 80 cwt } )
: Tot (step3_body_w_t mi)
= fun (t: nat {t < 80}) -> (Seq.index cwt t <: (wt: word SHA1 { wt == w' mi t }))
let step3_aux
(mi: word_block)
(h: words_state SHA1)
: Tot (words_state SHA1)
= let cwt = compute_w mi 0 Seq.empty in
Spec.Loops.repeat_range 0 80 (step3_body mi (index_compute_w mi cwt)) h
[@"opaque_to_smt"]
let step3 = step3_aux
(* Section 6.1.2 Step 4 *) | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Spec.SHA1.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "Spec.Hash.Definitions",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | mi: Spec.SHA1.word_block -> h: Spec.Hash.Definitions.words_state Spec.Hash.Definitions.SHA1
-> Spec.Hash.Definitions.words_state Spec.Hash.Definitions.SHA1 | Prims.Tot | [
"total"
] | [] | [
"Spec.SHA1.word_block",
"Spec.Hash.Definitions.words_state",
"Spec.Hash.Definitions.SHA1",
"FStar.Seq.Base.seq_of_list",
"Spec.Hash.Definitions.word",
"Prims.Cons",
"Lib.IntTypes.op_Plus_Dot",
"Spec.Hash.Definitions.word_t",
"Lib.IntTypes.SEC",
"FStar.Seq.Base.index",
"Prims.Nil",
"Spec.SHA1.step3"
] | [] | false | false | false | true | false | let step4_aux (mi: word_block) (h: words_state SHA1) : Tot (words_state SHA1) =
| let st = step3 mi h in
let sta = Seq.index st 0 in
let stb = Seq.index st 1 in
let stc = Seq.index st 2 in
let std = Seq.index st 3 in
let ste = Seq.index st 4 in
Seq.seq_of_list [
sta +. Seq.index h 0;
stb +. Seq.index h 1;
stc +. Seq.index h 2;
std +. Seq.index h 3;
ste +. Seq.index h 4
] | false |
Spec.SHA1.fst | Spec.SHA1.compute_w_post | val compute_w_post
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
: GTot Type0 | val compute_w_post
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
: GTot Type0 | let compute_w_post
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
: GTot Type0
= (n <= 80 /\ (
forall (i: nat) . i < n ==> Seq.index res i == w' mi i
)) | {
"file_name": "specs/Spec.SHA1.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 4,
"end_line": 39,
"start_col": 0,
"start_line": 32
} | module Spec.SHA1
open Lib.IntTypes
module H = Spec.Hash.Definitions
module Seq = FStar.Seq
open Spec.Hash.Definitions
(* Source: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf *)
(* Section 5.3.1 *)
inline_for_extraction
let init_as_list : list uint32 = [
u32 0x67452301;
u32 0xefcdab89;
u32 0x98badcfe;
u32 0x10325476;
u32 0xc3d2e1f0;
]
let init : words_state SHA1 = Seq.seq_of_list init_as_list
(* Section 6.1.2 Step 1: message schedule *)
let rec w' (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: nat {t <= 79}) : GTot (word SHA1) (decreases (t)) =
if t < 16
then Seq.index mi (t)
else (w' mi (t - 3) ^. w' mi (t - 8) ^. w' mi (t - 14) ^. w' mi (t - 16)) <<<. 1ul
let w (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: size_t {v t <= 79}) : GTot (word SHA1) = w' mi (v t) | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Spec.SHA1.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "Spec.Hash.Definitions",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
mi:
FStar.Seq.Properties.lseq (Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA1)
(Spec.Hash.Definitions.block_word_length Spec.Hash.Definitions.SHA1) ->
n: Prims.nat ->
res: FStar.Seq.Properties.lseq (Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA1) n
-> Prims.GTot Type0 | Prims.GTot | [
"sometrivial"
] | [] | [
"FStar.Seq.Properties.lseq",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.SHA1",
"Spec.Hash.Definitions.block_word_length",
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.op_LessThan",
"Prims.eq2",
"FStar.Seq.Base.index",
"Spec.SHA1.w'"
] | [] | false | false | false | false | true | let compute_w_post
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
: GTot Type0 =
| (n <= 80 /\ (forall (i: nat). i < n ==> Seq.index res i == w' mi i)) | false |
Spec.SHA1.fst | Spec.SHA1.step3_body'_aux | val step3_body'_aux
(mi: word_block)
(st: words_state SHA1)
(t: size_t{v t < 80})
(wt: word SHA1 {wt == w mi t})
: Tot (words_state SHA1) | val step3_body'_aux
(mi: word_block)
(st: words_state SHA1)
(t: size_t{v t < 80})
(wt: word SHA1 {wt == w mi t})
: Tot (words_state SHA1) | let step3_body'_aux
(mi: word_block)
(st: words_state SHA1)
(t: size_t {v t < 80})
(wt: word SHA1 { wt == w mi t } )
: Tot (words_state SHA1)
= let sta = Seq.index st 0 in
let stb = Seq.index st 1 in
let stc = Seq.index st 2 in
let std = Seq.index st 3 in
let ste = Seq.index st 4 in
let _T = (sta <<<. 5ul) +. f t stb stc std +. ste +. k t +. wt in
let e = std in
let d = stc in
let c = stb <<<. 30ul in
let b = sta in
let a = _T in
let l : list uint32 = [
a;
b;
c;
d;
e;
] in
assert_norm (List.Tot.length l = 5);
Seq.seq_of_list l | {
"file_name": "specs/Spec.SHA1.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 19,
"end_line": 168,
"start_col": 0,
"start_line": 143
} | module Spec.SHA1
open Lib.IntTypes
module H = Spec.Hash.Definitions
module Seq = FStar.Seq
open Spec.Hash.Definitions
(* Source: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf *)
(* Section 5.3.1 *)
inline_for_extraction
let init_as_list : list uint32 = [
u32 0x67452301;
u32 0xefcdab89;
u32 0x98badcfe;
u32 0x10325476;
u32 0xc3d2e1f0;
]
let init : words_state SHA1 = Seq.seq_of_list init_as_list
(* Section 6.1.2 Step 1: message schedule *)
let rec w' (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: nat {t <= 79}) : GTot (word SHA1) (decreases (t)) =
if t < 16
then Seq.index mi (t)
else (w' mi (t - 3) ^. w' mi (t - 8) ^. w' mi (t - 14) ^. w' mi (t - 16)) <<<. 1ul
let w (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: size_t {v t <= 79}) : GTot (word SHA1) = w' mi (v t)
let compute_w_post
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
: GTot Type0
= (n <= 80 /\ (
forall (i: nat) . i < n ==> Seq.index res i == w' mi i
))
let compute_w_post_intro
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
(u: squash (n <= 80))
(f: (i: nat) -> Lemma
(requires (i < n))
(ensures (i < n /\ Seq.index res i == w' mi i)))
: Lemma
(compute_w_post mi n res)
= Classical.forall_intro (Classical.move_requires f)
inline_for_extraction
let compute_w_n'
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(w: ((i: nat {i < n}) -> Tot (y: word SHA1 {y == w' mi i})))
: Tot (y: word SHA1 {y == w' mi n})
= let r =
if n < 16
then Seq.index mi n
else (w (n - 3) ^. w (n - 8) ^. w (n - 14) ^. w (n - 16)) <<<. 1ul
in
r
inline_for_extraction
let compute_w_n
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(accu: Seq.lseq (word SHA1) n)
: Pure (word SHA1)
(requires (compute_w_post mi n accu))
(ensures (fun y -> n <= 79 /\ y == w' mi n))
= [@inline_let]
let w (i: nat {i < n}) : Tot (y: word SHA1 {y == w' mi i}) = Seq.index accu i in
compute_w_n' mi n w
inline_for_extraction
let compute_w_next
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) (n + 1))
(requires (compute_w_post mi n accu))
(ensures (fun accu' -> compute_w_post mi (n + 1) accu'))
= let wn = compute_w_n mi n accu in
let accu' = Seq.snoc accu wn in
assert (n + 1 <= 80);
let g
(i: nat)
: Lemma
(requires (i < n + 1))
(ensures (i < n + 1 /\ Seq.index accu' i == w' mi i))
= if i = n
then ()
else ()
in
compute_w_post_intro mi (n + 1) accu' () g;
accu'
let rec compute_w
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) 80)
(requires (compute_w_post mi n accu))
(ensures (fun res -> compute_w_post mi 80 res))
(decreases (80 - n))
= assert (n <= 80); // this assert is necessary for Z3 to prove that n <= 79 in the else branch
if n = 80
then accu
else compute_w mi (n + 1) (compute_w_next mi n accu)
(* Section 4.1.1: logical functions *)
inline_for_extraction
let f (t: size_t {v t <= 79}) (x y z: word SHA1) : Tot (word SHA1) =
if t <. 20ul
then
(x &. y) ^. (~. x &. z)
else if 39ul <. t && t <. 60ul
then
(x &. y) ^. (x &. z) ^. (y &. z)
else
x ^. y ^. z
(* Section 4.2.1 *)
inline_for_extraction
let k (t: size_t { v t <= 79 } ) : Tot (word SHA1) =
if t <. 20ul
then u32 0x5a827999
else if t <. 40ul
then u32 0x6ed9eba1
else if t <. 60ul
then u32 0x8f1bbcdc
else u32 0xca62c1d6
(* Section 6.1.2 Step 3 *)
let word_block = Seq.lseq (word SHA1) (block_word_length SHA1) | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Spec.SHA1.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "Spec.Hash.Definitions",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
mi: Spec.SHA1.word_block ->
st: Spec.Hash.Definitions.words_state Spec.Hash.Definitions.SHA1 ->
t: Lib.IntTypes.size_t{Lib.IntTypes.v t < 80} ->
wt: Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA1 {wt == Spec.SHA1.w mi t}
-> Spec.Hash.Definitions.words_state Spec.Hash.Definitions.SHA1 | Prims.Tot | [
"total"
] | [] | [
"Spec.SHA1.word_block",
"Spec.Hash.Definitions.words_state",
"Spec.Hash.Definitions.SHA1",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Spec.Hash.Definitions.word",
"Prims.eq2",
"Spec.SHA1.w",
"FStar.Seq.Base.seq_of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.op_Equality",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.list",
"Prims.Cons",
"Prims.Nil",
"Spec.Hash.Definitions.word_t",
"Lib.IntTypes.op_Less_Less_Less_Dot",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.op_Plus_Dot",
"Spec.SHA1.f",
"Spec.SHA1.k",
"FStar.Seq.Base.index"
] | [] | false | false | false | false | false | let step3_body'_aux
(mi: word_block)
(st: words_state SHA1)
(t: size_t{v t < 80})
(wt: word SHA1 {wt == w mi t})
: Tot (words_state SHA1) =
| let sta = Seq.index st 0 in
let stb = Seq.index st 1 in
let stc = Seq.index st 2 in
let std = Seq.index st 3 in
let ste = Seq.index st 4 in
let _T = (sta <<<. 5ul) +. f t stb stc std +. ste +. k t +. wt in
let e = std in
let d = stc in
let c = stb <<<. 30ul in
let b = sta in
let a = _T in
let l:list uint32 = [a; b; c; d; e] in
assert_norm (List.Tot.length l = 5);
Seq.seq_of_list l | false |
Spec.SHA1.fst | Spec.SHA1.step3_body | val step3_body (mi: word_block) (w: step3_body_w_t mi) (st: words_state SHA1) (t: nat{t < 80})
: Tot (words_state SHA1) | val step3_body (mi: word_block) (w: step3_body_w_t mi) (st: words_state SHA1) (t: nat{t < 80})
: Tot (words_state SHA1) | let step3_body
(mi: word_block)
(w: step3_body_w_t mi)
(st: words_state SHA1)
(t: nat {t < 80})
: Tot (words_state SHA1)
= step3_body' mi st (size t) (w t) | {
"file_name": "specs/Spec.SHA1.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 34,
"end_line": 187,
"start_col": 0,
"start_line": 181
} | module Spec.SHA1
open Lib.IntTypes
module H = Spec.Hash.Definitions
module Seq = FStar.Seq
open Spec.Hash.Definitions
(* Source: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf *)
(* Section 5.3.1 *)
inline_for_extraction
let init_as_list : list uint32 = [
u32 0x67452301;
u32 0xefcdab89;
u32 0x98badcfe;
u32 0x10325476;
u32 0xc3d2e1f0;
]
let init : words_state SHA1 = Seq.seq_of_list init_as_list
(* Section 6.1.2 Step 1: message schedule *)
let rec w' (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: nat {t <= 79}) : GTot (word SHA1) (decreases (t)) =
if t < 16
then Seq.index mi (t)
else (w' mi (t - 3) ^. w' mi (t - 8) ^. w' mi (t - 14) ^. w' mi (t - 16)) <<<. 1ul
let w (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: size_t {v t <= 79}) : GTot (word SHA1) = w' mi (v t)
let compute_w_post
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
: GTot Type0
= (n <= 80 /\ (
forall (i: nat) . i < n ==> Seq.index res i == w' mi i
))
let compute_w_post_intro
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
(u: squash (n <= 80))
(f: (i: nat) -> Lemma
(requires (i < n))
(ensures (i < n /\ Seq.index res i == w' mi i)))
: Lemma
(compute_w_post mi n res)
= Classical.forall_intro (Classical.move_requires f)
inline_for_extraction
let compute_w_n'
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(w: ((i: nat {i < n}) -> Tot (y: word SHA1 {y == w' mi i})))
: Tot (y: word SHA1 {y == w' mi n})
= let r =
if n < 16
then Seq.index mi n
else (w (n - 3) ^. w (n - 8) ^. w (n - 14) ^. w (n - 16)) <<<. 1ul
in
r
inline_for_extraction
let compute_w_n
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(accu: Seq.lseq (word SHA1) n)
: Pure (word SHA1)
(requires (compute_w_post mi n accu))
(ensures (fun y -> n <= 79 /\ y == w' mi n))
= [@inline_let]
let w (i: nat {i < n}) : Tot (y: word SHA1 {y == w' mi i}) = Seq.index accu i in
compute_w_n' mi n w
inline_for_extraction
let compute_w_next
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) (n + 1))
(requires (compute_w_post mi n accu))
(ensures (fun accu' -> compute_w_post mi (n + 1) accu'))
= let wn = compute_w_n mi n accu in
let accu' = Seq.snoc accu wn in
assert (n + 1 <= 80);
let g
(i: nat)
: Lemma
(requires (i < n + 1))
(ensures (i < n + 1 /\ Seq.index accu' i == w' mi i))
= if i = n
then ()
else ()
in
compute_w_post_intro mi (n + 1) accu' () g;
accu'
let rec compute_w
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) 80)
(requires (compute_w_post mi n accu))
(ensures (fun res -> compute_w_post mi 80 res))
(decreases (80 - n))
= assert (n <= 80); // this assert is necessary for Z3 to prove that n <= 79 in the else branch
if n = 80
then accu
else compute_w mi (n + 1) (compute_w_next mi n accu)
(* Section 4.1.1: logical functions *)
inline_for_extraction
let f (t: size_t {v t <= 79}) (x y z: word SHA1) : Tot (word SHA1) =
if t <. 20ul
then
(x &. y) ^. (~. x &. z)
else if 39ul <. t && t <. 60ul
then
(x &. y) ^. (x &. z) ^. (y &. z)
else
x ^. y ^. z
(* Section 4.2.1 *)
inline_for_extraction
let k (t: size_t { v t <= 79 } ) : Tot (word SHA1) =
if t <. 20ul
then u32 0x5a827999
else if t <. 40ul
then u32 0x6ed9eba1
else if t <. 60ul
then u32 0x8f1bbcdc
else u32 0xca62c1d6
(* Section 6.1.2 Step 3 *)
let word_block = Seq.lseq (word SHA1) (block_word_length SHA1)
let step3_body'_aux
(mi: word_block)
(st: words_state SHA1)
(t: size_t {v t < 80})
(wt: word SHA1 { wt == w mi t } )
: Tot (words_state SHA1)
= let sta = Seq.index st 0 in
let stb = Seq.index st 1 in
let stc = Seq.index st 2 in
let std = Seq.index st 3 in
let ste = Seq.index st 4 in
let _T = (sta <<<. 5ul) +. f t stb stc std +. ste +. k t +. wt in
let e = std in
let d = stc in
let c = stb <<<. 30ul in
let b = sta in
let a = _T in
let l : list uint32 = [
a;
b;
c;
d;
e;
] in
assert_norm (List.Tot.length l = 5);
Seq.seq_of_list l
[@"opaque_to_smt"]
let step3_body' = step3_body'_aux
#reset-options "--z3rlimit 50"
[@unifier_hint_injective]
inline_for_extraction
let step3_body_w_t
(mi: word_block)
: Tot Type
= (t: nat { t < 80 }) -> Tot (wt: word SHA1 { wt == w' mi t } ) | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Spec.SHA1.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "Spec.Hash.Definitions",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
mi: Spec.SHA1.word_block ->
w: Spec.SHA1.step3_body_w_t mi ->
st: Spec.Hash.Definitions.words_state Spec.Hash.Definitions.SHA1 ->
t: Prims.nat{t < 80}
-> Spec.Hash.Definitions.words_state Spec.Hash.Definitions.SHA1 | Prims.Tot | [
"total"
] | [] | [
"Spec.SHA1.word_block",
"Spec.SHA1.step3_body_w_t",
"Spec.Hash.Definitions.words_state",
"Spec.Hash.Definitions.SHA1",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Spec.SHA1.step3_body'",
"Lib.IntTypes.size"
] | [] | false | false | false | false | false | let step3_body (mi: word_block) (w: step3_body_w_t mi) (st: words_state SHA1) (t: nat{t < 80})
: Tot (words_state SHA1) =
| step3_body' mi st (size t) (w t) | false |
Spec.SHA1.fst | Spec.SHA1.step3_aux | val step3_aux (mi: word_block) (h: words_state SHA1) : Tot (words_state SHA1) | val step3_aux (mi: word_block) (h: words_state SHA1) : Tot (words_state SHA1) | let step3_aux
(mi: word_block)
(h: words_state SHA1)
: Tot (words_state SHA1)
= let cwt = compute_w mi 0 Seq.empty in
Spec.Loops.repeat_range 0 80 (step3_body mi (index_compute_w mi cwt)) h | {
"file_name": "specs/Spec.SHA1.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 73,
"end_line": 201,
"start_col": 0,
"start_line": 196
} | module Spec.SHA1
open Lib.IntTypes
module H = Spec.Hash.Definitions
module Seq = FStar.Seq
open Spec.Hash.Definitions
(* Source: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf *)
(* Section 5.3.1 *)
inline_for_extraction
let init_as_list : list uint32 = [
u32 0x67452301;
u32 0xefcdab89;
u32 0x98badcfe;
u32 0x10325476;
u32 0xc3d2e1f0;
]
let init : words_state SHA1 = Seq.seq_of_list init_as_list
(* Section 6.1.2 Step 1: message schedule *)
let rec w' (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: nat {t <= 79}) : GTot (word SHA1) (decreases (t)) =
if t < 16
then Seq.index mi (t)
else (w' mi (t - 3) ^. w' mi (t - 8) ^. w' mi (t - 14) ^. w' mi (t - 16)) <<<. 1ul
let w (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: size_t {v t <= 79}) : GTot (word SHA1) = w' mi (v t)
let compute_w_post
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
: GTot Type0
= (n <= 80 /\ (
forall (i: nat) . i < n ==> Seq.index res i == w' mi i
))
let compute_w_post_intro
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
(u: squash (n <= 80))
(f: (i: nat) -> Lemma
(requires (i < n))
(ensures (i < n /\ Seq.index res i == w' mi i)))
: Lemma
(compute_w_post mi n res)
= Classical.forall_intro (Classical.move_requires f)
inline_for_extraction
let compute_w_n'
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(w: ((i: nat {i < n}) -> Tot (y: word SHA1 {y == w' mi i})))
: Tot (y: word SHA1 {y == w' mi n})
= let r =
if n < 16
then Seq.index mi n
else (w (n - 3) ^. w (n - 8) ^. w (n - 14) ^. w (n - 16)) <<<. 1ul
in
r
inline_for_extraction
let compute_w_n
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(accu: Seq.lseq (word SHA1) n)
: Pure (word SHA1)
(requires (compute_w_post mi n accu))
(ensures (fun y -> n <= 79 /\ y == w' mi n))
= [@inline_let]
let w (i: nat {i < n}) : Tot (y: word SHA1 {y == w' mi i}) = Seq.index accu i in
compute_w_n' mi n w
inline_for_extraction
let compute_w_next
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) (n + 1))
(requires (compute_w_post mi n accu))
(ensures (fun accu' -> compute_w_post mi (n + 1) accu'))
= let wn = compute_w_n mi n accu in
let accu' = Seq.snoc accu wn in
assert (n + 1 <= 80);
let g
(i: nat)
: Lemma
(requires (i < n + 1))
(ensures (i < n + 1 /\ Seq.index accu' i == w' mi i))
= if i = n
then ()
else ()
in
compute_w_post_intro mi (n + 1) accu' () g;
accu'
let rec compute_w
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) 80)
(requires (compute_w_post mi n accu))
(ensures (fun res -> compute_w_post mi 80 res))
(decreases (80 - n))
= assert (n <= 80); // this assert is necessary for Z3 to prove that n <= 79 in the else branch
if n = 80
then accu
else compute_w mi (n + 1) (compute_w_next mi n accu)
(* Section 4.1.1: logical functions *)
inline_for_extraction
let f (t: size_t {v t <= 79}) (x y z: word SHA1) : Tot (word SHA1) =
if t <. 20ul
then
(x &. y) ^. (~. x &. z)
else if 39ul <. t && t <. 60ul
then
(x &. y) ^. (x &. z) ^. (y &. z)
else
x ^. y ^. z
(* Section 4.2.1 *)
inline_for_extraction
let k (t: size_t { v t <= 79 } ) : Tot (word SHA1) =
if t <. 20ul
then u32 0x5a827999
else if t <. 40ul
then u32 0x6ed9eba1
else if t <. 60ul
then u32 0x8f1bbcdc
else u32 0xca62c1d6
(* Section 6.1.2 Step 3 *)
let word_block = Seq.lseq (word SHA1) (block_word_length SHA1)
let step3_body'_aux
(mi: word_block)
(st: words_state SHA1)
(t: size_t {v t < 80})
(wt: word SHA1 { wt == w mi t } )
: Tot (words_state SHA1)
= let sta = Seq.index st 0 in
let stb = Seq.index st 1 in
let stc = Seq.index st 2 in
let std = Seq.index st 3 in
let ste = Seq.index st 4 in
let _T = (sta <<<. 5ul) +. f t stb stc std +. ste +. k t +. wt in
let e = std in
let d = stc in
let c = stb <<<. 30ul in
let b = sta in
let a = _T in
let l : list uint32 = [
a;
b;
c;
d;
e;
] in
assert_norm (List.Tot.length l = 5);
Seq.seq_of_list l
[@"opaque_to_smt"]
let step3_body' = step3_body'_aux
#reset-options "--z3rlimit 50"
[@unifier_hint_injective]
inline_for_extraction
let step3_body_w_t
(mi: word_block)
: Tot Type
= (t: nat { t < 80 }) -> Tot (wt: word SHA1 { wt == w' mi t } )
let step3_body
(mi: word_block)
(w: step3_body_w_t mi)
(st: words_state SHA1)
(t: nat {t < 80})
: Tot (words_state SHA1)
= step3_body' mi st (size t) (w t)
inline_for_extraction
let index_compute_w
(mi: word_block)
(cwt: Seq.lseq (word SHA1) 80 { compute_w_post mi 80 cwt } )
: Tot (step3_body_w_t mi)
= fun (t: nat {t < 80}) -> (Seq.index cwt t <: (wt: word SHA1 { wt == w' mi t })) | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Spec.SHA1.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "Spec.Hash.Definitions",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | mi: Spec.SHA1.word_block -> h: Spec.Hash.Definitions.words_state Spec.Hash.Definitions.SHA1
-> Spec.Hash.Definitions.words_state Spec.Hash.Definitions.SHA1 | Prims.Tot | [
"total"
] | [] | [
"Spec.SHA1.word_block",
"Spec.Hash.Definitions.words_state",
"Spec.Hash.Definitions.SHA1",
"Spec.Loops.repeat_range",
"Spec.SHA1.step3_body",
"Spec.SHA1.index_compute_w",
"FStar.Seq.Properties.lseq",
"Spec.Hash.Definitions.word",
"Spec.SHA1.compute_w",
"FStar.Seq.Base.empty"
] | [] | false | false | false | true | false | let step3_aux (mi: word_block) (h: words_state SHA1) : Tot (words_state SHA1) =
| let cwt = compute_w mi 0 Seq.empty in
Spec.Loops.repeat_range 0 80 (step3_body mi (index_compute_w mi cwt)) h | false |
Spec.SHA1.fst | Spec.SHA1.init_as_list | val init_as_list:list uint32 | val init_as_list:list uint32 | let init_as_list : list uint32 = [
u32 0x67452301;
u32 0xefcdab89;
u32 0x98badcfe;
u32 0x10325476;
u32 0xc3d2e1f0;
] | {
"file_name": "specs/Spec.SHA1.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 1,
"end_line": 19,
"start_col": 0,
"start_line": 13
} | module Spec.SHA1
open Lib.IntTypes
module H = Spec.Hash.Definitions
module Seq = FStar.Seq
open Spec.Hash.Definitions
(* Source: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf *)
(* Section 5.3.1 *) | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Spec.SHA1.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "Spec.Hash.Definitions",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.list (Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.SEC) | Prims.Tot | [
"total"
] | [] | [
"Prims.Cons",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.SEC",
"Lib.IntTypes.u32",
"Prims.Nil"
] | [] | false | false | false | true | false | let init_as_list:list uint32 =
| [u32 0x67452301; u32 0xefcdab89; u32 0x98badcfe; u32 0x10325476; u32 0xc3d2e1f0] | false |
Spec.SHA1.fst | Spec.SHA1.w' | val w' (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: nat{t <= 79})
: GTot (word SHA1) (decreases (t)) | val w' (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: nat{t <= 79})
: GTot (word SHA1) (decreases (t)) | let rec w' (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: nat {t <= 79}) : GTot (word SHA1) (decreases (t)) =
if t < 16
then Seq.index mi (t)
else (w' mi (t - 3) ^. w' mi (t - 8) ^. w' mi (t - 14) ^. w' mi (t - 16)) <<<. 1ul | {
"file_name": "specs/Spec.SHA1.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 84,
"end_line": 28,
"start_col": 0,
"start_line": 25
} | module Spec.SHA1
open Lib.IntTypes
module H = Spec.Hash.Definitions
module Seq = FStar.Seq
open Spec.Hash.Definitions
(* Source: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf *)
(* Section 5.3.1 *)
inline_for_extraction
let init_as_list : list uint32 = [
u32 0x67452301;
u32 0xefcdab89;
u32 0x98badcfe;
u32 0x10325476;
u32 0xc3d2e1f0;
]
let init : words_state SHA1 = Seq.seq_of_list init_as_list
(* Section 6.1.2 Step 1: message schedule *) | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Spec.SHA1.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "Spec.Hash.Definitions",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
mi:
FStar.Seq.Properties.lseq (Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA1)
(Spec.Hash.Definitions.block_word_length Spec.Hash.Definitions.SHA1) ->
t: Prims.nat{t <= 79}
-> Prims.GTot (Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA1) | Prims.GTot | [
"sometrivial",
""
] | [] | [
"FStar.Seq.Properties.lseq",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.SHA1",
"Spec.Hash.Definitions.block_word_length",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"FStar.Seq.Base.index",
"Prims.bool",
"Lib.IntTypes.op_Less_Less_Less_Dot",
"Spec.Hash.Definitions.word_t",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Hat_Dot",
"Spec.SHA1.w'",
"Prims.op_Subtraction",
"FStar.UInt32.__uint_to_t"
] | [
"recursion"
] | false | false | false | false | false | let rec w' (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: nat{t <= 79})
: GTot (word SHA1) (decreases (t)) =
| if t < 16
then Seq.index mi (t)
else (w' mi (t - 3) ^. w' mi (t - 8) ^. w' mi (t - 14) ^. w' mi (t - 16)) <<<. 1ul | false |
Spec.SHA1.fst | Spec.SHA1.compute_w_n | val compute_w_n
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat{n <= 79})
(accu: Seq.lseq (word SHA1) n)
: Pure (word SHA1)
(requires (compute_w_post mi n accu))
(ensures (fun y -> n <= 79 /\ y == w' mi n)) | val compute_w_n
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat{n <= 79})
(accu: Seq.lseq (word SHA1) n)
: Pure (word SHA1)
(requires (compute_w_post mi n accu))
(ensures (fun y -> n <= 79 /\ y == w' mi n)) | let compute_w_n
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(accu: Seq.lseq (word SHA1) n)
: Pure (word SHA1)
(requires (compute_w_post mi n accu))
(ensures (fun y -> n <= 79 /\ y == w' mi n))
= [@inline_let]
let w (i: nat {i < n}) : Tot (y: word SHA1 {y == w' mi i}) = Seq.index accu i in
compute_w_n' mi n w | {
"file_name": "specs/Spec.SHA1.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 21,
"end_line": 76,
"start_col": 0,
"start_line": 67
} | module Spec.SHA1
open Lib.IntTypes
module H = Spec.Hash.Definitions
module Seq = FStar.Seq
open Spec.Hash.Definitions
(* Source: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf *)
(* Section 5.3.1 *)
inline_for_extraction
let init_as_list : list uint32 = [
u32 0x67452301;
u32 0xefcdab89;
u32 0x98badcfe;
u32 0x10325476;
u32 0xc3d2e1f0;
]
let init : words_state SHA1 = Seq.seq_of_list init_as_list
(* Section 6.1.2 Step 1: message schedule *)
let rec w' (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: nat {t <= 79}) : GTot (word SHA1) (decreases (t)) =
if t < 16
then Seq.index mi (t)
else (w' mi (t - 3) ^. w' mi (t - 8) ^. w' mi (t - 14) ^. w' mi (t - 16)) <<<. 1ul
let w (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: size_t {v t <= 79}) : GTot (word SHA1) = w' mi (v t)
let compute_w_post
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
: GTot Type0
= (n <= 80 /\ (
forall (i: nat) . i < n ==> Seq.index res i == w' mi i
))
let compute_w_post_intro
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
(u: squash (n <= 80))
(f: (i: nat) -> Lemma
(requires (i < n))
(ensures (i < n /\ Seq.index res i == w' mi i)))
: Lemma
(compute_w_post mi n res)
= Classical.forall_intro (Classical.move_requires f)
inline_for_extraction
let compute_w_n'
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(w: ((i: nat {i < n}) -> Tot (y: word SHA1 {y == w' mi i})))
: Tot (y: word SHA1 {y == w' mi n})
= let r =
if n < 16
then Seq.index mi n
else (w (n - 3) ^. w (n - 8) ^. w (n - 14) ^. w (n - 16)) <<<. 1ul
in
r | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Spec.SHA1.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "Spec.Hash.Definitions",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
mi:
FStar.Seq.Properties.lseq (Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA1)
(Spec.Hash.Definitions.block_word_length Spec.Hash.Definitions.SHA1) ->
n: Prims.nat{n <= 79} ->
accu: FStar.Seq.Properties.lseq (Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA1) n
-> Prims.Pure (Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA1) | Prims.Pure | [] | [] | [
"FStar.Seq.Properties.lseq",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.SHA1",
"Spec.Hash.Definitions.block_word_length",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Spec.SHA1.compute_w_n'",
"Prims.op_LessThan",
"Prims.eq2",
"Spec.SHA1.w'",
"FStar.Seq.Base.index",
"Spec.SHA1.compute_w_post",
"Prims.l_and"
] | [] | false | false | false | false | false | let compute_w_n
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat{n <= 79})
(accu: Seq.lseq (word SHA1) n)
: Pure (word SHA1)
(requires (compute_w_post mi n accu))
(ensures (fun y -> n <= 79 /\ y == w' mi n)) =
| [@@ inline_let ]let w (i: nat{i < n}) : Tot (y: word SHA1 {y == w' mi i}) = Seq.index accu i in
compute_w_n' mi n w | false |
Spec.SHA1.fst | Spec.SHA1.k | val k (t: size_t{v t <= 79}) : Tot (word SHA1) | val k (t: size_t{v t <= 79}) : Tot (word SHA1) | let k (t: size_t { v t <= 79 } ) : Tot (word SHA1) =
if t <. 20ul
then u32 0x5a827999
else if t <. 40ul
then u32 0x6ed9eba1
else if t <. 60ul
then u32 0x8f1bbcdc
else u32 0xca62c1d6 | {
"file_name": "specs/Spec.SHA1.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 21,
"end_line": 137,
"start_col": 0,
"start_line": 130
} | module Spec.SHA1
open Lib.IntTypes
module H = Spec.Hash.Definitions
module Seq = FStar.Seq
open Spec.Hash.Definitions
(* Source: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf *)
(* Section 5.3.1 *)
inline_for_extraction
let init_as_list : list uint32 = [
u32 0x67452301;
u32 0xefcdab89;
u32 0x98badcfe;
u32 0x10325476;
u32 0xc3d2e1f0;
]
let init : words_state SHA1 = Seq.seq_of_list init_as_list
(* Section 6.1.2 Step 1: message schedule *)
let rec w' (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: nat {t <= 79}) : GTot (word SHA1) (decreases (t)) =
if t < 16
then Seq.index mi (t)
else (w' mi (t - 3) ^. w' mi (t - 8) ^. w' mi (t - 14) ^. w' mi (t - 16)) <<<. 1ul
let w (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: size_t {v t <= 79}) : GTot (word SHA1) = w' mi (v t)
let compute_w_post
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
: GTot Type0
= (n <= 80 /\ (
forall (i: nat) . i < n ==> Seq.index res i == w' mi i
))
let compute_w_post_intro
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
(u: squash (n <= 80))
(f: (i: nat) -> Lemma
(requires (i < n))
(ensures (i < n /\ Seq.index res i == w' mi i)))
: Lemma
(compute_w_post mi n res)
= Classical.forall_intro (Classical.move_requires f)
inline_for_extraction
let compute_w_n'
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(w: ((i: nat {i < n}) -> Tot (y: word SHA1 {y == w' mi i})))
: Tot (y: word SHA1 {y == w' mi n})
= let r =
if n < 16
then Seq.index mi n
else (w (n - 3) ^. w (n - 8) ^. w (n - 14) ^. w (n - 16)) <<<. 1ul
in
r
inline_for_extraction
let compute_w_n
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(accu: Seq.lseq (word SHA1) n)
: Pure (word SHA1)
(requires (compute_w_post mi n accu))
(ensures (fun y -> n <= 79 /\ y == w' mi n))
= [@inline_let]
let w (i: nat {i < n}) : Tot (y: word SHA1 {y == w' mi i}) = Seq.index accu i in
compute_w_n' mi n w
inline_for_extraction
let compute_w_next
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) (n + 1))
(requires (compute_w_post mi n accu))
(ensures (fun accu' -> compute_w_post mi (n + 1) accu'))
= let wn = compute_w_n mi n accu in
let accu' = Seq.snoc accu wn in
assert (n + 1 <= 80);
let g
(i: nat)
: Lemma
(requires (i < n + 1))
(ensures (i < n + 1 /\ Seq.index accu' i == w' mi i))
= if i = n
then ()
else ()
in
compute_w_post_intro mi (n + 1) accu' () g;
accu'
let rec compute_w
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) 80)
(requires (compute_w_post mi n accu))
(ensures (fun res -> compute_w_post mi 80 res))
(decreases (80 - n))
= assert (n <= 80); // this assert is necessary for Z3 to prove that n <= 79 in the else branch
if n = 80
then accu
else compute_w mi (n + 1) (compute_w_next mi n accu)
(* Section 4.1.1: logical functions *)
inline_for_extraction
let f (t: size_t {v t <= 79}) (x y z: word SHA1) : Tot (word SHA1) =
if t <. 20ul
then
(x &. y) ^. (~. x &. z)
else if 39ul <. t && t <. 60ul
then
(x &. y) ^. (x &. z) ^. (y &. z)
else
x ^. y ^. z
(* Section 4.2.1 *) | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Spec.SHA1.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "Spec.Hash.Definitions",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Lib.IntTypes.size_t{Lib.IntTypes.v t <= 79}
-> Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA1 | Prims.Tot | [
"total"
] | [] | [
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.op_Less_Dot",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.u32",
"Prims.bool",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.SHA1"
] | [] | false | false | false | false | false | let k (t: size_t{v t <= 79}) : Tot (word SHA1) =
| if t <. 20ul
then u32 0x5a827999
else if t <. 40ul then u32 0x6ed9eba1 else if t <. 60ul then u32 0x8f1bbcdc else u32 0xca62c1d6 | false |
Spec.SHA1.fst | Spec.SHA1.words_of_bytes_block | val words_of_bytes_block (l: bytes{Seq.length l == block_length SHA1}) : Tot word_block | val words_of_bytes_block (l: bytes{Seq.length l == block_length SHA1}) : Tot word_block | let words_of_bytes_block
(l: bytes { Seq.length l == block_length SHA1 } )
: Tot word_block
= words_of_bytes SHA1 #((block_word_length SHA1)) l | {
"file_name": "specs/Spec.SHA1.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 51,
"end_line": 234,
"start_col": 0,
"start_line": 231
} | module Spec.SHA1
open Lib.IntTypes
module H = Spec.Hash.Definitions
module Seq = FStar.Seq
open Spec.Hash.Definitions
(* Source: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf *)
(* Section 5.3.1 *)
inline_for_extraction
let init_as_list : list uint32 = [
u32 0x67452301;
u32 0xefcdab89;
u32 0x98badcfe;
u32 0x10325476;
u32 0xc3d2e1f0;
]
let init : words_state SHA1 = Seq.seq_of_list init_as_list
(* Section 6.1.2 Step 1: message schedule *)
let rec w' (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: nat {t <= 79}) : GTot (word SHA1) (decreases (t)) =
if t < 16
then Seq.index mi (t)
else (w' mi (t - 3) ^. w' mi (t - 8) ^. w' mi (t - 14) ^. w' mi (t - 16)) <<<. 1ul
let w (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: size_t {v t <= 79}) : GTot (word SHA1) = w' mi (v t)
let compute_w_post
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
: GTot Type0
= (n <= 80 /\ (
forall (i: nat) . i < n ==> Seq.index res i == w' mi i
))
let compute_w_post_intro
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
(u: squash (n <= 80))
(f: (i: nat) -> Lemma
(requires (i < n))
(ensures (i < n /\ Seq.index res i == w' mi i)))
: Lemma
(compute_w_post mi n res)
= Classical.forall_intro (Classical.move_requires f)
inline_for_extraction
let compute_w_n'
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(w: ((i: nat {i < n}) -> Tot (y: word SHA1 {y == w' mi i})))
: Tot (y: word SHA1 {y == w' mi n})
= let r =
if n < 16
then Seq.index mi n
else (w (n - 3) ^. w (n - 8) ^. w (n - 14) ^. w (n - 16)) <<<. 1ul
in
r
inline_for_extraction
let compute_w_n
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(accu: Seq.lseq (word SHA1) n)
: Pure (word SHA1)
(requires (compute_w_post mi n accu))
(ensures (fun y -> n <= 79 /\ y == w' mi n))
= [@inline_let]
let w (i: nat {i < n}) : Tot (y: word SHA1 {y == w' mi i}) = Seq.index accu i in
compute_w_n' mi n w
inline_for_extraction
let compute_w_next
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) (n + 1))
(requires (compute_w_post mi n accu))
(ensures (fun accu' -> compute_w_post mi (n + 1) accu'))
= let wn = compute_w_n mi n accu in
let accu' = Seq.snoc accu wn in
assert (n + 1 <= 80);
let g
(i: nat)
: Lemma
(requires (i < n + 1))
(ensures (i < n + 1 /\ Seq.index accu' i == w' mi i))
= if i = n
then ()
else ()
in
compute_w_post_intro mi (n + 1) accu' () g;
accu'
let rec compute_w
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) 80)
(requires (compute_w_post mi n accu))
(ensures (fun res -> compute_w_post mi 80 res))
(decreases (80 - n))
= assert (n <= 80); // this assert is necessary for Z3 to prove that n <= 79 in the else branch
if n = 80
then accu
else compute_w mi (n + 1) (compute_w_next mi n accu)
(* Section 4.1.1: logical functions *)
inline_for_extraction
let f (t: size_t {v t <= 79}) (x y z: word SHA1) : Tot (word SHA1) =
if t <. 20ul
then
(x &. y) ^. (~. x &. z)
else if 39ul <. t && t <. 60ul
then
(x &. y) ^. (x &. z) ^. (y &. z)
else
x ^. y ^. z
(* Section 4.2.1 *)
inline_for_extraction
let k (t: size_t { v t <= 79 } ) : Tot (word SHA1) =
if t <. 20ul
then u32 0x5a827999
else if t <. 40ul
then u32 0x6ed9eba1
else if t <. 60ul
then u32 0x8f1bbcdc
else u32 0xca62c1d6
(* Section 6.1.2 Step 3 *)
let word_block = Seq.lseq (word SHA1) (block_word_length SHA1)
let step3_body'_aux
(mi: word_block)
(st: words_state SHA1)
(t: size_t {v t < 80})
(wt: word SHA1 { wt == w mi t } )
: Tot (words_state SHA1)
= let sta = Seq.index st 0 in
let stb = Seq.index st 1 in
let stc = Seq.index st 2 in
let std = Seq.index st 3 in
let ste = Seq.index st 4 in
let _T = (sta <<<. 5ul) +. f t stb stc std +. ste +. k t +. wt in
let e = std in
let d = stc in
let c = stb <<<. 30ul in
let b = sta in
let a = _T in
let l : list uint32 = [
a;
b;
c;
d;
e;
] in
assert_norm (List.Tot.length l = 5);
Seq.seq_of_list l
[@"opaque_to_smt"]
let step3_body' = step3_body'_aux
#reset-options "--z3rlimit 50"
[@unifier_hint_injective]
inline_for_extraction
let step3_body_w_t
(mi: word_block)
: Tot Type
= (t: nat { t < 80 }) -> Tot (wt: word SHA1 { wt == w' mi t } )
let step3_body
(mi: word_block)
(w: step3_body_w_t mi)
(st: words_state SHA1)
(t: nat {t < 80})
: Tot (words_state SHA1)
= step3_body' mi st (size t) (w t)
inline_for_extraction
let index_compute_w
(mi: word_block)
(cwt: Seq.lseq (word SHA1) 80 { compute_w_post mi 80 cwt } )
: Tot (step3_body_w_t mi)
= fun (t: nat {t < 80}) -> (Seq.index cwt t <: (wt: word SHA1 { wt == w' mi t }))
let step3_aux
(mi: word_block)
(h: words_state SHA1)
: Tot (words_state SHA1)
= let cwt = compute_w mi 0 Seq.empty in
Spec.Loops.repeat_range 0 80 (step3_body mi (index_compute_w mi cwt)) h
[@"opaque_to_smt"]
let step3 = step3_aux
(* Section 6.1.2 Step 4 *)
let step4_aux
(mi: word_block)
(h: words_state SHA1)
: Tot (words_state SHA1) =
let st = step3 mi h in
let sta = Seq.index st 0 in
let stb = Seq.index st 1 in
let stc = Seq.index st 2 in
let std = Seq.index st 3 in
let ste = Seq.index st 4 in
Seq.seq_of_list [
sta +. Seq.index h 0;
stb +. Seq.index h 1;
stc +. Seq.index h 2;
std +. Seq.index h 3;
ste +. Seq.index h 4;
]
[@"opaque_to_smt"]
let step4 = step4_aux
(* Section 3.1 al. 2: words and bytes, big-endian *) | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Spec.SHA1.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "Spec.Hash.Definitions",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
l:
Spec.Hash.Definitions.bytes
{FStar.Seq.Base.length l == Spec.Hash.Definitions.block_length Spec.Hash.Definitions.SHA1}
-> Spec.SHA1.word_block | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.bytes",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Prims.op_disEquality",
"FStar.Seq.Base.length",
"Lib.IntTypes.uint8",
"Spec.Hash.Definitions.block_length",
"Spec.Hash.Definitions.SHA1",
"Spec.Hash.Definitions.words_of_bytes",
"Spec.Hash.Definitions.block_word_length",
"Spec.SHA1.word_block"
] | [] | false | false | false | false | false | let words_of_bytes_block (l: bytes{Seq.length l == block_length SHA1}) : Tot word_block =
| words_of_bytes SHA1 #((block_word_length SHA1)) l | false |
Spec.SHA1.fst | Spec.SHA1.compute_w_next | val compute_w_next
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat{n <= 79})
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) (n + 1))
(requires (compute_w_post mi n accu))
(ensures (fun accu' -> compute_w_post mi (n + 1) accu')) | val compute_w_next
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat{n <= 79})
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) (n + 1))
(requires (compute_w_post mi n accu))
(ensures (fun accu' -> compute_w_post mi (n + 1) accu')) | let compute_w_next
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) (n + 1))
(requires (compute_w_post mi n accu))
(ensures (fun accu' -> compute_w_post mi (n + 1) accu'))
= let wn = compute_w_n mi n accu in
let accu' = Seq.snoc accu wn in
assert (n + 1 <= 80);
let g
(i: nat)
: Lemma
(requires (i < n + 1))
(ensures (i < n + 1 /\ Seq.index accu' i == w' mi i))
= if i = n
then ()
else ()
in
compute_w_post_intro mi (n + 1) accu' () g;
accu' | {
"file_name": "specs/Spec.SHA1.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 7,
"end_line": 99,
"start_col": 0,
"start_line": 79
} | module Spec.SHA1
open Lib.IntTypes
module H = Spec.Hash.Definitions
module Seq = FStar.Seq
open Spec.Hash.Definitions
(* Source: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf *)
(* Section 5.3.1 *)
inline_for_extraction
let init_as_list : list uint32 = [
u32 0x67452301;
u32 0xefcdab89;
u32 0x98badcfe;
u32 0x10325476;
u32 0xc3d2e1f0;
]
let init : words_state SHA1 = Seq.seq_of_list init_as_list
(* Section 6.1.2 Step 1: message schedule *)
let rec w' (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: nat {t <= 79}) : GTot (word SHA1) (decreases (t)) =
if t < 16
then Seq.index mi (t)
else (w' mi (t - 3) ^. w' mi (t - 8) ^. w' mi (t - 14) ^. w' mi (t - 16)) <<<. 1ul
let w (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: size_t {v t <= 79}) : GTot (word SHA1) = w' mi (v t)
let compute_w_post
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
: GTot Type0
= (n <= 80 /\ (
forall (i: nat) . i < n ==> Seq.index res i == w' mi i
))
let compute_w_post_intro
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
(u: squash (n <= 80))
(f: (i: nat) -> Lemma
(requires (i < n))
(ensures (i < n /\ Seq.index res i == w' mi i)))
: Lemma
(compute_w_post mi n res)
= Classical.forall_intro (Classical.move_requires f)
inline_for_extraction
let compute_w_n'
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(w: ((i: nat {i < n}) -> Tot (y: word SHA1 {y == w' mi i})))
: Tot (y: word SHA1 {y == w' mi n})
= let r =
if n < 16
then Seq.index mi n
else (w (n - 3) ^. w (n - 8) ^. w (n - 14) ^. w (n - 16)) <<<. 1ul
in
r
inline_for_extraction
let compute_w_n
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(accu: Seq.lseq (word SHA1) n)
: Pure (word SHA1)
(requires (compute_w_post mi n accu))
(ensures (fun y -> n <= 79 /\ y == w' mi n))
= [@inline_let]
let w (i: nat {i < n}) : Tot (y: word SHA1 {y == w' mi i}) = Seq.index accu i in
compute_w_n' mi n w | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Spec.SHA1.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "Spec.Hash.Definitions",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
mi:
FStar.Seq.Properties.lseq (Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA1)
(Spec.Hash.Definitions.block_word_length Spec.Hash.Definitions.SHA1) ->
n: Prims.nat{n <= 79} ->
accu: FStar.Seq.Properties.lseq (Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA1) n
-> Prims.Pure
(FStar.Seq.Properties.lseq (Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA1) (n + 1)) | Prims.Pure | [] | [] | [
"FStar.Seq.Properties.lseq",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.SHA1",
"Spec.Hash.Definitions.block_word_length",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.unit",
"Spec.SHA1.compute_w_post_intro",
"Prims.op_Addition",
"Prims.op_LessThan",
"Prims.squash",
"Prims.l_and",
"Prims.eq2",
"FStar.Seq.Base.index",
"Spec.SHA1.w'",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Prims.op_Equality",
"Prims.bool",
"Prims._assert",
"FStar.Seq.Base.seq",
"FStar.Seq.Properties.snoc",
"Spec.SHA1.compute_w_n",
"Spec.SHA1.compute_w_post"
] | [] | false | false | false | false | false | let compute_w_next
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat{n <= 79})
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) (n + 1))
(requires (compute_w_post mi n accu))
(ensures (fun accu' -> compute_w_post mi (n + 1) accu')) =
| let wn = compute_w_n mi n accu in
let accu' = Seq.snoc accu wn in
assert (n + 1 <= 80);
let g (i: nat) : Lemma (requires (i < n + 1)) (ensures (i < n + 1 /\ Seq.index accu' i == w' mi i))
=
if i = n then ()
in
compute_w_post_intro mi (n + 1) accu' () g;
accu' | false |
Spec.SHA1.fst | Spec.SHA1.compute_w_post_intro | val compute_w_post_intro
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
(u: squash (n <= 80))
(f: (i: nat -> Lemma (requires (i < n)) (ensures (i < n /\ Seq.index res i == w' mi i))))
: Lemma (compute_w_post mi n res) | val compute_w_post_intro
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
(u: squash (n <= 80))
(f: (i: nat -> Lemma (requires (i < n)) (ensures (i < n /\ Seq.index res i == w' mi i))))
: Lemma (compute_w_post mi n res) | let compute_w_post_intro
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
(u: squash (n <= 80))
(f: (i: nat) -> Lemma
(requires (i < n))
(ensures (i < n /\ Seq.index res i == w' mi i)))
: Lemma
(compute_w_post mi n res)
= Classical.forall_intro (Classical.move_requires f) | {
"file_name": "specs/Spec.SHA1.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 52,
"end_line": 51,
"start_col": 0,
"start_line": 41
} | module Spec.SHA1
open Lib.IntTypes
module H = Spec.Hash.Definitions
module Seq = FStar.Seq
open Spec.Hash.Definitions
(* Source: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf *)
(* Section 5.3.1 *)
inline_for_extraction
let init_as_list : list uint32 = [
u32 0x67452301;
u32 0xefcdab89;
u32 0x98badcfe;
u32 0x10325476;
u32 0xc3d2e1f0;
]
let init : words_state SHA1 = Seq.seq_of_list init_as_list
(* Section 6.1.2 Step 1: message schedule *)
let rec w' (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: nat {t <= 79}) : GTot (word SHA1) (decreases (t)) =
if t < 16
then Seq.index mi (t)
else (w' mi (t - 3) ^. w' mi (t - 8) ^. w' mi (t - 14) ^. w' mi (t - 16)) <<<. 1ul
let w (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: size_t {v t <= 79}) : GTot (word SHA1) = w' mi (v t)
let compute_w_post
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
: GTot Type0
= (n <= 80 /\ (
forall (i: nat) . i < n ==> Seq.index res i == w' mi i
)) | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Spec.SHA1.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "Spec.Hash.Definitions",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
mi:
FStar.Seq.Properties.lseq (Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA1)
(Spec.Hash.Definitions.block_word_length Spec.Hash.Definitions.SHA1) ->
n: Prims.nat ->
res: FStar.Seq.Properties.lseq (Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA1) n ->
u32: Prims.squash (n <= 80) ->
f:
(i: Prims.nat
-> FStar.Pervasives.Lemma (requires i < n)
(ensures i < n /\ FStar.Seq.Base.index res i == Spec.SHA1.w' mi i))
-> FStar.Pervasives.Lemma (ensures Spec.SHA1.compute_w_post mi n res) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"FStar.Seq.Properties.lseq",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.SHA1",
"Spec.Hash.Definitions.block_word_length",
"Prims.nat",
"Prims.squash",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.unit",
"Prims.op_LessThan",
"Prims.l_and",
"Prims.eq2",
"FStar.Seq.Base.index",
"Spec.SHA1.w'",
"Prims.Nil",
"FStar.Pervasives.pattern",
"FStar.Classical.forall_intro",
"Prims.l_imp",
"FStar.Classical.move_requires",
"Prims.l_True",
"Spec.SHA1.compute_w_post"
] | [] | false | false | true | false | false | let compute_w_post_intro
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
(u: squash (n <= 80))
(f: (i: nat -> Lemma (requires (i < n)) (ensures (i < n /\ Seq.index res i == w' mi i))))
: Lemma (compute_w_post mi n res) =
| Classical.forall_intro (Classical.move_requires f) | false |
LList32.fst | LList32.is_list | val is_list : ll: LList32.llist -> l: Prims.list LList32.u32 -> Steel.Effect.Common.vprop | let is_list (ll:llist) (l:list u32) = is_list ll l | {
"file_name": "share/steel/examples/steel/LList32.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 50,
"end_line": 40,
"start_col": 0,
"start_line": 40
} | (*
Copyright 2021 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.
Author: Aseem Rastogi
*)
module LList32
open Steel.Memory
open Steel.ST.Effect
open Steel.ST.Util
open LList.ST
module G = FStar.Ghost
/// Monomorphization of LList.ST for UInt32
#set-options "--ide_id_info_off"
type u32 = FStar.UInt32.t
inline_for_extraction
let llist_node = llist_node u32
inline_for_extraction
let llist = llist u32 | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.ST.Effect.fsti.checked",
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"LList.ST.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LList32.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": false,
"full_module": "LList.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | ll: LList32.llist -> l: Prims.list LList32.u32 -> Steel.Effect.Common.vprop | Prims.Tot | [
"total"
] | [] | [
"LList32.llist",
"Prims.list",
"LList32.u32",
"LList.ST.is_list",
"Steel.Effect.Common.vprop"
] | [] | false | false | false | true | false | let is_list (ll: llist) (l: list u32) =
| is_list ll l | false |
|
LList32.fst | LList32.llist_node | val llist_node : Type0 | let llist_node = llist_node u32 | {
"file_name": "share/steel/examples/steel/LList32.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 31,
"end_line": 35,
"start_col": 0,
"start_line": 35
} | (*
Copyright 2021 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.
Author: Aseem Rastogi
*)
module LList32
open Steel.Memory
open Steel.ST.Effect
open Steel.ST.Util
open LList.ST
module G = FStar.Ghost
/// Monomorphization of LList.ST for UInt32
#set-options "--ide_id_info_off"
type u32 = FStar.UInt32.t | {
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.ST.Effect.fsti.checked",
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"LList.ST.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LList32.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": false,
"full_module": "LList.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 | Type0 | Prims.Tot | [
"total"
] | [] | [
"LList.ST.llist_node",
"LList32.u32"
] | [] | false | false | false | true | true | let llist_node =
| llist_node u32 | false |
|
Spec.SHA1.fst | Spec.SHA1.compute_w | val compute_w
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) 80)
(requires (compute_w_post mi n accu))
(ensures (fun res -> compute_w_post mi 80 res))
(decreases (80 - n)) | val compute_w
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) 80)
(requires (compute_w_post mi n accu))
(ensures (fun res -> compute_w_post mi 80 res))
(decreases (80 - n)) | let rec compute_w
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) 80)
(requires (compute_w_post mi n accu))
(ensures (fun res -> compute_w_post mi 80 res))
(decreases (80 - n))
= assert (n <= 80); // this assert is necessary for Z3 to prove that n <= 79 in the else branch
if n = 80
then accu
else compute_w mi (n + 1) (compute_w_next mi n accu) | {
"file_name": "specs/Spec.SHA1.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 54,
"end_line": 112,
"start_col": 0,
"start_line": 101
} | module Spec.SHA1
open Lib.IntTypes
module H = Spec.Hash.Definitions
module Seq = FStar.Seq
open Spec.Hash.Definitions
(* Source: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf *)
(* Section 5.3.1 *)
inline_for_extraction
let init_as_list : list uint32 = [
u32 0x67452301;
u32 0xefcdab89;
u32 0x98badcfe;
u32 0x10325476;
u32 0xc3d2e1f0;
]
let init : words_state SHA1 = Seq.seq_of_list init_as_list
(* Section 6.1.2 Step 1: message schedule *)
let rec w' (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: nat {t <= 79}) : GTot (word SHA1) (decreases (t)) =
if t < 16
then Seq.index mi (t)
else (w' mi (t - 3) ^. w' mi (t - 8) ^. w' mi (t - 14) ^. w' mi (t - 16)) <<<. 1ul
let w (mi: Seq.lseq (word SHA1) (block_word_length SHA1)) (t: size_t {v t <= 79}) : GTot (word SHA1) = w' mi (v t)
let compute_w_post
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
: GTot Type0
= (n <= 80 /\ (
forall (i: nat) . i < n ==> Seq.index res i == w' mi i
))
let compute_w_post_intro
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(res: Seq.lseq (word SHA1) n)
(u: squash (n <= 80))
(f: (i: nat) -> Lemma
(requires (i < n))
(ensures (i < n /\ Seq.index res i == w' mi i)))
: Lemma
(compute_w_post mi n res)
= Classical.forall_intro (Classical.move_requires f)
inline_for_extraction
let compute_w_n'
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(w: ((i: nat {i < n}) -> Tot (y: word SHA1 {y == w' mi i})))
: Tot (y: word SHA1 {y == w' mi n})
= let r =
if n < 16
then Seq.index mi n
else (w (n - 3) ^. w (n - 8) ^. w (n - 14) ^. w (n - 16)) <<<. 1ul
in
r
inline_for_extraction
let compute_w_n
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(accu: Seq.lseq (word SHA1) n)
: Pure (word SHA1)
(requires (compute_w_post mi n accu))
(ensures (fun y -> n <= 79 /\ y == w' mi n))
= [@inline_let]
let w (i: nat {i < n}) : Tot (y: word SHA1 {y == w' mi i}) = Seq.index accu i in
compute_w_n' mi n w
inline_for_extraction
let compute_w_next
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat { n <= 79 } )
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) (n + 1))
(requires (compute_w_post mi n accu))
(ensures (fun accu' -> compute_w_post mi (n + 1) accu'))
= let wn = compute_w_n mi n accu in
let accu' = Seq.snoc accu wn in
assert (n + 1 <= 80);
let g
(i: nat)
: Lemma
(requires (i < n + 1))
(ensures (i < n + 1 /\ Seq.index accu' i == w' mi i))
= if i = n
then ()
else ()
in
compute_w_post_intro mi (n + 1) accu' () g;
accu' | {
"checked_file": "/",
"dependencies": [
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Spec.SHA1.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "Spec.Hash.Definitions",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
mi:
FStar.Seq.Properties.lseq (Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA1)
(Spec.Hash.Definitions.block_word_length Spec.Hash.Definitions.SHA1) ->
n: Prims.nat ->
accu: FStar.Seq.Properties.lseq (Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA1) n
-> Prims.Pure
(FStar.Seq.Properties.lseq (Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA1) 80) | Prims.Pure | [
""
] | [] | [
"FStar.Seq.Properties.lseq",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.SHA1",
"Spec.Hash.Definitions.block_word_length",
"Prims.nat",
"Prims.op_Equality",
"Prims.int",
"Prims.bool",
"Spec.SHA1.compute_w",
"Prims.op_Addition",
"Spec.SHA1.compute_w_next",
"Prims.unit",
"Prims._assert",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Spec.SHA1.compute_w_post"
] | [
"recursion"
] | false | false | false | false | false | let rec compute_w
(mi: Seq.lseq (word SHA1) (block_word_length SHA1))
(n: nat)
(accu: Seq.lseq (word SHA1) n)
: Pure (Seq.lseq (word SHA1) 80)
(requires (compute_w_post mi n accu))
(ensures (fun res -> compute_w_post mi 80 res))
(decreases (80 - n)) =
| assert (n <= 80);
if n = 80 then accu else compute_w mi (n + 1) (compute_w_next mi n accu) | false |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.