effect
stringclasses 48
values | original_source_type
stringlengths 0
23k
| opens_and_abbrevs
listlengths 2
92
| isa_cross_project_example
bool 1
class | source_definition
stringlengths 9
57.9k
| partial_definition
stringlengths 7
23.3k
| is_div
bool 2
classes | is_type
null | is_proof
bool 2
classes | completed_definiton
stringlengths 1
250k
| dependencies
dict | effect_flags
sequencelengths 0
2
| ideal_premises
sequencelengths 0
236
| mutual_with
sequencelengths 0
11
| file_context
stringlengths 0
407k
| interleaved
bool 1
class | is_simply_typed
bool 2
classes | file_name
stringlengths 5
48
| vconfig
dict | is_simple_lemma
null | source_type
stringlengths 10
23k
| proof_features
sequencelengths 0
1
| name
stringlengths 8
95
| source
dict | verbose_type
stringlengths 1
7.42k
| source_range
dict |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Vale.AES.X64.GCTR",
"short_module": "GC"
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret}) | let t128_no_mod = | false | null | false | TD_Buffer TUInt8 TUInt128 ({ modified = false; strict_disjointness = false; taint = MS.Secret }) | {
"checked_file": "Vale.Stdcalls.X64.GCTR.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.AES.X64.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.UInt64.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.GCTR.fst"
} | [
"total"
] | [
"Vale.Interop.Base.TD_Buffer",
"Vale.Arch.HeapTypes_s.TUInt8",
"Vale.Arch.HeapTypes_s.TUInt128",
"Vale.Interop.Base.Mkbuffer_qualifiers",
"Vale.Arch.HeapTypes_s.Secret"
] | [] | module Vale.Stdcalls.X64.GCTR
open FStar.HyperStack.ST
module B = LowStar.Buffer
module HS = FStar.HyperStack
open FStar.Mul
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AES.AES_s
module GC = Vale.AES.X64.GCTR
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b128 = buf_t TUInt8 TUInt128
[@__reduce__] noextract
let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq | false | true | Vale.Stdcalls.X64.GCTR.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val t128_no_mod : Vale.Interop.Base.td | [] | Vale.Stdcalls.X64.GCTR.t128_no_mod | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCTR.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Vale.Interop.Base.td | {
"end_col": 106,
"end_line": 40,
"start_col": 18,
"start_line": 40
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Vale.AES.X64.GCTR",
"short_module": "GC"
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let tuint64 = TD_Base TUInt64 | let tuint64 = | false | null | false | TD_Base TUInt64 | {
"checked_file": "Vale.Stdcalls.X64.GCTR.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.AES.X64.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.UInt64.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.GCTR.fst"
} | [
"total"
] | [
"Vale.Interop.Base.TD_Base",
"Vale.Arch.HeapTypes_s.TUInt64"
] | [] | module Vale.Stdcalls.X64.GCTR
open FStar.HyperStack.ST
module B = LowStar.Buffer
module HS = FStar.HyperStack
open FStar.Mul
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AES.AES_s
module GC = Vale.AES.X64.GCTR
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b128 = buf_t TUInt8 TUInt128
[@__reduce__] noextract
let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq
[@__reduce__] noextract
let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret}) | false | true | Vale.Stdcalls.X64.GCTR.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val tuint64 : Vale.Interop.Base.td | [] | Vale.Stdcalls.X64.GCTR.tuint64 | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCTR.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Vale.Interop.Base.td | {
"end_col": 29,
"end_line": 42,
"start_col": 14,
"start_line": 42
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Vale.AES.X64.GCTR",
"short_module": "GC"
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let code_gctr256 = GC.va_code_Gctr_bytes_stdcall IA.win AES_256 | let code_gctr256 = | false | null | false | GC.va_code_Gctr_bytes_stdcall IA.win AES_256 | {
"checked_file": "Vale.Stdcalls.X64.GCTR.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.AES.X64.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.UInt64.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.GCTR.fst"
} | [
"total"
] | [
"Vale.AES.X64.GCTR.va_code_Gctr_bytes_stdcall",
"Vale.Interop.Assumptions.win",
"Vale.AES.AES_common_s.AES_256"
] | [] | module Vale.Stdcalls.X64.GCTR
open FStar.HyperStack.ST
module B = LowStar.Buffer
module HS = FStar.HyperStack
open FStar.Mul
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AES.AES_s
module GC = Vale.AES.X64.GCTR
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b128 = buf_t TUInt8 TUInt128
[@__reduce__] noextract
let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq
[@__reduce__] noextract
let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let (dom: list td{List.length dom <= 20}) =
let y = [t128_no_mod; tuint64; t128_mod; t128_mod; t128_no_mod; t128_no_mod; tuint64] in
assert_norm (List.length y = 7);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr128_pre : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state) ->
GC.va_req_Gctr_bytes_stdcall c va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s)
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr128_post : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_post dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
GC.va_ens_Gctr_bytes_stdcall c va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) va_s1 f
#set-options "--z3rlimit 20"
[@__reduce__] noextract
let gctr128_lemma'
(s:Ghost.erased (Seq.seq nat32))
(code:V.va_code)
(_win:bool)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
gctr128_pre s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
gctr128_post s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer in_b) /\
ME.buffer_writeable (as_vale_buffer keys_b) /\
ME.buffer_writeable (as_vale_buffer ctr_b) /\
ME.buffer_writeable (as_vale_buffer inout_b) /\
ME.buffer_writeable (as_vale_buffer out_b)
)) =
let va_s1, f = GC.va_lemma_Gctr_bytes_stdcall code va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 ctr_b;
(va_s1, f)
noextract
let gctr128_lemma (s:Ghost.erased (Seq.seq nat32)) = as_t #(VSig.vale_sig_stdcall (gctr128_pre s) (gctr128_post s)) (gctr128_lemma' s)
noextract
let code_gctr128 = GC.va_code_Gctr_bytes_stdcall IA.win AES_128
[@__reduce__] noextract
let lowstar_gctr128_t (s:Ghost.erased (Seq.seq nat32)) =
assert_norm (List.length dom + List.length ([]<:list arg) <= 20);
IX64.as_lowstar_sig_t_weak_stdcall
code_gctr128
dom
[]
_
_
(W.mk_prediction code_gctr128 dom [] ((gctr128_lemma s) code_gctr128 IA.win))
(* And here's the gcm wrapper itself *)
noextract
let lowstar_gctr128 (s:Ghost.erased (Seq.seq nat32)) : lowstar_gctr128_t s =
assert_norm (List.length dom + List.length ([]<:list arg) <= 20);
IX64.wrap_weak_stdcall
code_gctr128
dom
(W.mk_prediction code_gctr128 dom [] ((gctr128_lemma s) code_gctr128 IA.win))
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr256_pre : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state) ->
GC.va_req_Gctr_bytes_stdcall c va_s0 IA.win AES_256
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s)
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr256_post : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_post dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
GC.va_ens_Gctr_bytes_stdcall c va_s0 IA.win AES_256
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) va_s1 f
#set-options "--z3rlimit 20"
[@__reduce__] noextract
let gctr256_lemma'
(s:Ghost.erased (Seq.seq nat32))
(code:V.va_code)
(_win:bool)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
gctr256_pre s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
gctr256_post s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer in_b) /\
ME.buffer_writeable (as_vale_buffer keys_b) /\
ME.buffer_writeable (as_vale_buffer ctr_b) /\
ME.buffer_writeable (as_vale_buffer inout_b) /\
ME.buffer_writeable (as_vale_buffer out_b)
)) =
let va_s1, f = GC.va_lemma_Gctr_bytes_stdcall code va_s0 IA.win AES_256
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 ctr_b;
(va_s1, f)
noextract
let gctr256_lemma (s:Ghost.erased (Seq.seq nat32)) = as_t #(VSig.vale_sig_stdcall (gctr256_pre s) (gctr256_post s)) (gctr256_lemma' s) | false | true | Vale.Stdcalls.X64.GCTR.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val code_gctr256 : Vale.X64.Decls.va_code | [] | Vale.Stdcalls.X64.GCTR.code_gctr256 | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCTR.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Vale.X64.Decls.va_code | {
"end_col": 63,
"end_line": 234,
"start_col": 19,
"start_line": 234
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Vale.AES.X64.GCTR",
"short_module": "GC"
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let code_gctr128 = GC.va_code_Gctr_bytes_stdcall IA.win AES_128 | let code_gctr128 = | false | null | false | GC.va_code_Gctr_bytes_stdcall IA.win AES_128 | {
"checked_file": "Vale.Stdcalls.X64.GCTR.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.AES.X64.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.UInt64.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.GCTR.fst"
} | [
"total"
] | [
"Vale.AES.X64.GCTR.va_code_Gctr_bytes_stdcall",
"Vale.Interop.Assumptions.win",
"Vale.AES.AES_common_s.AES_128"
] | [] | module Vale.Stdcalls.X64.GCTR
open FStar.HyperStack.ST
module B = LowStar.Buffer
module HS = FStar.HyperStack
open FStar.Mul
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AES.AES_s
module GC = Vale.AES.X64.GCTR
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b128 = buf_t TUInt8 TUInt128
[@__reduce__] noextract
let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq
[@__reduce__] noextract
let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let (dom: list td{List.length dom <= 20}) =
let y = [t128_no_mod; tuint64; t128_mod; t128_mod; t128_no_mod; t128_no_mod; tuint64] in
assert_norm (List.length y = 7);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr128_pre : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state) ->
GC.va_req_Gctr_bytes_stdcall c va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s)
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr128_post : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_post dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
GC.va_ens_Gctr_bytes_stdcall c va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) va_s1 f
#set-options "--z3rlimit 20"
[@__reduce__] noextract
let gctr128_lemma'
(s:Ghost.erased (Seq.seq nat32))
(code:V.va_code)
(_win:bool)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
gctr128_pre s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
gctr128_post s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer in_b) /\
ME.buffer_writeable (as_vale_buffer keys_b) /\
ME.buffer_writeable (as_vale_buffer ctr_b) /\
ME.buffer_writeable (as_vale_buffer inout_b) /\
ME.buffer_writeable (as_vale_buffer out_b)
)) =
let va_s1, f = GC.va_lemma_Gctr_bytes_stdcall code va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 ctr_b;
(va_s1, f)
noextract
let gctr128_lemma (s:Ghost.erased (Seq.seq nat32)) = as_t #(VSig.vale_sig_stdcall (gctr128_pre s) (gctr128_post s)) (gctr128_lemma' s) | false | true | Vale.Stdcalls.X64.GCTR.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val code_gctr128 : Vale.X64.Decls.va_code | [] | Vale.Stdcalls.X64.GCTR.code_gctr128 | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCTR.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Vale.X64.Decls.va_code | {
"end_col": 63,
"end_line": 131,
"start_col": 19,
"start_line": 131
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Vale.AES.X64.GCTR",
"short_module": "GC"
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let gctr128_bytes //: normal ((s:Ghost.erased (Seq.seq nat32)) -> lowstar_gctr128_t s)
= as_normal_t #((s:Ghost.erased (Seq.seq nat32)) -> lowstar_gctr128_t s) (fun (s:Ghost.erased (Seq.seq nat32)) -> lowstar_gctr128 s) | let gctr128_bytes = | false | null | false | as_normal_t #(s: Ghost.erased (Seq.seq nat32) -> lowstar_gctr128_t s)
(fun (s: Ghost.erased (Seq.seq nat32)) -> lowstar_gctr128 s) | {
"checked_file": "Vale.Stdcalls.X64.GCTR.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.AES.X64.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.UInt64.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.GCTR.fst"
} | [
"total"
] | [
"Vale.Stdcalls.X64.GCTR.as_normal_t",
"FStar.Ghost.erased",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat32",
"Vale.Stdcalls.X64.GCTR.lowstar_gctr128_t",
"Vale.Stdcalls.X64.GCTR.lowstar_gctr128"
] | [] | module Vale.Stdcalls.X64.GCTR
open FStar.HyperStack.ST
module B = LowStar.Buffer
module HS = FStar.HyperStack
open FStar.Mul
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AES.AES_s
module GC = Vale.AES.X64.GCTR
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b128 = buf_t TUInt8 TUInt128
[@__reduce__] noextract
let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq
[@__reduce__] noextract
let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let (dom: list td{List.length dom <= 20}) =
let y = [t128_no_mod; tuint64; t128_mod; t128_mod; t128_no_mod; t128_no_mod; tuint64] in
assert_norm (List.length y = 7);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr128_pre : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state) ->
GC.va_req_Gctr_bytes_stdcall c va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s)
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr128_post : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_post dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
GC.va_ens_Gctr_bytes_stdcall c va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) va_s1 f
#set-options "--z3rlimit 20"
[@__reduce__] noextract
let gctr128_lemma'
(s:Ghost.erased (Seq.seq nat32))
(code:V.va_code)
(_win:bool)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
gctr128_pre s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
gctr128_post s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer in_b) /\
ME.buffer_writeable (as_vale_buffer keys_b) /\
ME.buffer_writeable (as_vale_buffer ctr_b) /\
ME.buffer_writeable (as_vale_buffer inout_b) /\
ME.buffer_writeable (as_vale_buffer out_b)
)) =
let va_s1, f = GC.va_lemma_Gctr_bytes_stdcall code va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 ctr_b;
(va_s1, f)
noextract
let gctr128_lemma (s:Ghost.erased (Seq.seq nat32)) = as_t #(VSig.vale_sig_stdcall (gctr128_pre s) (gctr128_post s)) (gctr128_lemma' s)
noextract
let code_gctr128 = GC.va_code_Gctr_bytes_stdcall IA.win AES_128
[@__reduce__] noextract
let lowstar_gctr128_t (s:Ghost.erased (Seq.seq nat32)) =
assert_norm (List.length dom + List.length ([]<:list arg) <= 20);
IX64.as_lowstar_sig_t_weak_stdcall
code_gctr128
dom
[]
_
_
(W.mk_prediction code_gctr128 dom [] ((gctr128_lemma s) code_gctr128 IA.win))
(* And here's the gcm wrapper itself *)
noextract
let lowstar_gctr128 (s:Ghost.erased (Seq.seq nat32)) : lowstar_gctr128_t s =
assert_norm (List.length dom + List.length ([]<:list arg) <= 20);
IX64.wrap_weak_stdcall
code_gctr128
dom
(W.mk_prediction code_gctr128 dom [] ((gctr128_lemma s) code_gctr128 IA.win))
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr256_pre : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state) ->
GC.va_req_Gctr_bytes_stdcall c va_s0 IA.win AES_256
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s)
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr256_post : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_post dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
GC.va_ens_Gctr_bytes_stdcall c va_s0 IA.win AES_256
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) va_s1 f
#set-options "--z3rlimit 20"
[@__reduce__] noextract
let gctr256_lemma'
(s:Ghost.erased (Seq.seq nat32))
(code:V.va_code)
(_win:bool)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
gctr256_pre s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
gctr256_post s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer in_b) /\
ME.buffer_writeable (as_vale_buffer keys_b) /\
ME.buffer_writeable (as_vale_buffer ctr_b) /\
ME.buffer_writeable (as_vale_buffer inout_b) /\
ME.buffer_writeable (as_vale_buffer out_b)
)) =
let va_s1, f = GC.va_lemma_Gctr_bytes_stdcall code va_s0 IA.win AES_256
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 ctr_b;
(va_s1, f)
noextract
let gctr256_lemma (s:Ghost.erased (Seq.seq nat32)) = as_t #(VSig.vale_sig_stdcall (gctr256_pre s) (gctr256_post s)) (gctr256_lemma' s)
noextract
let code_gctr256 = GC.va_code_Gctr_bytes_stdcall IA.win AES_256
[@__reduce__] noextract
let lowstar_gctr256_t (s:Ghost.erased (Seq.seq nat32)) =
assert_norm (List.length dom + List.length ([]<:list arg) <= 20);
IX64.as_lowstar_sig_t_weak_stdcall
code_gctr256
dom
[]
_
_
(W.mk_prediction code_gctr256 dom [] ((gctr256_lemma s) code_gctr256 IA.win))
(* And here's the gcm wrapper itself *)
noextract
let lowstar_gctr256 (s:Ghost.erased (Seq.seq nat32)) : lowstar_gctr256_t s =
assert_norm (List.length dom + List.length ([]<:list arg) <= 20);
IX64.wrap_weak_stdcall
code_gctr256
dom
(W.mk_prediction code_gctr256 dom [] ((gctr256_lemma s) code_gctr256 IA.win))
[@ (CCConv "stdcall") ] | false | false | Vale.Stdcalls.X64.GCTR.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val gctr128_bytes : Vale.Interop.Base.normal (s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32)
-> Vale.Stdcalls.X64.GCTR.lowstar_gctr128_t s) | [] | Vale.Stdcalls.X64.GCTR.gctr128_bytes | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCTR.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Vale.Interop.Base.normal (s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32)
-> Vale.Stdcalls.X64.GCTR.lowstar_gctr128_t s) | {
"end_col": 134,
"end_line": 258,
"start_col": 4,
"start_line": 258
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Vale.AES.X64.GCTR",
"short_module": "GC"
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let gctr256_bytes //: normal ((s:Ghost.erased (Seq.seq nat32)) -> lowstar_gctr256_t s)
= as_normal_t #((s:Ghost.erased (Seq.seq nat32)) -> lowstar_gctr256_t s) (fun (s:Ghost.erased (Seq.seq nat32)) -> lowstar_gctr256 s) | let gctr256_bytes = | false | null | false | as_normal_t #(s: Ghost.erased (Seq.seq nat32) -> lowstar_gctr256_t s)
(fun (s: Ghost.erased (Seq.seq nat32)) -> lowstar_gctr256 s) | {
"checked_file": "Vale.Stdcalls.X64.GCTR.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.AES.X64.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.UInt64.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.GCTR.fst"
} | [
"total"
] | [
"Vale.Stdcalls.X64.GCTR.as_normal_t",
"FStar.Ghost.erased",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat32",
"Vale.Stdcalls.X64.GCTR.lowstar_gctr256_t",
"Vale.Stdcalls.X64.GCTR.lowstar_gctr256"
] | [] | module Vale.Stdcalls.X64.GCTR
open FStar.HyperStack.ST
module B = LowStar.Buffer
module HS = FStar.HyperStack
open FStar.Mul
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AES.AES_s
module GC = Vale.AES.X64.GCTR
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b128 = buf_t TUInt8 TUInt128
[@__reduce__] noextract
let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq
[@__reduce__] noextract
let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let (dom: list td{List.length dom <= 20}) =
let y = [t128_no_mod; tuint64; t128_mod; t128_mod; t128_no_mod; t128_no_mod; tuint64] in
assert_norm (List.length y = 7);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr128_pre : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state) ->
GC.va_req_Gctr_bytes_stdcall c va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s)
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr128_post : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_post dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
GC.va_ens_Gctr_bytes_stdcall c va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) va_s1 f
#set-options "--z3rlimit 20"
[@__reduce__] noextract
let gctr128_lemma'
(s:Ghost.erased (Seq.seq nat32))
(code:V.va_code)
(_win:bool)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
gctr128_pre s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
gctr128_post s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer in_b) /\
ME.buffer_writeable (as_vale_buffer keys_b) /\
ME.buffer_writeable (as_vale_buffer ctr_b) /\
ME.buffer_writeable (as_vale_buffer inout_b) /\
ME.buffer_writeable (as_vale_buffer out_b)
)) =
let va_s1, f = GC.va_lemma_Gctr_bytes_stdcall code va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 ctr_b;
(va_s1, f)
noextract
let gctr128_lemma (s:Ghost.erased (Seq.seq nat32)) = as_t #(VSig.vale_sig_stdcall (gctr128_pre s) (gctr128_post s)) (gctr128_lemma' s)
noextract
let code_gctr128 = GC.va_code_Gctr_bytes_stdcall IA.win AES_128
[@__reduce__] noextract
let lowstar_gctr128_t (s:Ghost.erased (Seq.seq nat32)) =
assert_norm (List.length dom + List.length ([]<:list arg) <= 20);
IX64.as_lowstar_sig_t_weak_stdcall
code_gctr128
dom
[]
_
_
(W.mk_prediction code_gctr128 dom [] ((gctr128_lemma s) code_gctr128 IA.win))
(* And here's the gcm wrapper itself *)
noextract
let lowstar_gctr128 (s:Ghost.erased (Seq.seq nat32)) : lowstar_gctr128_t s =
assert_norm (List.length dom + List.length ([]<:list arg) <= 20);
IX64.wrap_weak_stdcall
code_gctr128
dom
(W.mk_prediction code_gctr128 dom [] ((gctr128_lemma s) code_gctr128 IA.win))
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr256_pre : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state) ->
GC.va_req_Gctr_bytes_stdcall c va_s0 IA.win AES_256
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s)
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr256_post : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_post dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
GC.va_ens_Gctr_bytes_stdcall c va_s0 IA.win AES_256
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) va_s1 f
#set-options "--z3rlimit 20"
[@__reduce__] noextract
let gctr256_lemma'
(s:Ghost.erased (Seq.seq nat32))
(code:V.va_code)
(_win:bool)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
gctr256_pre s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
gctr256_post s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer in_b) /\
ME.buffer_writeable (as_vale_buffer keys_b) /\
ME.buffer_writeable (as_vale_buffer ctr_b) /\
ME.buffer_writeable (as_vale_buffer inout_b) /\
ME.buffer_writeable (as_vale_buffer out_b)
)) =
let va_s1, f = GC.va_lemma_Gctr_bytes_stdcall code va_s0 IA.win AES_256
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 ctr_b;
(va_s1, f)
noextract
let gctr256_lemma (s:Ghost.erased (Seq.seq nat32)) = as_t #(VSig.vale_sig_stdcall (gctr256_pre s) (gctr256_post s)) (gctr256_lemma' s)
noextract
let code_gctr256 = GC.va_code_Gctr_bytes_stdcall IA.win AES_256
[@__reduce__] noextract
let lowstar_gctr256_t (s:Ghost.erased (Seq.seq nat32)) =
assert_norm (List.length dom + List.length ([]<:list arg) <= 20);
IX64.as_lowstar_sig_t_weak_stdcall
code_gctr256
dom
[]
_
_
(W.mk_prediction code_gctr256 dom [] ((gctr256_lemma s) code_gctr256 IA.win))
(* And here's the gcm wrapper itself *)
noextract
let lowstar_gctr256 (s:Ghost.erased (Seq.seq nat32)) : lowstar_gctr256_t s =
assert_norm (List.length dom + List.length ([]<:list arg) <= 20);
IX64.wrap_weak_stdcall
code_gctr256
dom
(W.mk_prediction code_gctr256 dom [] ((gctr256_lemma s) code_gctr256 IA.win))
[@ (CCConv "stdcall") ]
let gctr128_bytes //: normal ((s:Ghost.erased (Seq.seq nat32)) -> lowstar_gctr128_t s)
= as_normal_t #((s:Ghost.erased (Seq.seq nat32)) -> lowstar_gctr128_t s) (fun (s:Ghost.erased (Seq.seq nat32)) -> lowstar_gctr128 s)
[@ (CCConv "stdcall") ] | false | false | Vale.Stdcalls.X64.GCTR.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val gctr256_bytes : Vale.Interop.Base.normal (s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32)
-> Vale.Stdcalls.X64.GCTR.lowstar_gctr256_t s) | [] | Vale.Stdcalls.X64.GCTR.gctr256_bytes | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCTR.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Vale.Interop.Base.normal (s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32)
-> Vale.Stdcalls.X64.GCTR.lowstar_gctr256_t s) | {
"end_col": 134,
"end_line": 262,
"start_col": 4,
"start_line": 262
} |
|
Prims.Tot | val as_normal_t (#a: Type) (x: a) : normal a | [
{
"abbrev": true,
"full_module": "Vale.AES.X64.GCTR",
"short_module": "GC"
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let as_normal_t (#a:Type) (x:a) : normal a = x | val as_normal_t (#a: Type) (x: a) : normal a
let as_normal_t (#a: Type) (x: a) : normal a = | false | null | false | x | {
"checked_file": "Vale.Stdcalls.X64.GCTR.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.AES.X64.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.UInt64.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.GCTR.fst"
} | [
"total"
] | [
"Vale.Interop.Base.normal"
] | [] | module Vale.Stdcalls.X64.GCTR
open FStar.HyperStack.ST
module B = LowStar.Buffer
module HS = FStar.HyperStack
open FStar.Mul
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AES.AES_s
module GC = Vale.AES.X64.GCTR
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x | false | false | Vale.Stdcalls.X64.GCTR.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val as_normal_t (#a: Type) (x: a) : normal a | [] | Vale.Stdcalls.X64.GCTR.as_normal_t | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCTR.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: a -> Vale.Interop.Base.normal a | {
"end_col": 46,
"end_line": 33,
"start_col": 45,
"start_line": 33
} |
Prims.Tot | val as_t (#a: Type) (x: normal a) : a | [
{
"abbrev": true,
"full_module": "Vale.AES.X64.GCTR",
"short_module": "GC"
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let as_t (#a:Type) (x:normal a) : a = x | val as_t (#a: Type) (x: normal a) : a
let as_t (#a: Type) (x: normal a) : a = | false | null | false | x | {
"checked_file": "Vale.Stdcalls.X64.GCTR.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.AES.X64.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.UInt64.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.GCTR.fst"
} | [
"total"
] | [
"Vale.Interop.Base.normal"
] | [] | module Vale.Stdcalls.X64.GCTR
open FStar.HyperStack.ST
module B = LowStar.Buffer
module HS = FStar.HyperStack
open FStar.Mul
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AES.AES_s
module GC = Vale.AES.X64.GCTR
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *) | false | false | Vale.Stdcalls.X64.GCTR.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val as_t (#a: Type) (x: normal a) : a | [] | Vale.Stdcalls.X64.GCTR.as_t | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCTR.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Vale.Interop.Base.normal a -> a | {
"end_col": 39,
"end_line": 31,
"start_col": 38,
"start_line": 31
} |
Prims.Tot | val dom:dom: list td {List.length dom <= 20} | [
{
"abbrev": true,
"full_module": "Vale.AES.X64.GCTR",
"short_module": "GC"
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let (dom: list td{List.length dom <= 20}) =
let y = [t128_no_mod; tuint64; t128_mod; t128_mod; t128_no_mod; t128_no_mod; tuint64] in
assert_norm (List.length y = 7);
y | val dom:dom: list td {List.length dom <= 20}
let dom:dom: list td {List.length dom <= 20} = | false | null | false | let y = [t128_no_mod; tuint64; t128_mod; t128_mod; t128_no_mod; t128_no_mod; tuint64] in
assert_norm (List.length y = 7);
y | {
"checked_file": "Vale.Stdcalls.X64.GCTR.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.AES.X64.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.UInt64.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.GCTR.fst"
} | [
"total"
] | [
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"FStar.List.Tot.Base.length",
"Vale.Interop.Base.td",
"Prims.list",
"Prims.Cons",
"Vale.Stdcalls.X64.GCTR.t128_no_mod",
"Vale.Stdcalls.X64.GCTR.tuint64",
"Vale.Stdcalls.X64.GCTR.t128_mod",
"Prims.Nil"
] | [] | module Vale.Stdcalls.X64.GCTR
open FStar.HyperStack.ST
module B = LowStar.Buffer
module HS = FStar.HyperStack
open FStar.Mul
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AES.AES_s
module GC = Vale.AES.X64.GCTR
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b128 = buf_t TUInt8 TUInt128
[@__reduce__] noextract
let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq
[@__reduce__] noextract
let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64 | false | false | Vale.Stdcalls.X64.GCTR.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val dom:dom: list td {List.length dom <= 20} | [] | Vale.Stdcalls.X64.GCTR.dom | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCTR.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | dom: Prims.list Vale.Interop.Base.td {FStar.List.Tot.Base.length dom <= 20} | {
"end_col": 3,
"end_line": 48,
"start_col": 43,
"start_line": 45
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Vale.AES.X64.GCTR",
"short_module": "GC"
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lowstar_gctr128_t (s:Ghost.erased (Seq.seq nat32)) =
assert_norm (List.length dom + List.length ([]<:list arg) <= 20);
IX64.as_lowstar_sig_t_weak_stdcall
code_gctr128
dom
[]
_
_
(W.mk_prediction code_gctr128 dom [] ((gctr128_lemma s) code_gctr128 IA.win)) | let lowstar_gctr128_t (s: Ghost.erased (Seq.seq nat32)) = | false | null | false | assert_norm (List.length dom + List.length ([] <: list arg) <= 20);
IX64.as_lowstar_sig_t_weak_stdcall code_gctr128
dom
[]
_
_
(W.mk_prediction code_gctr128 dom [] ((gctr128_lemma s) code_gctr128 IA.win)) | {
"checked_file": "Vale.Stdcalls.X64.GCTR.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.AES.X64.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.UInt64.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.GCTR.fst"
} | [
"total"
] | [
"FStar.Ghost.erased",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat32",
"Vale.Interop.X64.as_lowstar_sig_t_weak_stdcall",
"Vale.Stdcalls.X64.GCTR.code_gctr128",
"Vale.Stdcalls.X64.GCTR.dom",
"Prims.Nil",
"Vale.Interop.Base.arg",
"Vale.AsLowStar.Wrapper.pre_rel_generic",
"Vale.Interop.X64.max_stdcall",
"Vale.Interop.X64.arg_reg_stdcall",
"Vale.Stdcalls.X64.GCTR.gctr128_pre",
"Vale.AsLowStar.Wrapper.post_rel_generic",
"Vale.Stdcalls.X64.GCTR.gctr128_post",
"Vale.AsLowStar.Wrapper.mk_prediction",
"Vale.Interop.X64.regs_modified_stdcall",
"Vale.Interop.X64.xmms_modified_stdcall",
"Vale.Stdcalls.X64.GCTR.gctr128_lemma",
"Vale.Interop.Assumptions.win",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"FStar.List.Tot.Base.length",
"Vale.Interop.Base.td",
"Prims.list"
] | [] | module Vale.Stdcalls.X64.GCTR
open FStar.HyperStack.ST
module B = LowStar.Buffer
module HS = FStar.HyperStack
open FStar.Mul
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AES.AES_s
module GC = Vale.AES.X64.GCTR
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b128 = buf_t TUInt8 TUInt128
[@__reduce__] noextract
let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq
[@__reduce__] noextract
let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let (dom: list td{List.length dom <= 20}) =
let y = [t128_no_mod; tuint64; t128_mod; t128_mod; t128_no_mod; t128_no_mod; tuint64] in
assert_norm (List.length y = 7);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr128_pre : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state) ->
GC.va_req_Gctr_bytes_stdcall c va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s)
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr128_post : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_post dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
GC.va_ens_Gctr_bytes_stdcall c va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) va_s1 f
#set-options "--z3rlimit 20"
[@__reduce__] noextract
let gctr128_lemma'
(s:Ghost.erased (Seq.seq nat32))
(code:V.va_code)
(_win:bool)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
gctr128_pre s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
gctr128_post s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer in_b) /\
ME.buffer_writeable (as_vale_buffer keys_b) /\
ME.buffer_writeable (as_vale_buffer ctr_b) /\
ME.buffer_writeable (as_vale_buffer inout_b) /\
ME.buffer_writeable (as_vale_buffer out_b)
)) =
let va_s1, f = GC.va_lemma_Gctr_bytes_stdcall code va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 ctr_b;
(va_s1, f)
noextract
let gctr128_lemma (s:Ghost.erased (Seq.seq nat32)) = as_t #(VSig.vale_sig_stdcall (gctr128_pre s) (gctr128_post s)) (gctr128_lemma' s)
noextract
let code_gctr128 = GC.va_code_Gctr_bytes_stdcall IA.win AES_128
[@__reduce__] noextract | false | true | Vale.Stdcalls.X64.GCTR.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lowstar_gctr128_t : s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32) -> Type0 | [] | Vale.Stdcalls.X64.GCTR.lowstar_gctr128_t | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCTR.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32) -> Type0 | {
"end_col": 81,
"end_line": 142,
"start_col": 2,
"start_line": 135
} |
|
Prims.Tot | val lowstar_gctr256 (s: Ghost.erased (Seq.seq nat32)) : lowstar_gctr256_t s | [
{
"abbrev": true,
"full_module": "Vale.AES.X64.GCTR",
"short_module": "GC"
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lowstar_gctr256 (s:Ghost.erased (Seq.seq nat32)) : lowstar_gctr256_t s =
assert_norm (List.length dom + List.length ([]<:list arg) <= 20);
IX64.wrap_weak_stdcall
code_gctr256
dom
(W.mk_prediction code_gctr256 dom [] ((gctr256_lemma s) code_gctr256 IA.win)) | val lowstar_gctr256 (s: Ghost.erased (Seq.seq nat32)) : lowstar_gctr256_t s
let lowstar_gctr256 (s: Ghost.erased (Seq.seq nat32)) : lowstar_gctr256_t s = | false | null | false | assert_norm (List.length dom + List.length ([] <: list arg) <= 20);
IX64.wrap_weak_stdcall code_gctr256
dom
(W.mk_prediction code_gctr256 dom [] ((gctr256_lemma s) code_gctr256 IA.win)) | {
"checked_file": "Vale.Stdcalls.X64.GCTR.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.AES.X64.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.UInt64.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.GCTR.fst"
} | [
"total"
] | [
"FStar.Ghost.erased",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat32",
"Vale.Interop.X64.wrap_weak_stdcall",
"Vale.Stdcalls.X64.GCTR.code_gctr256",
"Vale.Stdcalls.X64.GCTR.dom",
"Vale.AsLowStar.Wrapper.pre_rel_generic",
"Vale.Interop.X64.max_stdcall",
"Vale.Interop.X64.arg_reg_stdcall",
"Prims.Nil",
"Vale.Interop.Base.arg",
"Vale.Stdcalls.X64.GCTR.gctr256_pre",
"Vale.AsLowStar.Wrapper.post_rel_generic",
"Vale.Stdcalls.X64.GCTR.gctr256_post",
"Vale.AsLowStar.Wrapper.mk_prediction",
"Vale.Interop.X64.regs_modified_stdcall",
"Vale.Interop.X64.xmms_modified_stdcall",
"Vale.Stdcalls.X64.GCTR.gctr256_lemma",
"Vale.Interop.Assumptions.win",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"FStar.List.Tot.Base.length",
"Vale.Interop.Base.td",
"Prims.list",
"Vale.Stdcalls.X64.GCTR.lowstar_gctr256_t"
] | [] | module Vale.Stdcalls.X64.GCTR
open FStar.HyperStack.ST
module B = LowStar.Buffer
module HS = FStar.HyperStack
open FStar.Mul
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AES.AES_s
module GC = Vale.AES.X64.GCTR
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b128 = buf_t TUInt8 TUInt128
[@__reduce__] noextract
let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq
[@__reduce__] noextract
let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let (dom: list td{List.length dom <= 20}) =
let y = [t128_no_mod; tuint64; t128_mod; t128_mod; t128_no_mod; t128_no_mod; tuint64] in
assert_norm (List.length y = 7);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr128_pre : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state) ->
GC.va_req_Gctr_bytes_stdcall c va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s)
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr128_post : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_post dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
GC.va_ens_Gctr_bytes_stdcall c va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) va_s1 f
#set-options "--z3rlimit 20"
[@__reduce__] noextract
let gctr128_lemma'
(s:Ghost.erased (Seq.seq nat32))
(code:V.va_code)
(_win:bool)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
gctr128_pre s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
gctr128_post s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer in_b) /\
ME.buffer_writeable (as_vale_buffer keys_b) /\
ME.buffer_writeable (as_vale_buffer ctr_b) /\
ME.buffer_writeable (as_vale_buffer inout_b) /\
ME.buffer_writeable (as_vale_buffer out_b)
)) =
let va_s1, f = GC.va_lemma_Gctr_bytes_stdcall code va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 ctr_b;
(va_s1, f)
noextract
let gctr128_lemma (s:Ghost.erased (Seq.seq nat32)) = as_t #(VSig.vale_sig_stdcall (gctr128_pre s) (gctr128_post s)) (gctr128_lemma' s)
noextract
let code_gctr128 = GC.va_code_Gctr_bytes_stdcall IA.win AES_128
[@__reduce__] noextract
let lowstar_gctr128_t (s:Ghost.erased (Seq.seq nat32)) =
assert_norm (List.length dom + List.length ([]<:list arg) <= 20);
IX64.as_lowstar_sig_t_weak_stdcall
code_gctr128
dom
[]
_
_
(W.mk_prediction code_gctr128 dom [] ((gctr128_lemma s) code_gctr128 IA.win))
(* And here's the gcm wrapper itself *)
noextract
let lowstar_gctr128 (s:Ghost.erased (Seq.seq nat32)) : lowstar_gctr128_t s =
assert_norm (List.length dom + List.length ([]<:list arg) <= 20);
IX64.wrap_weak_stdcall
code_gctr128
dom
(W.mk_prediction code_gctr128 dom [] ((gctr128_lemma s) code_gctr128 IA.win))
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr256_pre : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state) ->
GC.va_req_Gctr_bytes_stdcall c va_s0 IA.win AES_256
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s)
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr256_post : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_post dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
GC.va_ens_Gctr_bytes_stdcall c va_s0 IA.win AES_256
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) va_s1 f
#set-options "--z3rlimit 20"
[@__reduce__] noextract
let gctr256_lemma'
(s:Ghost.erased (Seq.seq nat32))
(code:V.va_code)
(_win:bool)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
gctr256_pre s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
gctr256_post s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer in_b) /\
ME.buffer_writeable (as_vale_buffer keys_b) /\
ME.buffer_writeable (as_vale_buffer ctr_b) /\
ME.buffer_writeable (as_vale_buffer inout_b) /\
ME.buffer_writeable (as_vale_buffer out_b)
)) =
let va_s1, f = GC.va_lemma_Gctr_bytes_stdcall code va_s0 IA.win AES_256
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 ctr_b;
(va_s1, f)
noextract
let gctr256_lemma (s:Ghost.erased (Seq.seq nat32)) = as_t #(VSig.vale_sig_stdcall (gctr256_pre s) (gctr256_post s)) (gctr256_lemma' s)
noextract
let code_gctr256 = GC.va_code_Gctr_bytes_stdcall IA.win AES_256
[@__reduce__] noextract
let lowstar_gctr256_t (s:Ghost.erased (Seq.seq nat32)) =
assert_norm (List.length dom + List.length ([]<:list arg) <= 20);
IX64.as_lowstar_sig_t_weak_stdcall
code_gctr256
dom
[]
_
_
(W.mk_prediction code_gctr256 dom [] ((gctr256_lemma s) code_gctr256 IA.win))
(* And here's the gcm wrapper itself *)
noextract | false | false | Vale.Stdcalls.X64.GCTR.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lowstar_gctr256 (s: Ghost.erased (Seq.seq nat32)) : lowstar_gctr256_t s | [] | Vale.Stdcalls.X64.GCTR.lowstar_gctr256 | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCTR.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32)
-> Vale.Stdcalls.X64.GCTR.lowstar_gctr256_t s | {
"end_col": 81,
"end_line": 254,
"start_col": 2,
"start_line": 250
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Vale.AES.X64.GCTR",
"short_module": "GC"
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lowstar_gctr256_t (s:Ghost.erased (Seq.seq nat32)) =
assert_norm (List.length dom + List.length ([]<:list arg) <= 20);
IX64.as_lowstar_sig_t_weak_stdcall
code_gctr256
dom
[]
_
_
(W.mk_prediction code_gctr256 dom [] ((gctr256_lemma s) code_gctr256 IA.win)) | let lowstar_gctr256_t (s: Ghost.erased (Seq.seq nat32)) = | false | null | false | assert_norm (List.length dom + List.length ([] <: list arg) <= 20);
IX64.as_lowstar_sig_t_weak_stdcall code_gctr256
dom
[]
_
_
(W.mk_prediction code_gctr256 dom [] ((gctr256_lemma s) code_gctr256 IA.win)) | {
"checked_file": "Vale.Stdcalls.X64.GCTR.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.AES.X64.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.UInt64.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.GCTR.fst"
} | [
"total"
] | [
"FStar.Ghost.erased",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat32",
"Vale.Interop.X64.as_lowstar_sig_t_weak_stdcall",
"Vale.Stdcalls.X64.GCTR.code_gctr256",
"Vale.Stdcalls.X64.GCTR.dom",
"Prims.Nil",
"Vale.Interop.Base.arg",
"Vale.AsLowStar.Wrapper.pre_rel_generic",
"Vale.Interop.X64.max_stdcall",
"Vale.Interop.X64.arg_reg_stdcall",
"Vale.Stdcalls.X64.GCTR.gctr256_pre",
"Vale.AsLowStar.Wrapper.post_rel_generic",
"Vale.Stdcalls.X64.GCTR.gctr256_post",
"Vale.AsLowStar.Wrapper.mk_prediction",
"Vale.Interop.X64.regs_modified_stdcall",
"Vale.Interop.X64.xmms_modified_stdcall",
"Vale.Stdcalls.X64.GCTR.gctr256_lemma",
"Vale.Interop.Assumptions.win",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"FStar.List.Tot.Base.length",
"Vale.Interop.Base.td",
"Prims.list"
] | [] | module Vale.Stdcalls.X64.GCTR
open FStar.HyperStack.ST
module B = LowStar.Buffer
module HS = FStar.HyperStack
open FStar.Mul
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AES.AES_s
module GC = Vale.AES.X64.GCTR
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b128 = buf_t TUInt8 TUInt128
[@__reduce__] noextract
let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq
[@__reduce__] noextract
let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let (dom: list td{List.length dom <= 20}) =
let y = [t128_no_mod; tuint64; t128_mod; t128_mod; t128_no_mod; t128_no_mod; tuint64] in
assert_norm (List.length y = 7);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr128_pre : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state) ->
GC.va_req_Gctr_bytes_stdcall c va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s)
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr128_post : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_post dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
GC.va_ens_Gctr_bytes_stdcall c va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) va_s1 f
#set-options "--z3rlimit 20"
[@__reduce__] noextract
let gctr128_lemma'
(s:Ghost.erased (Seq.seq nat32))
(code:V.va_code)
(_win:bool)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
gctr128_pre s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
gctr128_post s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer in_b) /\
ME.buffer_writeable (as_vale_buffer keys_b) /\
ME.buffer_writeable (as_vale_buffer ctr_b) /\
ME.buffer_writeable (as_vale_buffer inout_b) /\
ME.buffer_writeable (as_vale_buffer out_b)
)) =
let va_s1, f = GC.va_lemma_Gctr_bytes_stdcall code va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 ctr_b;
(va_s1, f)
noextract
let gctr128_lemma (s:Ghost.erased (Seq.seq nat32)) = as_t #(VSig.vale_sig_stdcall (gctr128_pre s) (gctr128_post s)) (gctr128_lemma' s)
noextract
let code_gctr128 = GC.va_code_Gctr_bytes_stdcall IA.win AES_128
[@__reduce__] noextract
let lowstar_gctr128_t (s:Ghost.erased (Seq.seq nat32)) =
assert_norm (List.length dom + List.length ([]<:list arg) <= 20);
IX64.as_lowstar_sig_t_weak_stdcall
code_gctr128
dom
[]
_
_
(W.mk_prediction code_gctr128 dom [] ((gctr128_lemma s) code_gctr128 IA.win))
(* And here's the gcm wrapper itself *)
noextract
let lowstar_gctr128 (s:Ghost.erased (Seq.seq nat32)) : lowstar_gctr128_t s =
assert_norm (List.length dom + List.length ([]<:list arg) <= 20);
IX64.wrap_weak_stdcall
code_gctr128
dom
(W.mk_prediction code_gctr128 dom [] ((gctr128_lemma s) code_gctr128 IA.win))
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr256_pre : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state) ->
GC.va_req_Gctr_bytes_stdcall c va_s0 IA.win AES_256
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s)
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr256_post : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_post dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
GC.va_ens_Gctr_bytes_stdcall c va_s0 IA.win AES_256
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) va_s1 f
#set-options "--z3rlimit 20"
[@__reduce__] noextract
let gctr256_lemma'
(s:Ghost.erased (Seq.seq nat32))
(code:V.va_code)
(_win:bool)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
gctr256_pre s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
gctr256_post s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer in_b) /\
ME.buffer_writeable (as_vale_buffer keys_b) /\
ME.buffer_writeable (as_vale_buffer ctr_b) /\
ME.buffer_writeable (as_vale_buffer inout_b) /\
ME.buffer_writeable (as_vale_buffer out_b)
)) =
let va_s1, f = GC.va_lemma_Gctr_bytes_stdcall code va_s0 IA.win AES_256
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 ctr_b;
(va_s1, f)
noextract
let gctr256_lemma (s:Ghost.erased (Seq.seq nat32)) = as_t #(VSig.vale_sig_stdcall (gctr256_pre s) (gctr256_post s)) (gctr256_lemma' s)
noextract
let code_gctr256 = GC.va_code_Gctr_bytes_stdcall IA.win AES_256
[@__reduce__] noextract | false | true | Vale.Stdcalls.X64.GCTR.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lowstar_gctr256_t : s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32) -> Type0 | [] | Vale.Stdcalls.X64.GCTR.lowstar_gctr256_t | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCTR.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32) -> Type0 | {
"end_col": 81,
"end_line": 245,
"start_col": 2,
"start_line": 238
} |
|
Prims.Tot | val lowstar_gctr128 (s: Ghost.erased (Seq.seq nat32)) : lowstar_gctr128_t s | [
{
"abbrev": true,
"full_module": "Vale.AES.X64.GCTR",
"short_module": "GC"
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lowstar_gctr128 (s:Ghost.erased (Seq.seq nat32)) : lowstar_gctr128_t s =
assert_norm (List.length dom + List.length ([]<:list arg) <= 20);
IX64.wrap_weak_stdcall
code_gctr128
dom
(W.mk_prediction code_gctr128 dom [] ((gctr128_lemma s) code_gctr128 IA.win)) | val lowstar_gctr128 (s: Ghost.erased (Seq.seq nat32)) : lowstar_gctr128_t s
let lowstar_gctr128 (s: Ghost.erased (Seq.seq nat32)) : lowstar_gctr128_t s = | false | null | false | assert_norm (List.length dom + List.length ([] <: list arg) <= 20);
IX64.wrap_weak_stdcall code_gctr128
dom
(W.mk_prediction code_gctr128 dom [] ((gctr128_lemma s) code_gctr128 IA.win)) | {
"checked_file": "Vale.Stdcalls.X64.GCTR.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.AES.X64.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.UInt64.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.GCTR.fst"
} | [
"total"
] | [
"FStar.Ghost.erased",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat32",
"Vale.Interop.X64.wrap_weak_stdcall",
"Vale.Stdcalls.X64.GCTR.code_gctr128",
"Vale.Stdcalls.X64.GCTR.dom",
"Vale.AsLowStar.Wrapper.pre_rel_generic",
"Vale.Interop.X64.max_stdcall",
"Vale.Interop.X64.arg_reg_stdcall",
"Prims.Nil",
"Vale.Interop.Base.arg",
"Vale.Stdcalls.X64.GCTR.gctr128_pre",
"Vale.AsLowStar.Wrapper.post_rel_generic",
"Vale.Stdcalls.X64.GCTR.gctr128_post",
"Vale.AsLowStar.Wrapper.mk_prediction",
"Vale.Interop.X64.regs_modified_stdcall",
"Vale.Interop.X64.xmms_modified_stdcall",
"Vale.Stdcalls.X64.GCTR.gctr128_lemma",
"Vale.Interop.Assumptions.win",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"FStar.List.Tot.Base.length",
"Vale.Interop.Base.td",
"Prims.list",
"Vale.Stdcalls.X64.GCTR.lowstar_gctr128_t"
] | [] | module Vale.Stdcalls.X64.GCTR
open FStar.HyperStack.ST
module B = LowStar.Buffer
module HS = FStar.HyperStack
open FStar.Mul
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AES.AES_s
module GC = Vale.AES.X64.GCTR
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b128 = buf_t TUInt8 TUInt128
[@__reduce__] noextract
let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq
[@__reduce__] noextract
let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let (dom: list td{List.length dom <= 20}) =
let y = [t128_no_mod; tuint64; t128_mod; t128_mod; t128_no_mod; t128_no_mod; tuint64] in
assert_norm (List.length y = 7);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr128_pre : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state) ->
GC.va_req_Gctr_bytes_stdcall c va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s)
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr128_post : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_post dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
GC.va_ens_Gctr_bytes_stdcall c va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) va_s1 f
#set-options "--z3rlimit 20"
[@__reduce__] noextract
let gctr128_lemma'
(s:Ghost.erased (Seq.seq nat32))
(code:V.va_code)
(_win:bool)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
gctr128_pre s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
gctr128_post s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer in_b) /\
ME.buffer_writeable (as_vale_buffer keys_b) /\
ME.buffer_writeable (as_vale_buffer ctr_b) /\
ME.buffer_writeable (as_vale_buffer inout_b) /\
ME.buffer_writeable (as_vale_buffer out_b)
)) =
let va_s1, f = GC.va_lemma_Gctr_bytes_stdcall code va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 ctr_b;
(va_s1, f)
noextract
let gctr128_lemma (s:Ghost.erased (Seq.seq nat32)) = as_t #(VSig.vale_sig_stdcall (gctr128_pre s) (gctr128_post s)) (gctr128_lemma' s)
noextract
let code_gctr128 = GC.va_code_Gctr_bytes_stdcall IA.win AES_128
[@__reduce__] noextract
let lowstar_gctr128_t (s:Ghost.erased (Seq.seq nat32)) =
assert_norm (List.length dom + List.length ([]<:list arg) <= 20);
IX64.as_lowstar_sig_t_weak_stdcall
code_gctr128
dom
[]
_
_
(W.mk_prediction code_gctr128 dom [] ((gctr128_lemma s) code_gctr128 IA.win))
(* And here's the gcm wrapper itself *)
noextract | false | false | Vale.Stdcalls.X64.GCTR.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lowstar_gctr128 (s: Ghost.erased (Seq.seq nat32)) : lowstar_gctr128_t s | [] | Vale.Stdcalls.X64.GCTR.lowstar_gctr128 | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCTR.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32)
-> Vale.Stdcalls.X64.GCTR.lowstar_gctr128_t s | {
"end_col": 81,
"end_line": 151,
"start_col": 2,
"start_line": 147
} |
Prims.Tot | val gctr128_pre: (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom | [
{
"abbrev": true,
"full_module": "Vale.AES.X64.GCTR",
"short_module": "GC"
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let gctr128_pre : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state) ->
GC.va_req_Gctr_bytes_stdcall c va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) | val gctr128_pre: (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom
let gctr128_pre: (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom = | false | null | false | fun
(s: Ghost.erased (Seq.seq nat32))
(c: V.va_code)
(in_b: b128)
(num_bytes: uint64)
(out_b: b128)
(inout_b: b128)
(keys_b: b128)
(ctr_b: b128)
(num_blocks: uint64)
(va_s0: V.va_state)
->
GC.va_req_Gctr_bytes_stdcall c va_s0 IA.win AES_128 (as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b) (as_vale_buffer ctr_b)
(UInt64.v num_blocks) (Ghost.reveal s) | {
"checked_file": "Vale.Stdcalls.X64.GCTR.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.AES.X64.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.UInt64.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.GCTR.fst"
} | [
"total"
] | [
"FStar.Ghost.erased",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat32",
"Vale.X64.Decls.va_code",
"Vale.Stdcalls.X64.GCTR.b128",
"Vale.Stdcalls.X64.GCTR.uint64",
"Vale.X64.Decls.va_state",
"Vale.AES.X64.GCTR.va_req_Gctr_bytes_stdcall",
"Vale.Interop.Assumptions.win",
"Vale.AES.AES_common_s.AES_128",
"Vale.X64.MemoryAdapters.as_vale_buffer",
"Vale.Arch.HeapTypes_s.TUInt8",
"Vale.Arch.HeapTypes_s.TUInt128",
"FStar.UInt64.v",
"FStar.Ghost.reveal",
"Prims.prop"
] | [] | module Vale.Stdcalls.X64.GCTR
open FStar.HyperStack.ST
module B = LowStar.Buffer
module HS = FStar.HyperStack
open FStar.Mul
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AES.AES_s
module GC = Vale.AES.X64.GCTR
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b128 = buf_t TUInt8 TUInt128
[@__reduce__] noextract
let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq
[@__reduce__] noextract
let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let (dom: list td{List.length dom <= 20}) =
let y = [t128_no_mod; tuint64; t128_mod; t128_mod; t128_no_mod; t128_no_mod; tuint64] in
assert_norm (List.length y = 7);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract | false | true | Vale.Stdcalls.X64.GCTR.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val gctr128_pre: (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom | [] | Vale.Stdcalls.X64.GCTR.gctr128_pre | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCTR.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Words_s.nat32)
-> Vale.AsLowStar.ValeSig.vale_pre Vale.Stdcalls.X64.GCTR.dom | {
"end_col": 69,
"end_line": 66,
"start_col": 2,
"start_line": 53
} |
Prims.Tot | val gctr256_pre: (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom | [
{
"abbrev": true,
"full_module": "Vale.AES.X64.GCTR",
"short_module": "GC"
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let gctr256_pre : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state) ->
GC.va_req_Gctr_bytes_stdcall c va_s0 IA.win AES_256
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) | val gctr256_pre: (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom
let gctr256_pre: (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom = | false | null | false | fun
(s: Ghost.erased (Seq.seq nat32))
(c: V.va_code)
(in_b: b128)
(num_bytes: uint64)
(out_b: b128)
(inout_b: b128)
(keys_b: b128)
(ctr_b: b128)
(num_blocks: uint64)
(va_s0: V.va_state)
->
GC.va_req_Gctr_bytes_stdcall c va_s0 IA.win AES_256 (as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b) (as_vale_buffer ctr_b)
(UInt64.v num_blocks) (Ghost.reveal s) | {
"checked_file": "Vale.Stdcalls.X64.GCTR.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.AES.X64.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.UInt64.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.GCTR.fst"
} | [
"total"
] | [
"FStar.Ghost.erased",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat32",
"Vale.X64.Decls.va_code",
"Vale.Stdcalls.X64.GCTR.b128",
"Vale.Stdcalls.X64.GCTR.uint64",
"Vale.X64.Decls.va_state",
"Vale.AES.X64.GCTR.va_req_Gctr_bytes_stdcall",
"Vale.Interop.Assumptions.win",
"Vale.AES.AES_common_s.AES_256",
"Vale.X64.MemoryAdapters.as_vale_buffer",
"Vale.Arch.HeapTypes_s.TUInt8",
"Vale.Arch.HeapTypes_s.TUInt128",
"FStar.UInt64.v",
"FStar.Ghost.reveal",
"Prims.prop"
] | [] | module Vale.Stdcalls.X64.GCTR
open FStar.HyperStack.ST
module B = LowStar.Buffer
module HS = FStar.HyperStack
open FStar.Mul
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AES.AES_s
module GC = Vale.AES.X64.GCTR
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b128 = buf_t TUInt8 TUInt128
[@__reduce__] noextract
let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq
[@__reduce__] noextract
let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let (dom: list td{List.length dom <= 20}) =
let y = [t128_no_mod; tuint64; t128_mod; t128_mod; t128_no_mod; t128_no_mod; tuint64] in
assert_norm (List.length y = 7);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr128_pre : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state) ->
GC.va_req_Gctr_bytes_stdcall c va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s)
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr128_post : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_post dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
GC.va_ens_Gctr_bytes_stdcall c va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) va_s1 f
#set-options "--z3rlimit 20"
[@__reduce__] noextract
let gctr128_lemma'
(s:Ghost.erased (Seq.seq nat32))
(code:V.va_code)
(_win:bool)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
gctr128_pre s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
gctr128_post s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer in_b) /\
ME.buffer_writeable (as_vale_buffer keys_b) /\
ME.buffer_writeable (as_vale_buffer ctr_b) /\
ME.buffer_writeable (as_vale_buffer inout_b) /\
ME.buffer_writeable (as_vale_buffer out_b)
)) =
let va_s1, f = GC.va_lemma_Gctr_bytes_stdcall code va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 ctr_b;
(va_s1, f)
noextract
let gctr128_lemma (s:Ghost.erased (Seq.seq nat32)) = as_t #(VSig.vale_sig_stdcall (gctr128_pre s) (gctr128_post s)) (gctr128_lemma' s)
noextract
let code_gctr128 = GC.va_code_Gctr_bytes_stdcall IA.win AES_128
[@__reduce__] noextract
let lowstar_gctr128_t (s:Ghost.erased (Seq.seq nat32)) =
assert_norm (List.length dom + List.length ([]<:list arg) <= 20);
IX64.as_lowstar_sig_t_weak_stdcall
code_gctr128
dom
[]
_
_
(W.mk_prediction code_gctr128 dom [] ((gctr128_lemma s) code_gctr128 IA.win))
(* And here's the gcm wrapper itself *)
noextract
let lowstar_gctr128 (s:Ghost.erased (Seq.seq nat32)) : lowstar_gctr128_t s =
assert_norm (List.length dom + List.length ([]<:list arg) <= 20);
IX64.wrap_weak_stdcall
code_gctr128
dom
(W.mk_prediction code_gctr128 dom [] ((gctr128_lemma s) code_gctr128 IA.win))
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract | false | true | Vale.Stdcalls.X64.GCTR.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val gctr256_pre: (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom | [] | Vale.Stdcalls.X64.GCTR.gctr256_pre | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCTR.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Words_s.nat32)
-> Vale.AsLowStar.ValeSig.vale_pre Vale.Stdcalls.X64.GCTR.dom | {
"end_col": 69,
"end_line": 169,
"start_col": 2,
"start_line": 156
} |
Prims.Tot | val gctr128_post: (Ghost.erased (Seq.seq nat32)) -> VSig.vale_post dom | [
{
"abbrev": true,
"full_module": "Vale.AES.X64.GCTR",
"short_module": "GC"
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let gctr128_post : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_post dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
GC.va_ens_Gctr_bytes_stdcall c va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) va_s1 f | val gctr128_post: (Ghost.erased (Seq.seq nat32)) -> VSig.vale_post dom
let gctr128_post: (Ghost.erased (Seq.seq nat32)) -> VSig.vale_post dom = | false | null | false | fun
(s: Ghost.erased (Seq.seq nat32))
(c: V.va_code)
(in_b: b128)
(num_bytes: uint64)
(out_b: b128)
(inout_b: b128)
(keys_b: b128)
(ctr_b: b128)
(num_blocks: uint64)
(va_s0: V.va_state)
(va_s1: V.va_state)
(f: V.va_fuel)
->
GC.va_ens_Gctr_bytes_stdcall c va_s0 IA.win AES_128 (as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b) (as_vale_buffer ctr_b)
(UInt64.v num_blocks) (Ghost.reveal s) va_s1 f | {
"checked_file": "Vale.Stdcalls.X64.GCTR.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.AES.X64.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.UInt64.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.GCTR.fst"
} | [
"total"
] | [
"FStar.Ghost.erased",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat32",
"Vale.X64.Decls.va_code",
"Vale.Stdcalls.X64.GCTR.b128",
"Vale.Stdcalls.X64.GCTR.uint64",
"Vale.X64.Decls.va_state",
"Vale.X64.Decls.va_fuel",
"Vale.AES.X64.GCTR.va_ens_Gctr_bytes_stdcall",
"Vale.Interop.Assumptions.win",
"Vale.AES.AES_common_s.AES_128",
"Vale.X64.MemoryAdapters.as_vale_buffer",
"Vale.Arch.HeapTypes_s.TUInt8",
"Vale.Arch.HeapTypes_s.TUInt128",
"FStar.UInt64.v",
"FStar.Ghost.reveal",
"Prims.prop"
] | [] | module Vale.Stdcalls.X64.GCTR
open FStar.HyperStack.ST
module B = LowStar.Buffer
module HS = FStar.HyperStack
open FStar.Mul
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AES.AES_s
module GC = Vale.AES.X64.GCTR
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b128 = buf_t TUInt8 TUInt128
[@__reduce__] noextract
let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq
[@__reduce__] noextract
let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let (dom: list td{List.length dom <= 20}) =
let y = [t128_no_mod; tuint64; t128_mod; t128_mod; t128_no_mod; t128_no_mod; tuint64] in
assert_norm (List.length y = 7);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr128_pre : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state) ->
GC.va_req_Gctr_bytes_stdcall c va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s)
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract | false | true | Vale.Stdcalls.X64.GCTR.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val gctr128_post: (Ghost.erased (Seq.seq nat32)) -> VSig.vale_post dom | [] | Vale.Stdcalls.X64.GCTR.gctr128_post | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCTR.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Words_s.nat32)
-> Vale.AsLowStar.ValeSig.vale_post Vale.Stdcalls.X64.GCTR.dom | {
"end_col": 77,
"end_line": 86,
"start_col": 2,
"start_line": 71
} |
Prims.Tot | val gctr256_post: (Ghost.erased (Seq.seq nat32)) -> VSig.vale_post dom | [
{
"abbrev": true,
"full_module": "Vale.AES.X64.GCTR",
"short_module": "GC"
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let gctr256_post : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_post dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
GC.va_ens_Gctr_bytes_stdcall c va_s0 IA.win AES_256
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) va_s1 f | val gctr256_post: (Ghost.erased (Seq.seq nat32)) -> VSig.vale_post dom
let gctr256_post: (Ghost.erased (Seq.seq nat32)) -> VSig.vale_post dom = | false | null | false | fun
(s: Ghost.erased (Seq.seq nat32))
(c: V.va_code)
(in_b: b128)
(num_bytes: uint64)
(out_b: b128)
(inout_b: b128)
(keys_b: b128)
(ctr_b: b128)
(num_blocks: uint64)
(va_s0: V.va_state)
(va_s1: V.va_state)
(f: V.va_fuel)
->
GC.va_ens_Gctr_bytes_stdcall c va_s0 IA.win AES_256 (as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b) (as_vale_buffer ctr_b)
(UInt64.v num_blocks) (Ghost.reveal s) va_s1 f | {
"checked_file": "Vale.Stdcalls.X64.GCTR.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.AES.X64.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.UInt64.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.GCTR.fst"
} | [
"total"
] | [
"FStar.Ghost.erased",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat32",
"Vale.X64.Decls.va_code",
"Vale.Stdcalls.X64.GCTR.b128",
"Vale.Stdcalls.X64.GCTR.uint64",
"Vale.X64.Decls.va_state",
"Vale.X64.Decls.va_fuel",
"Vale.AES.X64.GCTR.va_ens_Gctr_bytes_stdcall",
"Vale.Interop.Assumptions.win",
"Vale.AES.AES_common_s.AES_256",
"Vale.X64.MemoryAdapters.as_vale_buffer",
"Vale.Arch.HeapTypes_s.TUInt8",
"Vale.Arch.HeapTypes_s.TUInt128",
"FStar.UInt64.v",
"FStar.Ghost.reveal",
"Prims.prop"
] | [] | module Vale.Stdcalls.X64.GCTR
open FStar.HyperStack.ST
module B = LowStar.Buffer
module HS = FStar.HyperStack
open FStar.Mul
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AES.AES_s
module GC = Vale.AES.X64.GCTR
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b128 = buf_t TUInt8 TUInt128
[@__reduce__] noextract
let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq
[@__reduce__] noextract
let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let (dom: list td{List.length dom <= 20}) =
let y = [t128_no_mod; tuint64; t128_mod; t128_mod; t128_no_mod; t128_no_mod; tuint64] in
assert_norm (List.length y = 7);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr128_pre : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state) ->
GC.va_req_Gctr_bytes_stdcall c va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s)
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr128_post : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_post dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
GC.va_ens_Gctr_bytes_stdcall c va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) va_s1 f
#set-options "--z3rlimit 20"
[@__reduce__] noextract
let gctr128_lemma'
(s:Ghost.erased (Seq.seq nat32))
(code:V.va_code)
(_win:bool)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
gctr128_pre s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
gctr128_post s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer in_b) /\
ME.buffer_writeable (as_vale_buffer keys_b) /\
ME.buffer_writeable (as_vale_buffer ctr_b) /\
ME.buffer_writeable (as_vale_buffer inout_b) /\
ME.buffer_writeable (as_vale_buffer out_b)
)) =
let va_s1, f = GC.va_lemma_Gctr_bytes_stdcall code va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 ctr_b;
(va_s1, f)
noextract
let gctr128_lemma (s:Ghost.erased (Seq.seq nat32)) = as_t #(VSig.vale_sig_stdcall (gctr128_pre s) (gctr128_post s)) (gctr128_lemma' s)
noextract
let code_gctr128 = GC.va_code_Gctr_bytes_stdcall IA.win AES_128
[@__reduce__] noextract
let lowstar_gctr128_t (s:Ghost.erased (Seq.seq nat32)) =
assert_norm (List.length dom + List.length ([]<:list arg) <= 20);
IX64.as_lowstar_sig_t_weak_stdcall
code_gctr128
dom
[]
_
_
(W.mk_prediction code_gctr128 dom [] ((gctr128_lemma s) code_gctr128 IA.win))
(* And here's the gcm wrapper itself *)
noextract
let lowstar_gctr128 (s:Ghost.erased (Seq.seq nat32)) : lowstar_gctr128_t s =
assert_norm (List.length dom + List.length ([]<:list arg) <= 20);
IX64.wrap_weak_stdcall
code_gctr128
dom
(W.mk_prediction code_gctr128 dom [] ((gctr128_lemma s) code_gctr128 IA.win))
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr256_pre : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state) ->
GC.va_req_Gctr_bytes_stdcall c va_s0 IA.win AES_256
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s)
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract | false | true | Vale.Stdcalls.X64.GCTR.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val gctr256_post: (Ghost.erased (Seq.seq nat32)) -> VSig.vale_post dom | [] | Vale.Stdcalls.X64.GCTR.gctr256_post | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCTR.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Words_s.nat32)
-> Vale.AsLowStar.ValeSig.vale_post Vale.Stdcalls.X64.GCTR.dom | {
"end_col": 77,
"end_line": 189,
"start_col": 2,
"start_line": 174
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Vale.AES.X64.GCTR",
"short_module": "GC"
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let gctr128_lemma (s:Ghost.erased (Seq.seq nat32)) = as_t #(VSig.vale_sig_stdcall (gctr128_pre s) (gctr128_post s)) (gctr128_lemma' s) | let gctr128_lemma (s: Ghost.erased (Seq.seq nat32)) = | false | null | false | as_t #(VSig.vale_sig_stdcall (gctr128_pre s) (gctr128_post s)) (gctr128_lemma' s) | {
"checked_file": "Vale.Stdcalls.X64.GCTR.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.AES.X64.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.UInt64.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.GCTR.fst"
} | [
"total"
] | [
"FStar.Ghost.erased",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat32",
"Vale.Stdcalls.X64.GCTR.as_t",
"Vale.AsLowStar.ValeSig.vale_sig_stdcall",
"Vale.Stdcalls.X64.GCTR.dom",
"Vale.Stdcalls.X64.GCTR.gctr128_pre",
"Vale.Stdcalls.X64.GCTR.gctr128_post",
"Vale.Stdcalls.X64.GCTR.gctr128_lemma'"
] | [] | module Vale.Stdcalls.X64.GCTR
open FStar.HyperStack.ST
module B = LowStar.Buffer
module HS = FStar.HyperStack
open FStar.Mul
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AES.AES_s
module GC = Vale.AES.X64.GCTR
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b128 = buf_t TUInt8 TUInt128
[@__reduce__] noextract
let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq
[@__reduce__] noextract
let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let (dom: list td{List.length dom <= 20}) =
let y = [t128_no_mod; tuint64; t128_mod; t128_mod; t128_no_mod; t128_no_mod; tuint64] in
assert_norm (List.length y = 7);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr128_pre : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state) ->
GC.va_req_Gctr_bytes_stdcall c va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s)
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr128_post : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_post dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
GC.va_ens_Gctr_bytes_stdcall c va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) va_s1 f
#set-options "--z3rlimit 20"
[@__reduce__] noextract
let gctr128_lemma'
(s:Ghost.erased (Seq.seq nat32))
(code:V.va_code)
(_win:bool)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
gctr128_pre s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
gctr128_post s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer in_b) /\
ME.buffer_writeable (as_vale_buffer keys_b) /\
ME.buffer_writeable (as_vale_buffer ctr_b) /\
ME.buffer_writeable (as_vale_buffer inout_b) /\
ME.buffer_writeable (as_vale_buffer out_b)
)) =
let va_s1, f = GC.va_lemma_Gctr_bytes_stdcall code va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 ctr_b;
(va_s1, f) | false | false | Vale.Stdcalls.X64.GCTR.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val gctr128_lemma : s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32)
-> Vale.AsLowStar.ValeSig.vale_sig_stdcall (Vale.Stdcalls.X64.GCTR.gctr128_pre s)
(Vale.Stdcalls.X64.GCTR.gctr128_post s) | [] | Vale.Stdcalls.X64.GCTR.gctr128_lemma | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCTR.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32)
-> Vale.AsLowStar.ValeSig.vale_sig_stdcall (Vale.Stdcalls.X64.GCTR.gctr128_pre s)
(Vale.Stdcalls.X64.GCTR.gctr128_post s) | {
"end_col": 135,
"end_line": 128,
"start_col": 53,
"start_line": 128
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Vale.AES.X64.GCTR",
"short_module": "GC"
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let gctr256_lemma (s:Ghost.erased (Seq.seq nat32)) = as_t #(VSig.vale_sig_stdcall (gctr256_pre s) (gctr256_post s)) (gctr256_lemma' s) | let gctr256_lemma (s: Ghost.erased (Seq.seq nat32)) = | false | null | false | as_t #(VSig.vale_sig_stdcall (gctr256_pre s) (gctr256_post s)) (gctr256_lemma' s) | {
"checked_file": "Vale.Stdcalls.X64.GCTR.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.AES.X64.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.UInt64.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.GCTR.fst"
} | [
"total"
] | [
"FStar.Ghost.erased",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat32",
"Vale.Stdcalls.X64.GCTR.as_t",
"Vale.AsLowStar.ValeSig.vale_sig_stdcall",
"Vale.Stdcalls.X64.GCTR.dom",
"Vale.Stdcalls.X64.GCTR.gctr256_pre",
"Vale.Stdcalls.X64.GCTR.gctr256_post",
"Vale.Stdcalls.X64.GCTR.gctr256_lemma'"
] | [] | module Vale.Stdcalls.X64.GCTR
open FStar.HyperStack.ST
module B = LowStar.Buffer
module HS = FStar.HyperStack
open FStar.Mul
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AES.AES_s
module GC = Vale.AES.X64.GCTR
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b128 = buf_t TUInt8 TUInt128
[@__reduce__] noextract
let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq
[@__reduce__] noextract
let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let (dom: list td{List.length dom <= 20}) =
let y = [t128_no_mod; tuint64; t128_mod; t128_mod; t128_no_mod; t128_no_mod; tuint64] in
assert_norm (List.length y = 7);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr128_pre : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state) ->
GC.va_req_Gctr_bytes_stdcall c va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s)
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr128_post : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_post dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
GC.va_ens_Gctr_bytes_stdcall c va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) va_s1 f
#set-options "--z3rlimit 20"
[@__reduce__] noextract
let gctr128_lemma'
(s:Ghost.erased (Seq.seq nat32))
(code:V.va_code)
(_win:bool)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
gctr128_pre s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
gctr128_post s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer in_b) /\
ME.buffer_writeable (as_vale_buffer keys_b) /\
ME.buffer_writeable (as_vale_buffer ctr_b) /\
ME.buffer_writeable (as_vale_buffer inout_b) /\
ME.buffer_writeable (as_vale_buffer out_b)
)) =
let va_s1, f = GC.va_lemma_Gctr_bytes_stdcall code va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 ctr_b;
(va_s1, f)
noextract
let gctr128_lemma (s:Ghost.erased (Seq.seq nat32)) = as_t #(VSig.vale_sig_stdcall (gctr128_pre s) (gctr128_post s)) (gctr128_lemma' s)
noextract
let code_gctr128 = GC.va_code_Gctr_bytes_stdcall IA.win AES_128
[@__reduce__] noextract
let lowstar_gctr128_t (s:Ghost.erased (Seq.seq nat32)) =
assert_norm (List.length dom + List.length ([]<:list arg) <= 20);
IX64.as_lowstar_sig_t_weak_stdcall
code_gctr128
dom
[]
_
_
(W.mk_prediction code_gctr128 dom [] ((gctr128_lemma s) code_gctr128 IA.win))
(* And here's the gcm wrapper itself *)
noextract
let lowstar_gctr128 (s:Ghost.erased (Seq.seq nat32)) : lowstar_gctr128_t s =
assert_norm (List.length dom + List.length ([]<:list arg) <= 20);
IX64.wrap_weak_stdcall
code_gctr128
dom
(W.mk_prediction code_gctr128 dom [] ((gctr128_lemma s) code_gctr128 IA.win))
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr256_pre : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state) ->
GC.va_req_Gctr_bytes_stdcall c va_s0 IA.win AES_256
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s)
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr256_post : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_post dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
GC.va_ens_Gctr_bytes_stdcall c va_s0 IA.win AES_256
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) va_s1 f
#set-options "--z3rlimit 20"
[@__reduce__] noextract
let gctr256_lemma'
(s:Ghost.erased (Seq.seq nat32))
(code:V.va_code)
(_win:bool)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
gctr256_pre s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
gctr256_post s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer in_b) /\
ME.buffer_writeable (as_vale_buffer keys_b) /\
ME.buffer_writeable (as_vale_buffer ctr_b) /\
ME.buffer_writeable (as_vale_buffer inout_b) /\
ME.buffer_writeable (as_vale_buffer out_b)
)) =
let va_s1, f = GC.va_lemma_Gctr_bytes_stdcall code va_s0 IA.win AES_256
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 ctr_b;
(va_s1, f) | false | false | Vale.Stdcalls.X64.GCTR.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val gctr256_lemma : s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32)
-> Vale.AsLowStar.ValeSig.vale_sig_stdcall (Vale.Stdcalls.X64.GCTR.gctr256_pre s)
(Vale.Stdcalls.X64.GCTR.gctr256_post s) | [] | Vale.Stdcalls.X64.GCTR.gctr256_lemma | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCTR.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32)
-> Vale.AsLowStar.ValeSig.vale_sig_stdcall (Vale.Stdcalls.X64.GCTR.gctr256_pre s)
(Vale.Stdcalls.X64.GCTR.gctr256_post s) | {
"end_col": 135,
"end_line": 231,
"start_col": 53,
"start_line": 231
} |
|
Prims.Ghost | val gctr128_lemma'
(s: Ghost.erased (Seq.seq nat32))
(code: V.va_code)
(_win: bool)
(in_b: b128)
(num_bytes: uint64)
(out_b inout_b keys_b ctr_b: b128)
(num_blocks: uint64)
(va_s0: V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires gctr128_pre s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0)
(ensures
(fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
gctr128_post s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer in_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\
ME.buffer_writeable (as_vale_buffer ctr_b) /\
ME.buffer_writeable (as_vale_buffer inout_b) /\
ME.buffer_writeable (as_vale_buffer out_b))) | [
{
"abbrev": true,
"full_module": "Vale.AES.X64.GCTR",
"short_module": "GC"
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let gctr128_lemma'
(s:Ghost.erased (Seq.seq nat32))
(code:V.va_code)
(_win:bool)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
gctr128_pre s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
gctr128_post s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer in_b) /\
ME.buffer_writeable (as_vale_buffer keys_b) /\
ME.buffer_writeable (as_vale_buffer ctr_b) /\
ME.buffer_writeable (as_vale_buffer inout_b) /\
ME.buffer_writeable (as_vale_buffer out_b)
)) =
let va_s1, f = GC.va_lemma_Gctr_bytes_stdcall code va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 ctr_b;
(va_s1, f) | val gctr128_lemma'
(s: Ghost.erased (Seq.seq nat32))
(code: V.va_code)
(_win: bool)
(in_b: b128)
(num_bytes: uint64)
(out_b inout_b keys_b ctr_b: b128)
(num_blocks: uint64)
(va_s0: V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires gctr128_pre s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0)
(ensures
(fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
gctr128_post s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer in_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\
ME.buffer_writeable (as_vale_buffer ctr_b) /\
ME.buffer_writeable (as_vale_buffer inout_b) /\
ME.buffer_writeable (as_vale_buffer out_b)))
let gctr128_lemma'
(s: Ghost.erased (Seq.seq nat32))
(code: V.va_code)
(_win: bool)
(in_b: b128)
(num_bytes: uint64)
(out_b inout_b keys_b ctr_b: b128)
(num_blocks: uint64)
(va_s0: V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires gctr128_pre s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0)
(ensures
(fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
gctr128_post s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer in_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\
ME.buffer_writeable (as_vale_buffer ctr_b) /\
ME.buffer_writeable (as_vale_buffer inout_b) /\
ME.buffer_writeable (as_vale_buffer out_b))) = | false | null | false | let va_s1, f =
GC.va_lemma_Gctr_bytes_stdcall code va_s0 IA.win AES_128 (as_vale_buffer in_b)
(UInt64.v num_bytes) (as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s)
in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 ctr_b;
(va_s1, f) | {
"checked_file": "Vale.Stdcalls.X64.GCTR.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.AES.X64.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.UInt64.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.GCTR.fst"
} | [] | [
"FStar.Ghost.erased",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat32",
"Vale.X64.Decls.va_code",
"Prims.bool",
"Vale.Stdcalls.X64.GCTR.b128",
"Vale.Stdcalls.X64.GCTR.uint64",
"Vale.X64.Decls.va_state",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.Mktuple2",
"Prims.unit",
"Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal",
"Vale.Arch.HeapTypes_s.TUInt8",
"Vale.Arch.HeapTypes_s.TUInt128",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.State.vale_state",
"Vale.AES.X64.GCTR.va_lemma_Gctr_bytes_stdcall",
"Vale.Interop.Assumptions.win",
"Vale.AES.AES_common_s.AES_128",
"Vale.X64.MemoryAdapters.as_vale_buffer",
"FStar.UInt64.v",
"FStar.Ghost.reveal",
"Vale.Stdcalls.X64.GCTR.gctr128_pre",
"Prims.l_and",
"Vale.X64.Decls.eval_code",
"Vale.AsLowStar.ValeSig.vale_calling_conventions_stdcall",
"Vale.Stdcalls.X64.GCTR.gctr128_post",
"Vale.X64.Memory.buffer_writeable"
] | [] | module Vale.Stdcalls.X64.GCTR
open FStar.HyperStack.ST
module B = LowStar.Buffer
module HS = FStar.HyperStack
open FStar.Mul
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AES.AES_s
module GC = Vale.AES.X64.GCTR
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b128 = buf_t TUInt8 TUInt128
[@__reduce__] noextract
let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq
[@__reduce__] noextract
let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let (dom: list td{List.length dom <= 20}) =
let y = [t128_no_mod; tuint64; t128_mod; t128_mod; t128_no_mod; t128_no_mod; tuint64] in
assert_norm (List.length y = 7);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr128_pre : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state) ->
GC.va_req_Gctr_bytes_stdcall c va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s)
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr128_post : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_post dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
GC.va_ens_Gctr_bytes_stdcall c va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) va_s1 f
#set-options "--z3rlimit 20"
[@__reduce__] noextract
let gctr128_lemma'
(s:Ghost.erased (Seq.seq nat32))
(code:V.va_code)
(_win:bool)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
gctr128_pre s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
gctr128_post s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer in_b) /\
ME.buffer_writeable (as_vale_buffer keys_b) /\
ME.buffer_writeable (as_vale_buffer ctr_b) /\
ME.buffer_writeable (as_vale_buffer inout_b) /\ | false | false | Vale.Stdcalls.X64.GCTR.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val gctr128_lemma'
(s: Ghost.erased (Seq.seq nat32))
(code: V.va_code)
(_win: bool)
(in_b: b128)
(num_bytes: uint64)
(out_b inout_b keys_b ctr_b: b128)
(num_blocks: uint64)
(va_s0: V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires gctr128_pre s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0)
(ensures
(fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
gctr128_post s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer in_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\
ME.buffer_writeable (as_vale_buffer ctr_b) /\
ME.buffer_writeable (as_vale_buffer inout_b) /\
ME.buffer_writeable (as_vale_buffer out_b))) | [] | Vale.Stdcalls.X64.GCTR.gctr128_lemma' | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCTR.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32) ->
code: Vale.X64.Decls.va_code ->
_win: Prims.bool ->
in_b: Vale.Stdcalls.X64.GCTR.b128 ->
num_bytes: Vale.Stdcalls.X64.GCTR.uint64 ->
out_b: Vale.Stdcalls.X64.GCTR.b128 ->
inout_b: Vale.Stdcalls.X64.GCTR.b128 ->
keys_b: Vale.Stdcalls.X64.GCTR.b128 ->
ctr_b: Vale.Stdcalls.X64.GCTR.b128 ->
num_blocks: Vale.Stdcalls.X64.GCTR.uint64 ->
va_s0: Vale.X64.Decls.va_state
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | {
"end_col": 13,
"end_line": 125,
"start_col": 5,
"start_line": 115
} |
Prims.Ghost | val gctr256_lemma'
(s: Ghost.erased (Seq.seq nat32))
(code: V.va_code)
(_win: bool)
(in_b: b128)
(num_bytes: uint64)
(out_b inout_b keys_b ctr_b: b128)
(num_blocks: uint64)
(va_s0: V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires gctr256_pre s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0)
(ensures
(fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
gctr256_post s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer in_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\
ME.buffer_writeable (as_vale_buffer ctr_b) /\
ME.buffer_writeable (as_vale_buffer inout_b) /\
ME.buffer_writeable (as_vale_buffer out_b))) | [
{
"abbrev": true,
"full_module": "Vale.AES.X64.GCTR",
"short_module": "GC"
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Stdcalls.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let gctr256_lemma'
(s:Ghost.erased (Seq.seq nat32))
(code:V.va_code)
(_win:bool)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
gctr256_pre s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
gctr256_post s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer in_b) /\
ME.buffer_writeable (as_vale_buffer keys_b) /\
ME.buffer_writeable (as_vale_buffer ctr_b) /\
ME.buffer_writeable (as_vale_buffer inout_b) /\
ME.buffer_writeable (as_vale_buffer out_b)
)) =
let va_s1, f = GC.va_lemma_Gctr_bytes_stdcall code va_s0 IA.win AES_256
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 ctr_b;
(va_s1, f) | val gctr256_lemma'
(s: Ghost.erased (Seq.seq nat32))
(code: V.va_code)
(_win: bool)
(in_b: b128)
(num_bytes: uint64)
(out_b inout_b keys_b ctr_b: b128)
(num_blocks: uint64)
(va_s0: V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires gctr256_pre s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0)
(ensures
(fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
gctr256_post s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer in_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\
ME.buffer_writeable (as_vale_buffer ctr_b) /\
ME.buffer_writeable (as_vale_buffer inout_b) /\
ME.buffer_writeable (as_vale_buffer out_b)))
let gctr256_lemma'
(s: Ghost.erased (Seq.seq nat32))
(code: V.va_code)
(_win: bool)
(in_b: b128)
(num_bytes: uint64)
(out_b inout_b keys_b ctr_b: b128)
(num_blocks: uint64)
(va_s0: V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires gctr256_pre s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0)
(ensures
(fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
gctr256_post s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer in_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\
ME.buffer_writeable (as_vale_buffer ctr_b) /\
ME.buffer_writeable (as_vale_buffer inout_b) /\
ME.buffer_writeable (as_vale_buffer out_b))) = | false | null | false | let va_s1, f =
GC.va_lemma_Gctr_bytes_stdcall code va_s0 IA.win AES_256 (as_vale_buffer in_b)
(UInt64.v num_bytes) (as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s)
in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 ctr_b;
(va_s1, f) | {
"checked_file": "Vale.Stdcalls.X64.GCTR.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"Vale.AES.X64.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.UInt64.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.Stdcalls.X64.GCTR.fst"
} | [] | [
"FStar.Ghost.erased",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat32",
"Vale.X64.Decls.va_code",
"Prims.bool",
"Vale.Stdcalls.X64.GCTR.b128",
"Vale.Stdcalls.X64.GCTR.uint64",
"Vale.X64.Decls.va_state",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.Mktuple2",
"Prims.unit",
"Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal",
"Vale.Arch.HeapTypes_s.TUInt8",
"Vale.Arch.HeapTypes_s.TUInt128",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.State.vale_state",
"Vale.AES.X64.GCTR.va_lemma_Gctr_bytes_stdcall",
"Vale.Interop.Assumptions.win",
"Vale.AES.AES_common_s.AES_256",
"Vale.X64.MemoryAdapters.as_vale_buffer",
"FStar.UInt64.v",
"FStar.Ghost.reveal",
"Vale.Stdcalls.X64.GCTR.gctr256_pre",
"Prims.l_and",
"Vale.X64.Decls.eval_code",
"Vale.AsLowStar.ValeSig.vale_calling_conventions_stdcall",
"Vale.Stdcalls.X64.GCTR.gctr256_post",
"Vale.X64.Memory.buffer_writeable"
] | [] | module Vale.Stdcalls.X64.GCTR
open FStar.HyperStack.ST
module B = LowStar.Buffer
module HS = FStar.HyperStack
open FStar.Mul
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
open Vale.AES.AES_s
module GC = Vale.AES.X64.GCTR
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
noextract
let as_t (#a:Type) (x:normal a) : a = x
noextract
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__] noextract
let b128 = buf_t TUInt8 TUInt128
[@__reduce__] noextract
let t128_mod = TD_Buffer TUInt8 TUInt128 default_bq
[@__reduce__] noextract
let t128_no_mod = TD_Buffer TUInt8 TUInt128 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__] noextract
let tuint64 = TD_Base TUInt64
[@__reduce__] noextract
let (dom: list td{List.length dom <= 20}) =
let y = [t128_no_mod; tuint64; t128_mod; t128_mod; t128_no_mod; t128_no_mod; tuint64] in
assert_norm (List.length y = 7);
y
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr128_pre : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state) ->
GC.va_req_Gctr_bytes_stdcall c va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s)
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr128_post : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_post dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
GC.va_ens_Gctr_bytes_stdcall c va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) va_s1 f
#set-options "--z3rlimit 20"
[@__reduce__] noextract
let gctr128_lemma'
(s:Ghost.erased (Seq.seq nat32))
(code:V.va_code)
(_win:bool)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
gctr128_pre s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
gctr128_post s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer in_b) /\
ME.buffer_writeable (as_vale_buffer keys_b) /\
ME.buffer_writeable (as_vale_buffer ctr_b) /\
ME.buffer_writeable (as_vale_buffer inout_b) /\
ME.buffer_writeable (as_vale_buffer out_b)
)) =
let va_s1, f = GC.va_lemma_Gctr_bytes_stdcall code va_s0 IA.win AES_128
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 in_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 out_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 inout_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 keys_b;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt8 ME.TUInt128 ctr_b;
(va_s1, f)
noextract
let gctr128_lemma (s:Ghost.erased (Seq.seq nat32)) = as_t #(VSig.vale_sig_stdcall (gctr128_pre s) (gctr128_post s)) (gctr128_lemma' s)
noextract
let code_gctr128 = GC.va_code_Gctr_bytes_stdcall IA.win AES_128
[@__reduce__] noextract
let lowstar_gctr128_t (s:Ghost.erased (Seq.seq nat32)) =
assert_norm (List.length dom + List.length ([]<:list arg) <= 20);
IX64.as_lowstar_sig_t_weak_stdcall
code_gctr128
dom
[]
_
_
(W.mk_prediction code_gctr128 dom [] ((gctr128_lemma s) code_gctr128 IA.win))
(* And here's the gcm wrapper itself *)
noextract
let lowstar_gctr128 (s:Ghost.erased (Seq.seq nat32)) : lowstar_gctr128_t s =
assert_norm (List.length dom + List.length ([]<:list arg) <= 20);
IX64.wrap_weak_stdcall
code_gctr128
dom
(W.mk_prediction code_gctr128 dom [] ((gctr128_lemma s) code_gctr128 IA.win))
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr256_pre : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_pre dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state) ->
GC.va_req_Gctr_bytes_stdcall c va_s0 IA.win AES_256
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s)
(* Need to rearrange the order of arguments *)
[@__reduce__] noextract
let gctr256_post : (Ghost.erased (Seq.seq nat32)) -> VSig.vale_post dom =
fun (s:Ghost.erased (Seq.seq nat32))
(c:V.va_code)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
GC.va_ens_Gctr_bytes_stdcall c va_s0 IA.win AES_256
(as_vale_buffer in_b) (UInt64.v num_bytes)
(as_vale_buffer out_b) (as_vale_buffer inout_b) (as_vale_buffer keys_b)
(as_vale_buffer ctr_b) (UInt64.v num_blocks) (Ghost.reveal s) va_s1 f
#set-options "--z3rlimit 20"
[@__reduce__] noextract
let gctr256_lemma'
(s:Ghost.erased (Seq.seq nat32))
(code:V.va_code)
(_win:bool)
(in_b:b128)
(num_bytes:uint64)
(out_b:b128)
(inout_b:b128)
(keys_b:b128)
(ctr_b:b128)
(num_blocks:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
gctr256_pre s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
gctr256_post s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer in_b) /\
ME.buffer_writeable (as_vale_buffer keys_b) /\
ME.buffer_writeable (as_vale_buffer ctr_b) /\
ME.buffer_writeable (as_vale_buffer inout_b) /\ | false | false | Vale.Stdcalls.X64.GCTR.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val gctr256_lemma'
(s: Ghost.erased (Seq.seq nat32))
(code: V.va_code)
(_win: bool)
(in_b: b128)
(num_bytes: uint64)
(out_b inout_b keys_b ctr_b: b128)
(num_blocks: uint64)
(va_s0: V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires gctr256_pre s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0)
(ensures
(fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\
gctr256_post s code in_b num_bytes out_b inout_b keys_b ctr_b num_blocks va_s0 va_s1 f /\
ME.buffer_writeable (as_vale_buffer in_b) /\ ME.buffer_writeable (as_vale_buffer keys_b) /\
ME.buffer_writeable (as_vale_buffer ctr_b) /\
ME.buffer_writeable (as_vale_buffer inout_b) /\
ME.buffer_writeable (as_vale_buffer out_b))) | [] | Vale.Stdcalls.X64.GCTR.gctr256_lemma' | {
"file_name": "vale/code/arch/x64/interop/Vale.Stdcalls.X64.GCTR.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
s: FStar.Ghost.erased (FStar.Seq.Base.seq Vale.Def.Types_s.nat32) ->
code: Vale.X64.Decls.va_code ->
_win: Prims.bool ->
in_b: Vale.Stdcalls.X64.GCTR.b128 ->
num_bytes: Vale.Stdcalls.X64.GCTR.uint64 ->
out_b: Vale.Stdcalls.X64.GCTR.b128 ->
inout_b: Vale.Stdcalls.X64.GCTR.b128 ->
keys_b: Vale.Stdcalls.X64.GCTR.b128 ->
ctr_b: Vale.Stdcalls.X64.GCTR.b128 ->
num_blocks: Vale.Stdcalls.X64.GCTR.uint64 ->
va_s0: Vale.X64.Decls.va_state
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | {
"end_col": 13,
"end_line": 228,
"start_col": 5,
"start_line": 218
} |
FStar.Pervasives.Lemma | val big_or'_nil (#a: Type) (f: (a -> Type)) : Lemma (big_or' f [] == False) | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let big_or'_nil (#a:Type) (f:a -> Type)
= assert (big_or' f [] == False) by (T.compute()) | val big_or'_nil (#a: Type) (f: (a -> Type)) : Lemma (big_or' f [] == False)
let big_or'_nil (#a: Type) (f: (a -> Type)) = | false | null | true | FStar.Tactics.Effect.assert_by_tactic (big_or' f [] == False)
(fun _ ->
();
(T.compute ())) | {
"checked_file": "FStar.BigOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.BigOps.fst"
} | [
"lemma"
] | [
"FStar.Tactics.Effect.assert_by_tactic",
"Prims.eq2",
"FStar.BigOps.big_or'",
"Prims.Nil",
"Prims.l_False",
"Prims.unit",
"FStar.Tactics.V2.Derived.compute"
] | [] | (*
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.BigOps
module T = FStar.Tactics.V2
let normal_eq (#a:Type) (f:a)
= ()
////////////////////////////////////////////////////////////////////////////////
let map_op'_nil
(#a:Type) (#b:Type) (#c:Type)
(op:b -> c -> GTot c) (f:a -> GTot b) (z:c)
: Lemma (map_op' op f [] z == z)
= ()
let map_op'_cons #a #b #c (op:b -> c -> GTot c) (f:a -> GTot b) (hd:a) (tl:list a) (z:c)
: Lemma (map_op' op f (hd::tl) z == f hd `op` map_op' op f tl z)
= ()
////////////////////////////////////////////////////////////////////////////////
let big_and'_nil (#a:Type) (f:a -> Type)
= assert (big_and' f [] == True) by (T.compute())
let big_and'_cons (#a:Type) (f:a -> Type) (hd:a) (tl:list a)
= assert (big_and' f (hd :: tl) == (f hd /\ big_and' f tl)) by (T.compute())
let big_and'_prop (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_and'_nil f
| hd::tl -> big_and'_cons f hd tl
let rec big_and'_forall (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_and'_nil f; ()
| hd::tl -> big_and'_cons f hd tl; big_and'_forall f tl
//////////////////////////////////////////////////////////////////////////////// | false | false | FStar.BigOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val big_or'_nil (#a: Type) (f: (a -> Type)) : Lemma (big_or' f [] == False) | [] | FStar.BigOps.big_or'_nil | {
"file_name": "ulib/FStar.BigOps.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: a -> Type0) -> FStar.Pervasives.Lemma (ensures FStar.BigOps.big_or' f [] == Prims.l_False) | {
"end_col": 51,
"end_line": 52,
"start_col": 4,
"start_line": 52
} |
FStar.Pervasives.Lemma | val big_or'_exists (#a: Type) (f: (a -> Type)) (l: list a)
: Lemma (big_or' f l <==> (exists x. L.memP x l /\ f x)) | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec big_or'_exists (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_or'_nil f; ()
| hd::tl -> big_or'_cons f hd tl; big_or'_exists f tl | val big_or'_exists (#a: Type) (f: (a -> Type)) (l: list a)
: Lemma (big_or' f l <==> (exists x. L.memP x l /\ f x))
let rec big_or'_exists (#a: Type) (f: (a -> Type)) (l: list a) = | false | null | true | match l with
| [] ->
big_or'_nil f;
()
| hd :: tl ->
big_or'_cons f hd tl;
big_or'_exists f tl | {
"checked_file": "FStar.BigOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.BigOps.fst"
} | [
"lemma"
] | [
"Prims.list",
"Prims.unit",
"FStar.BigOps.big_or'_nil",
"FStar.BigOps.big_or'_exists",
"FStar.BigOps.big_or'_cons"
] | [] | (*
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.BigOps
module T = FStar.Tactics.V2
let normal_eq (#a:Type) (f:a)
= ()
////////////////////////////////////////////////////////////////////////////////
let map_op'_nil
(#a:Type) (#b:Type) (#c:Type)
(op:b -> c -> GTot c) (f:a -> GTot b) (z:c)
: Lemma (map_op' op f [] z == z)
= ()
let map_op'_cons #a #b #c (op:b -> c -> GTot c) (f:a -> GTot b) (hd:a) (tl:list a) (z:c)
: Lemma (map_op' op f (hd::tl) z == f hd `op` map_op' op f tl z)
= ()
////////////////////////////////////////////////////////////////////////////////
let big_and'_nil (#a:Type) (f:a -> Type)
= assert (big_and' f [] == True) by (T.compute())
let big_and'_cons (#a:Type) (f:a -> Type) (hd:a) (tl:list a)
= assert (big_and' f (hd :: tl) == (f hd /\ big_and' f tl)) by (T.compute())
let big_and'_prop (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_and'_nil f
| hd::tl -> big_and'_cons f hd tl
let rec big_and'_forall (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_and'_nil f; ()
| hd::tl -> big_and'_cons f hd tl; big_and'_forall f tl
////////////////////////////////////////////////////////////////////////////////
let big_or'_nil (#a:Type) (f:a -> Type)
= assert (big_or' f [] == False) by (T.compute())
let big_or'_cons (#a:Type) (f:a -> Type) (hd:a) (tl:list a)
= assert (big_or' f (hd :: tl) == (f hd \/ big_or' f tl)) by (T.compute())
let big_or'_prop (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_or'_nil f
| hd::tl -> big_or'_cons f hd tl | false | false | FStar.BigOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val big_or'_exists (#a: Type) (f: (a -> Type)) (l: list a)
: Lemma (big_or' f l <==> (exists x. L.memP x l /\ f x)) | [
"recursion"
] | FStar.BigOps.big_or'_exists | {
"file_name": "ulib/FStar.BigOps.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: a -> Type0) -> l: Prims.list a
-> FStar.Pervasives.Lemma
(ensures FStar.BigOps.big_or' f l <==> (exists (x: a). FStar.List.Tot.Base.memP x l /\ f x)) | {
"end_col": 57,
"end_line": 65,
"start_col": 4,
"start_line": 63
} |
FStar.Pervasives.Lemma | val big_and'_prop (#a: Type) (f: (a -> Type)) (l: list a) : Lemma ((big_and' f l) `subtype_of` unit) | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let big_and'_prop (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_and'_nil f
| hd::tl -> big_and'_cons f hd tl | val big_and'_prop (#a: Type) (f: (a -> Type)) (l: list a) : Lemma ((big_and' f l) `subtype_of` unit)
let big_and'_prop (#a: Type) (f: (a -> Type)) (l: list a) = | false | null | true | match l with
| [] -> big_and'_nil f
| hd :: tl -> big_and'_cons f hd tl | {
"checked_file": "FStar.BigOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.BigOps.fst"
} | [
"lemma"
] | [
"Prims.list",
"FStar.BigOps.big_and'_nil",
"FStar.BigOps.big_and'_cons",
"Prims.unit"
] | [] | (*
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.BigOps
module T = FStar.Tactics.V2
let normal_eq (#a:Type) (f:a)
= ()
////////////////////////////////////////////////////////////////////////////////
let map_op'_nil
(#a:Type) (#b:Type) (#c:Type)
(op:b -> c -> GTot c) (f:a -> GTot b) (z:c)
: Lemma (map_op' op f [] z == z)
= ()
let map_op'_cons #a #b #c (op:b -> c -> GTot c) (f:a -> GTot b) (hd:a) (tl:list a) (z:c)
: Lemma (map_op' op f (hd::tl) z == f hd `op` map_op' op f tl z)
= ()
////////////////////////////////////////////////////////////////////////////////
let big_and'_nil (#a:Type) (f:a -> Type)
= assert (big_and' f [] == True) by (T.compute())
let big_and'_cons (#a:Type) (f:a -> Type) (hd:a) (tl:list a)
= assert (big_and' f (hd :: tl) == (f hd /\ big_and' f tl)) by (T.compute()) | false | false | FStar.BigOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val big_and'_prop (#a: Type) (f: (a -> Type)) (l: list a) : Lemma ((big_and' f l) `subtype_of` unit) | [] | FStar.BigOps.big_and'_prop | {
"file_name": "ulib/FStar.BigOps.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: a -> Type0) -> l: Prims.list a
-> FStar.Pervasives.Lemma (ensures Prims.subtype_of (FStar.BigOps.big_and' f l) Prims.unit) | {
"end_col": 37,
"end_line": 43,
"start_col": 4,
"start_line": 41
} |
FStar.Pervasives.Lemma | val pairwise_or'_nil (#a: Type) (f: (a -> a -> Type0)) : Lemma (pairwise_or' f [] == False) | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pairwise_or'_nil (#a:Type) (f:a -> a -> Type0)
= assert (pairwise_or' f [] == False) by (T.compute()) | val pairwise_or'_nil (#a: Type) (f: (a -> a -> Type0)) : Lemma (pairwise_or' f [] == False)
let pairwise_or'_nil (#a: Type) (f: (a -> a -> Type0)) = | false | null | true | FStar.Tactics.Effect.assert_by_tactic (pairwise_or' f [] == False)
(fun _ ->
();
(T.compute ())) | {
"checked_file": "FStar.BigOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.BigOps.fst"
} | [
"lemma"
] | [
"FStar.Tactics.Effect.assert_by_tactic",
"Prims.eq2",
"FStar.BigOps.pairwise_or'",
"Prims.Nil",
"Prims.l_False",
"Prims.unit",
"FStar.Tactics.V2.Derived.compute"
] | [] | (*
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.BigOps
module T = FStar.Tactics.V2
let normal_eq (#a:Type) (f:a)
= ()
////////////////////////////////////////////////////////////////////////////////
let map_op'_nil
(#a:Type) (#b:Type) (#c:Type)
(op:b -> c -> GTot c) (f:a -> GTot b) (z:c)
: Lemma (map_op' op f [] z == z)
= ()
let map_op'_cons #a #b #c (op:b -> c -> GTot c) (f:a -> GTot b) (hd:a) (tl:list a) (z:c)
: Lemma (map_op' op f (hd::tl) z == f hd `op` map_op' op f tl z)
= ()
////////////////////////////////////////////////////////////////////////////////
let big_and'_nil (#a:Type) (f:a -> Type)
= assert (big_and' f [] == True) by (T.compute())
let big_and'_cons (#a:Type) (f:a -> Type) (hd:a) (tl:list a)
= assert (big_and' f (hd :: tl) == (f hd /\ big_and' f tl)) by (T.compute())
let big_and'_prop (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_and'_nil f
| hd::tl -> big_and'_cons f hd tl
let rec big_and'_forall (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_and'_nil f; ()
| hd::tl -> big_and'_cons f hd tl; big_and'_forall f tl
////////////////////////////////////////////////////////////////////////////////
let big_or'_nil (#a:Type) (f:a -> Type)
= assert (big_or' f [] == False) by (T.compute())
let big_or'_cons (#a:Type) (f:a -> Type) (hd:a) (tl:list a)
= assert (big_or' f (hd :: tl) == (f hd \/ big_or' f tl)) by (T.compute())
let big_or'_prop (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_or'_nil f
| hd::tl -> big_or'_cons f hd tl
let rec big_or'_exists (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_or'_nil f; ()
| hd::tl -> big_or'_cons f hd tl; big_or'_exists f tl
////////////////////////////////////////////////////////////////////////////////
let pairwise_and'_nil (#a:Type) (f:a -> a -> Type0)
= assert (pairwise_and' f [] == True) by (T.compute())
let pairwise_and'_cons (#a:Type) (f:a -> a -> Type) (hd:a) (tl:list a)
= assert (pairwise_and' f (hd::tl) == (big_and' (f hd) tl /\ pairwise_and' f tl))
by (T.trefl())
let pairwise_and'_prop (#a:Type) (f:a -> a -> Type) (l:list a)
= match l with
| [] -> pairwise_and'_nil f
| hd::tl -> pairwise_and'_cons f hd tl
(* Note, this is good example of where the difference between
the implicitly and explicitly reducing variants of the definitions
makes a difference.
Proving this lemma directly on the `pairwise_and` is much harder
since one has to reason about many partially reduced forms.
Instead, we first prove the lemma on the non-reducing primed
version of the definition, and then obtain the lemma we want
at the end using `normal_eq` *)
let rec pairwise_and'_forall (#a:Type) (f: a -> a -> Type) (l:list a)
= match l with
| [] -> pairwise_and'_nil f
| hd::tl ->
pairwise_and'_cons f hd tl;
pairwise_and'_forall f tl;
big_and'_forall (f hd) tl
let rec pairwise_and'_forall_no_repeats (#a:Type) (f: a -> a -> Type) (l:list a)
= match l with
| [] -> pairwise_and'_nil f
| hd::tl ->
pairwise_and'_cons f hd tl;
pairwise_and'_forall_no_repeats f tl;
big_and'_forall (f hd) tl
//////////////////////////////////////////////////////////////////////////////// | false | false | FStar.BigOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pairwise_or'_nil (#a: Type) (f: (a -> a -> Type0)) : Lemma (pairwise_or' f [] == False) | [] | FStar.BigOps.pairwise_or'_nil | {
"file_name": "ulib/FStar.BigOps.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: a -> _: a -> Type0)
-> FStar.Pervasives.Lemma (ensures FStar.BigOps.pairwise_or' f [] == Prims.l_False) | {
"end_col": 56,
"end_line": 108,
"start_col": 4,
"start_line": 108
} |
FStar.Pervasives.Lemma | val big_and'_nil (#a: Type) (f: (a -> Type)) : Lemma (big_and' f [] == True) | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let big_and'_nil (#a:Type) (f:a -> Type)
= assert (big_and' f [] == True) by (T.compute()) | val big_and'_nil (#a: Type) (f: (a -> Type)) : Lemma (big_and' f [] == True)
let big_and'_nil (#a: Type) (f: (a -> Type)) = | false | null | true | FStar.Tactics.Effect.assert_by_tactic (big_and' f [] == True)
(fun _ ->
();
(T.compute ())) | {
"checked_file": "FStar.BigOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.BigOps.fst"
} | [
"lemma"
] | [
"FStar.Tactics.Effect.assert_by_tactic",
"Prims.eq2",
"FStar.BigOps.big_and'",
"Prims.Nil",
"Prims.l_True",
"Prims.unit",
"FStar.Tactics.V2.Derived.compute"
] | [] | (*
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.BigOps
module T = FStar.Tactics.V2
let normal_eq (#a:Type) (f:a)
= ()
////////////////////////////////////////////////////////////////////////////////
let map_op'_nil
(#a:Type) (#b:Type) (#c:Type)
(op:b -> c -> GTot c) (f:a -> GTot b) (z:c)
: Lemma (map_op' op f [] z == z)
= ()
let map_op'_cons #a #b #c (op:b -> c -> GTot c) (f:a -> GTot b) (hd:a) (tl:list a) (z:c)
: Lemma (map_op' op f (hd::tl) z == f hd `op` map_op' op f tl z)
= ()
//////////////////////////////////////////////////////////////////////////////// | false | false | FStar.BigOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val big_and'_nil (#a: Type) (f: (a -> Type)) : Lemma (big_and' f [] == True) | [] | FStar.BigOps.big_and'_nil | {
"file_name": "ulib/FStar.BigOps.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: a -> Type0) -> FStar.Pervasives.Lemma (ensures FStar.BigOps.big_and' f [] == Prims.l_True) | {
"end_col": 51,
"end_line": 35,
"start_col": 4,
"start_line": 35
} |
FStar.Pervasives.Lemma | val pairwise_and'_cons (#a: Type) (f: (a -> a -> Type0)) (hd: a) (tl: list a)
: Lemma (pairwise_and' f (hd :: tl) == (big_and' (f hd) tl /\ pairwise_and' f tl)) | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pairwise_and'_cons (#a:Type) (f:a -> a -> Type) (hd:a) (tl:list a)
= assert (pairwise_and' f (hd::tl) == (big_and' (f hd) tl /\ pairwise_and' f tl))
by (T.trefl()) | val pairwise_and'_cons (#a: Type) (f: (a -> a -> Type0)) (hd: a) (tl: list a)
: Lemma (pairwise_and' f (hd :: tl) == (big_and' (f hd) tl /\ pairwise_and' f tl))
let pairwise_and'_cons (#a: Type) (f: (a -> a -> Type)) (hd: a) (tl: list a) = | false | null | true | FStar.Tactics.Effect.assert_by_tactic (pairwise_and' f (hd :: tl) ==
(big_and' (f hd) tl /\ pairwise_and' f tl))
(fun _ ->
();
(T.trefl ())) | {
"checked_file": "FStar.BigOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.BigOps.fst"
} | [
"lemma"
] | [
"Prims.list",
"FStar.Tactics.Effect.assert_by_tactic",
"Prims.eq2",
"FStar.BigOps.pairwise_and'",
"Prims.Cons",
"Prims.l_and",
"FStar.BigOps.big_and'",
"Prims.unit",
"FStar.Tactics.V2.Derived.trefl"
] | [] | (*
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.BigOps
module T = FStar.Tactics.V2
let normal_eq (#a:Type) (f:a)
= ()
////////////////////////////////////////////////////////////////////////////////
let map_op'_nil
(#a:Type) (#b:Type) (#c:Type)
(op:b -> c -> GTot c) (f:a -> GTot b) (z:c)
: Lemma (map_op' op f [] z == z)
= ()
let map_op'_cons #a #b #c (op:b -> c -> GTot c) (f:a -> GTot b) (hd:a) (tl:list a) (z:c)
: Lemma (map_op' op f (hd::tl) z == f hd `op` map_op' op f tl z)
= ()
////////////////////////////////////////////////////////////////////////////////
let big_and'_nil (#a:Type) (f:a -> Type)
= assert (big_and' f [] == True) by (T.compute())
let big_and'_cons (#a:Type) (f:a -> Type) (hd:a) (tl:list a)
= assert (big_and' f (hd :: tl) == (f hd /\ big_and' f tl)) by (T.compute())
let big_and'_prop (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_and'_nil f
| hd::tl -> big_and'_cons f hd tl
let rec big_and'_forall (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_and'_nil f; ()
| hd::tl -> big_and'_cons f hd tl; big_and'_forall f tl
////////////////////////////////////////////////////////////////////////////////
let big_or'_nil (#a:Type) (f:a -> Type)
= assert (big_or' f [] == False) by (T.compute())
let big_or'_cons (#a:Type) (f:a -> Type) (hd:a) (tl:list a)
= assert (big_or' f (hd :: tl) == (f hd \/ big_or' f tl)) by (T.compute())
let big_or'_prop (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_or'_nil f
| hd::tl -> big_or'_cons f hd tl
let rec big_or'_exists (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_or'_nil f; ()
| hd::tl -> big_or'_cons f hd tl; big_or'_exists f tl
////////////////////////////////////////////////////////////////////////////////
let pairwise_and'_nil (#a:Type) (f:a -> a -> Type0)
= assert (pairwise_and' f [] == True) by (T.compute()) | false | false | FStar.BigOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pairwise_and'_cons (#a: Type) (f: (a -> a -> Type0)) (hd: a) (tl: list a)
: Lemma (pairwise_and' f (hd :: tl) == (big_and' (f hd) tl /\ pairwise_and' f tl)) | [] | FStar.BigOps.pairwise_and'_cons | {
"file_name": "ulib/FStar.BigOps.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: a -> _: a -> Type0) -> hd: a -> tl: Prims.list a
-> FStar.Pervasives.Lemma
(ensures
FStar.BigOps.pairwise_and' f (hd :: tl) ==
FStar.BigOps.big_and' (f hd) tl /\ FStar.BigOps.pairwise_and' f tl) | {
"end_col": 22,
"end_line": 73,
"start_col": 4,
"start_line": 72
} |
FStar.Pervasives.Lemma | val big_and'_cons (#a: Type) (f: (a -> Type)) (hd: a) (tl: list a)
: Lemma (big_and' f (hd :: tl) == (f hd /\ big_and' f tl)) | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let big_and'_cons (#a:Type) (f:a -> Type) (hd:a) (tl:list a)
= assert (big_and' f (hd :: tl) == (f hd /\ big_and' f tl)) by (T.compute()) | val big_and'_cons (#a: Type) (f: (a -> Type)) (hd: a) (tl: list a)
: Lemma (big_and' f (hd :: tl) == (f hd /\ big_and' f tl))
let big_and'_cons (#a: Type) (f: (a -> Type)) (hd: a) (tl: list a) = | false | null | true | FStar.Tactics.Effect.assert_by_tactic (big_and' f (hd :: tl) == (f hd /\ big_and' f tl))
(fun _ ->
();
(T.compute ())) | {
"checked_file": "FStar.BigOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.BigOps.fst"
} | [
"lemma"
] | [
"Prims.list",
"FStar.Tactics.Effect.assert_by_tactic",
"Prims.eq2",
"FStar.BigOps.big_and'",
"Prims.Cons",
"Prims.l_and",
"Prims.unit",
"FStar.Tactics.V2.Derived.compute"
] | [] | (*
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.BigOps
module T = FStar.Tactics.V2
let normal_eq (#a:Type) (f:a)
= ()
////////////////////////////////////////////////////////////////////////////////
let map_op'_nil
(#a:Type) (#b:Type) (#c:Type)
(op:b -> c -> GTot c) (f:a -> GTot b) (z:c)
: Lemma (map_op' op f [] z == z)
= ()
let map_op'_cons #a #b #c (op:b -> c -> GTot c) (f:a -> GTot b) (hd:a) (tl:list a) (z:c)
: Lemma (map_op' op f (hd::tl) z == f hd `op` map_op' op f tl z)
= ()
////////////////////////////////////////////////////////////////////////////////
let big_and'_nil (#a:Type) (f:a -> Type)
= assert (big_and' f [] == True) by (T.compute()) | false | false | FStar.BigOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val big_and'_cons (#a: Type) (f: (a -> Type)) (hd: a) (tl: list a)
: Lemma (big_and' f (hd :: tl) == (f hd /\ big_and' f tl)) | [] | FStar.BigOps.big_and'_cons | {
"file_name": "ulib/FStar.BigOps.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: a -> Type0) -> hd: a -> tl: Prims.list a
-> FStar.Pervasives.Lemma
(ensures FStar.BigOps.big_and' f (hd :: tl) == f hd /\ FStar.BigOps.big_and' f tl) | {
"end_col": 78,
"end_line": 38,
"start_col": 4,
"start_line": 38
} |
FStar.Pervasives.Lemma | val big_or'_cons (#a: Type) (f: (a -> Type)) (hd: a) (tl: list a)
: Lemma (big_or' f (hd :: tl) == (f hd \/ big_or' f tl)) | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let big_or'_cons (#a:Type) (f:a -> Type) (hd:a) (tl:list a)
= assert (big_or' f (hd :: tl) == (f hd \/ big_or' f tl)) by (T.compute()) | val big_or'_cons (#a: Type) (f: (a -> Type)) (hd: a) (tl: list a)
: Lemma (big_or' f (hd :: tl) == (f hd \/ big_or' f tl))
let big_or'_cons (#a: Type) (f: (a -> Type)) (hd: a) (tl: list a) = | false | null | true | FStar.Tactics.Effect.assert_by_tactic (big_or' f (hd :: tl) == (f hd \/ big_or' f tl))
(fun _ ->
();
(T.compute ())) | {
"checked_file": "FStar.BigOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.BigOps.fst"
} | [
"lemma"
] | [
"Prims.list",
"FStar.Tactics.Effect.assert_by_tactic",
"Prims.eq2",
"FStar.BigOps.big_or'",
"Prims.Cons",
"Prims.l_or",
"Prims.unit",
"FStar.Tactics.V2.Derived.compute"
] | [] | (*
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.BigOps
module T = FStar.Tactics.V2
let normal_eq (#a:Type) (f:a)
= ()
////////////////////////////////////////////////////////////////////////////////
let map_op'_nil
(#a:Type) (#b:Type) (#c:Type)
(op:b -> c -> GTot c) (f:a -> GTot b) (z:c)
: Lemma (map_op' op f [] z == z)
= ()
let map_op'_cons #a #b #c (op:b -> c -> GTot c) (f:a -> GTot b) (hd:a) (tl:list a) (z:c)
: Lemma (map_op' op f (hd::tl) z == f hd `op` map_op' op f tl z)
= ()
////////////////////////////////////////////////////////////////////////////////
let big_and'_nil (#a:Type) (f:a -> Type)
= assert (big_and' f [] == True) by (T.compute())
let big_and'_cons (#a:Type) (f:a -> Type) (hd:a) (tl:list a)
= assert (big_and' f (hd :: tl) == (f hd /\ big_and' f tl)) by (T.compute())
let big_and'_prop (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_and'_nil f
| hd::tl -> big_and'_cons f hd tl
let rec big_and'_forall (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_and'_nil f; ()
| hd::tl -> big_and'_cons f hd tl; big_and'_forall f tl
////////////////////////////////////////////////////////////////////////////////
let big_or'_nil (#a:Type) (f:a -> Type)
= assert (big_or' f [] == False) by (T.compute()) | false | false | FStar.BigOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val big_or'_cons (#a: Type) (f: (a -> Type)) (hd: a) (tl: list a)
: Lemma (big_or' f (hd :: tl) == (f hd \/ big_or' f tl)) | [] | FStar.BigOps.big_or'_cons | {
"file_name": "ulib/FStar.BigOps.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: a -> Type0) -> hd: a -> tl: Prims.list a
-> FStar.Pervasives.Lemma
(ensures FStar.BigOps.big_or' f (hd :: tl) == (f hd \/ FStar.BigOps.big_or' f tl)) | {
"end_col": 76,
"end_line": 55,
"start_col": 4,
"start_line": 55
} |
FStar.Pervasives.Lemma | val big_or'_prop (#a: Type) (f: (a -> Type)) (l: list a) : Lemma ((big_or' f l) `subtype_of` unit) | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let big_or'_prop (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_or'_nil f
| hd::tl -> big_or'_cons f hd tl | val big_or'_prop (#a: Type) (f: (a -> Type)) (l: list a) : Lemma ((big_or' f l) `subtype_of` unit)
let big_or'_prop (#a: Type) (f: (a -> Type)) (l: list a) = | false | null | true | match l with
| [] -> big_or'_nil f
| hd :: tl -> big_or'_cons f hd tl | {
"checked_file": "FStar.BigOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.BigOps.fst"
} | [
"lemma"
] | [
"Prims.list",
"FStar.BigOps.big_or'_nil",
"FStar.BigOps.big_or'_cons",
"Prims.unit"
] | [] | (*
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.BigOps
module T = FStar.Tactics.V2
let normal_eq (#a:Type) (f:a)
= ()
////////////////////////////////////////////////////////////////////////////////
let map_op'_nil
(#a:Type) (#b:Type) (#c:Type)
(op:b -> c -> GTot c) (f:a -> GTot b) (z:c)
: Lemma (map_op' op f [] z == z)
= ()
let map_op'_cons #a #b #c (op:b -> c -> GTot c) (f:a -> GTot b) (hd:a) (tl:list a) (z:c)
: Lemma (map_op' op f (hd::tl) z == f hd `op` map_op' op f tl z)
= ()
////////////////////////////////////////////////////////////////////////////////
let big_and'_nil (#a:Type) (f:a -> Type)
= assert (big_and' f [] == True) by (T.compute())
let big_and'_cons (#a:Type) (f:a -> Type) (hd:a) (tl:list a)
= assert (big_and' f (hd :: tl) == (f hd /\ big_and' f tl)) by (T.compute())
let big_and'_prop (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_and'_nil f
| hd::tl -> big_and'_cons f hd tl
let rec big_and'_forall (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_and'_nil f; ()
| hd::tl -> big_and'_cons f hd tl; big_and'_forall f tl
////////////////////////////////////////////////////////////////////////////////
let big_or'_nil (#a:Type) (f:a -> Type)
= assert (big_or' f [] == False) by (T.compute())
let big_or'_cons (#a:Type) (f:a -> Type) (hd:a) (tl:list a)
= assert (big_or' f (hd :: tl) == (f hd \/ big_or' f tl)) by (T.compute()) | false | false | FStar.BigOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val big_or'_prop (#a: Type) (f: (a -> Type)) (l: list a) : Lemma ((big_or' f l) `subtype_of` unit) | [] | FStar.BigOps.big_or'_prop | {
"file_name": "ulib/FStar.BigOps.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: a -> Type0) -> l: Prims.list a
-> FStar.Pervasives.Lemma (ensures Prims.subtype_of (FStar.BigOps.big_or' f l) Prims.unit) | {
"end_col": 36,
"end_line": 60,
"start_col": 4,
"start_line": 58
} |
FStar.Pervasives.Lemma | val pairwise_and'_nil (#a: Type) (f: (a -> a -> Type0)) : Lemma (pairwise_and' f [] == True) | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pairwise_and'_nil (#a:Type) (f:a -> a -> Type0)
= assert (pairwise_and' f [] == True) by (T.compute()) | val pairwise_and'_nil (#a: Type) (f: (a -> a -> Type0)) : Lemma (pairwise_and' f [] == True)
let pairwise_and'_nil (#a: Type) (f: (a -> a -> Type0)) = | false | null | true | FStar.Tactics.Effect.assert_by_tactic (pairwise_and' f [] == True)
(fun _ ->
();
(T.compute ())) | {
"checked_file": "FStar.BigOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.BigOps.fst"
} | [
"lemma"
] | [
"FStar.Tactics.Effect.assert_by_tactic",
"Prims.eq2",
"FStar.BigOps.pairwise_and'",
"Prims.Nil",
"Prims.l_True",
"Prims.unit",
"FStar.Tactics.V2.Derived.compute"
] | [] | (*
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.BigOps
module T = FStar.Tactics.V2
let normal_eq (#a:Type) (f:a)
= ()
////////////////////////////////////////////////////////////////////////////////
let map_op'_nil
(#a:Type) (#b:Type) (#c:Type)
(op:b -> c -> GTot c) (f:a -> GTot b) (z:c)
: Lemma (map_op' op f [] z == z)
= ()
let map_op'_cons #a #b #c (op:b -> c -> GTot c) (f:a -> GTot b) (hd:a) (tl:list a) (z:c)
: Lemma (map_op' op f (hd::tl) z == f hd `op` map_op' op f tl z)
= ()
////////////////////////////////////////////////////////////////////////////////
let big_and'_nil (#a:Type) (f:a -> Type)
= assert (big_and' f [] == True) by (T.compute())
let big_and'_cons (#a:Type) (f:a -> Type) (hd:a) (tl:list a)
= assert (big_and' f (hd :: tl) == (f hd /\ big_and' f tl)) by (T.compute())
let big_and'_prop (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_and'_nil f
| hd::tl -> big_and'_cons f hd tl
let rec big_and'_forall (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_and'_nil f; ()
| hd::tl -> big_and'_cons f hd tl; big_and'_forall f tl
////////////////////////////////////////////////////////////////////////////////
let big_or'_nil (#a:Type) (f:a -> Type)
= assert (big_or' f [] == False) by (T.compute())
let big_or'_cons (#a:Type) (f:a -> Type) (hd:a) (tl:list a)
= assert (big_or' f (hd :: tl) == (f hd \/ big_or' f tl)) by (T.compute())
let big_or'_prop (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_or'_nil f
| hd::tl -> big_or'_cons f hd tl
let rec big_or'_exists (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_or'_nil f; ()
| hd::tl -> big_or'_cons f hd tl; big_or'_exists f tl
//////////////////////////////////////////////////////////////////////////////// | false | false | FStar.BigOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pairwise_and'_nil (#a: Type) (f: (a -> a -> Type0)) : Lemma (pairwise_and' f [] == True) | [] | FStar.BigOps.pairwise_and'_nil | {
"file_name": "ulib/FStar.BigOps.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: a -> _: a -> Type0)
-> FStar.Pervasives.Lemma (ensures FStar.BigOps.pairwise_and' f [] == Prims.l_True) | {
"end_col": 56,
"end_line": 69,
"start_col": 4,
"start_line": 69
} |
FStar.Pervasives.Lemma | val pairwise_or'_prop (#a: Type) (f: (a -> a -> Type)) (l: list a)
: Lemma ((pairwise_or' f l) `subtype_of` unit) | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pairwise_or'_prop (#a:Type) (f:a -> a -> Type) (l:list a)
= match l with
| [] -> pairwise_or'_nil f
| hd::tl -> pairwise_or'_cons f hd tl | val pairwise_or'_prop (#a: Type) (f: (a -> a -> Type)) (l: list a)
: Lemma ((pairwise_or' f l) `subtype_of` unit)
let pairwise_or'_prop (#a: Type) (f: (a -> a -> Type)) (l: list a) = | false | null | true | match l with
| [] -> pairwise_or'_nil f
| hd :: tl -> pairwise_or'_cons f hd tl | {
"checked_file": "FStar.BigOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.BigOps.fst"
} | [
"lemma"
] | [
"Prims.list",
"FStar.BigOps.pairwise_or'_nil",
"FStar.BigOps.pairwise_or'_cons",
"Prims.unit"
] | [] | (*
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.BigOps
module T = FStar.Tactics.V2
let normal_eq (#a:Type) (f:a)
= ()
////////////////////////////////////////////////////////////////////////////////
let map_op'_nil
(#a:Type) (#b:Type) (#c:Type)
(op:b -> c -> GTot c) (f:a -> GTot b) (z:c)
: Lemma (map_op' op f [] z == z)
= ()
let map_op'_cons #a #b #c (op:b -> c -> GTot c) (f:a -> GTot b) (hd:a) (tl:list a) (z:c)
: Lemma (map_op' op f (hd::tl) z == f hd `op` map_op' op f tl z)
= ()
////////////////////////////////////////////////////////////////////////////////
let big_and'_nil (#a:Type) (f:a -> Type)
= assert (big_and' f [] == True) by (T.compute())
let big_and'_cons (#a:Type) (f:a -> Type) (hd:a) (tl:list a)
= assert (big_and' f (hd :: tl) == (f hd /\ big_and' f tl)) by (T.compute())
let big_and'_prop (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_and'_nil f
| hd::tl -> big_and'_cons f hd tl
let rec big_and'_forall (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_and'_nil f; ()
| hd::tl -> big_and'_cons f hd tl; big_and'_forall f tl
////////////////////////////////////////////////////////////////////////////////
let big_or'_nil (#a:Type) (f:a -> Type)
= assert (big_or' f [] == False) by (T.compute())
let big_or'_cons (#a:Type) (f:a -> Type) (hd:a) (tl:list a)
= assert (big_or' f (hd :: tl) == (f hd \/ big_or' f tl)) by (T.compute())
let big_or'_prop (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_or'_nil f
| hd::tl -> big_or'_cons f hd tl
let rec big_or'_exists (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_or'_nil f; ()
| hd::tl -> big_or'_cons f hd tl; big_or'_exists f tl
////////////////////////////////////////////////////////////////////////////////
let pairwise_and'_nil (#a:Type) (f:a -> a -> Type0)
= assert (pairwise_and' f [] == True) by (T.compute())
let pairwise_and'_cons (#a:Type) (f:a -> a -> Type) (hd:a) (tl:list a)
= assert (pairwise_and' f (hd::tl) == (big_and' (f hd) tl /\ pairwise_and' f tl))
by (T.trefl())
let pairwise_and'_prop (#a:Type) (f:a -> a -> Type) (l:list a)
= match l with
| [] -> pairwise_and'_nil f
| hd::tl -> pairwise_and'_cons f hd tl
(* Note, this is good example of where the difference between
the implicitly and explicitly reducing variants of the definitions
makes a difference.
Proving this lemma directly on the `pairwise_and` is much harder
since one has to reason about many partially reduced forms.
Instead, we first prove the lemma on the non-reducing primed
version of the definition, and then obtain the lemma we want
at the end using `normal_eq` *)
let rec pairwise_and'_forall (#a:Type) (f: a -> a -> Type) (l:list a)
= match l with
| [] -> pairwise_and'_nil f
| hd::tl ->
pairwise_and'_cons f hd tl;
pairwise_and'_forall f tl;
big_and'_forall (f hd) tl
let rec pairwise_and'_forall_no_repeats (#a:Type) (f: a -> a -> Type) (l:list a)
= match l with
| [] -> pairwise_and'_nil f
| hd::tl ->
pairwise_and'_cons f hd tl;
pairwise_and'_forall_no_repeats f tl;
big_and'_forall (f hd) tl
////////////////////////////////////////////////////////////////////////////////
let pairwise_or'_nil (#a:Type) (f:a -> a -> Type0)
= assert (pairwise_or' f [] == False) by (T.compute())
let pairwise_or'_cons (#a:Type) (f:a -> a -> Type) (hd:a) (tl:list a)
= assert (pairwise_or' f (hd::tl) == (big_or' (f hd) tl \/ pairwise_or' f tl)) | false | false | FStar.BigOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pairwise_or'_prop (#a: Type) (f: (a -> a -> Type)) (l: list a)
: Lemma ((pairwise_or' f l) `subtype_of` unit) | [] | FStar.BigOps.pairwise_or'_prop | {
"file_name": "ulib/FStar.BigOps.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: a -> _: a -> Type0) -> l: Prims.list a
-> FStar.Pervasives.Lemma (ensures Prims.subtype_of (FStar.BigOps.pairwise_or' f l) Prims.unit) | {
"end_col": 41,
"end_line": 116,
"start_col": 4,
"start_line": 114
} |
FStar.Pervasives.Lemma | val pairwise_or'_exists (#a: Type) (f: (a -> a -> Type)) (l: list a)
: Lemma (requires symmetric f /\ anti_reflexive f)
(ensures (pairwise_or' f l <==> (exists x y. L.memP x l /\ L.memP y l /\ f x y))) | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec pairwise_or'_exists (#a:Type) (f: a -> a -> Type) (l:list a)
= match l with
| [] -> pairwise_or'_nil f
| hd::tl ->
pairwise_or'_cons f hd tl;
pairwise_or'_exists f tl;
big_or'_exists (f hd) tl | val pairwise_or'_exists (#a: Type) (f: (a -> a -> Type)) (l: list a)
: Lemma (requires symmetric f /\ anti_reflexive f)
(ensures (pairwise_or' f l <==> (exists x y. L.memP x l /\ L.memP y l /\ f x y)))
let rec pairwise_or'_exists (#a: Type) (f: (a -> a -> Type)) (l: list a) = | false | null | true | match l with
| [] -> pairwise_or'_nil f
| hd :: tl ->
pairwise_or'_cons f hd tl;
pairwise_or'_exists f tl;
big_or'_exists (f hd) tl | {
"checked_file": "FStar.BigOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.BigOps.fst"
} | [
"lemma"
] | [
"Prims.list",
"FStar.BigOps.pairwise_or'_nil",
"FStar.BigOps.big_or'_exists",
"Prims.unit",
"FStar.BigOps.pairwise_or'_exists",
"FStar.BigOps.pairwise_or'_cons"
] | [] | (*
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.BigOps
module T = FStar.Tactics.V2
let normal_eq (#a:Type) (f:a)
= ()
////////////////////////////////////////////////////////////////////////////////
let map_op'_nil
(#a:Type) (#b:Type) (#c:Type)
(op:b -> c -> GTot c) (f:a -> GTot b) (z:c)
: Lemma (map_op' op f [] z == z)
= ()
let map_op'_cons #a #b #c (op:b -> c -> GTot c) (f:a -> GTot b) (hd:a) (tl:list a) (z:c)
: Lemma (map_op' op f (hd::tl) z == f hd `op` map_op' op f tl z)
= ()
////////////////////////////////////////////////////////////////////////////////
let big_and'_nil (#a:Type) (f:a -> Type)
= assert (big_and' f [] == True) by (T.compute())
let big_and'_cons (#a:Type) (f:a -> Type) (hd:a) (tl:list a)
= assert (big_and' f (hd :: tl) == (f hd /\ big_and' f tl)) by (T.compute())
let big_and'_prop (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_and'_nil f
| hd::tl -> big_and'_cons f hd tl
let rec big_and'_forall (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_and'_nil f; ()
| hd::tl -> big_and'_cons f hd tl; big_and'_forall f tl
////////////////////////////////////////////////////////////////////////////////
let big_or'_nil (#a:Type) (f:a -> Type)
= assert (big_or' f [] == False) by (T.compute())
let big_or'_cons (#a:Type) (f:a -> Type) (hd:a) (tl:list a)
= assert (big_or' f (hd :: tl) == (f hd \/ big_or' f tl)) by (T.compute())
let big_or'_prop (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_or'_nil f
| hd::tl -> big_or'_cons f hd tl
let rec big_or'_exists (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_or'_nil f; ()
| hd::tl -> big_or'_cons f hd tl; big_or'_exists f tl
////////////////////////////////////////////////////////////////////////////////
let pairwise_and'_nil (#a:Type) (f:a -> a -> Type0)
= assert (pairwise_and' f [] == True) by (T.compute())
let pairwise_and'_cons (#a:Type) (f:a -> a -> Type) (hd:a) (tl:list a)
= assert (pairwise_and' f (hd::tl) == (big_and' (f hd) tl /\ pairwise_and' f tl))
by (T.trefl())
let pairwise_and'_prop (#a:Type) (f:a -> a -> Type) (l:list a)
= match l with
| [] -> pairwise_and'_nil f
| hd::tl -> pairwise_and'_cons f hd tl
(* Note, this is good example of where the difference between
the implicitly and explicitly reducing variants of the definitions
makes a difference.
Proving this lemma directly on the `pairwise_and` is much harder
since one has to reason about many partially reduced forms.
Instead, we first prove the lemma on the non-reducing primed
version of the definition, and then obtain the lemma we want
at the end using `normal_eq` *)
let rec pairwise_and'_forall (#a:Type) (f: a -> a -> Type) (l:list a)
= match l with
| [] -> pairwise_and'_nil f
| hd::tl ->
pairwise_and'_cons f hd tl;
pairwise_and'_forall f tl;
big_and'_forall (f hd) tl
let rec pairwise_and'_forall_no_repeats (#a:Type) (f: a -> a -> Type) (l:list a)
= match l with
| [] -> pairwise_and'_nil f
| hd::tl ->
pairwise_and'_cons f hd tl;
pairwise_and'_forall_no_repeats f tl;
big_and'_forall (f hd) tl
////////////////////////////////////////////////////////////////////////////////
let pairwise_or'_nil (#a:Type) (f:a -> a -> Type0)
= assert (pairwise_or' f [] == False) by (T.compute())
let pairwise_or'_cons (#a:Type) (f:a -> a -> Type) (hd:a) (tl:list a)
= assert (pairwise_or' f (hd::tl) == (big_or' (f hd) tl \/ pairwise_or' f tl))
let pairwise_or'_prop (#a:Type) (f:a -> a -> Type) (l:list a)
= match l with
| [] -> pairwise_or'_nil f
| hd::tl -> pairwise_or'_cons f hd tl | false | false | FStar.BigOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pairwise_or'_exists (#a: Type) (f: (a -> a -> Type)) (l: list a)
: Lemma (requires symmetric f /\ anti_reflexive f)
(ensures (pairwise_or' f l <==> (exists x y. L.memP x l /\ L.memP y l /\ f x y))) | [
"recursion"
] | FStar.BigOps.pairwise_or'_exists | {
"file_name": "ulib/FStar.BigOps.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: a -> _: a -> Type0) -> l: Prims.list a
-> FStar.Pervasives.Lemma (requires FStar.BigOps.symmetric f /\ FStar.BigOps.anti_reflexive f)
(ensures
FStar.BigOps.pairwise_or' f l <==>
(exists (x: a) (y: a). FStar.List.Tot.Base.memP x l /\ FStar.List.Tot.Base.memP y l /\ f x y
)) | {
"end_col": 30,
"end_line": 124,
"start_col": 4,
"start_line": 119
} |
FStar.Pervasives.Lemma | val pairwise_and'_prop (#a: Type) (f: (a -> a -> Type)) (l: list a)
: Lemma ((pairwise_and' f l) `subtype_of` unit) | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pairwise_and'_prop (#a:Type) (f:a -> a -> Type) (l:list a)
= match l with
| [] -> pairwise_and'_nil f
| hd::tl -> pairwise_and'_cons f hd tl | val pairwise_and'_prop (#a: Type) (f: (a -> a -> Type)) (l: list a)
: Lemma ((pairwise_and' f l) `subtype_of` unit)
let pairwise_and'_prop (#a: Type) (f: (a -> a -> Type)) (l: list a) = | false | null | true | match l with
| [] -> pairwise_and'_nil f
| hd :: tl -> pairwise_and'_cons f hd tl | {
"checked_file": "FStar.BigOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.BigOps.fst"
} | [
"lemma"
] | [
"Prims.list",
"FStar.BigOps.pairwise_and'_nil",
"FStar.BigOps.pairwise_and'_cons",
"Prims.unit"
] | [] | (*
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.BigOps
module T = FStar.Tactics.V2
let normal_eq (#a:Type) (f:a)
= ()
////////////////////////////////////////////////////////////////////////////////
let map_op'_nil
(#a:Type) (#b:Type) (#c:Type)
(op:b -> c -> GTot c) (f:a -> GTot b) (z:c)
: Lemma (map_op' op f [] z == z)
= ()
let map_op'_cons #a #b #c (op:b -> c -> GTot c) (f:a -> GTot b) (hd:a) (tl:list a) (z:c)
: Lemma (map_op' op f (hd::tl) z == f hd `op` map_op' op f tl z)
= ()
////////////////////////////////////////////////////////////////////////////////
let big_and'_nil (#a:Type) (f:a -> Type)
= assert (big_and' f [] == True) by (T.compute())
let big_and'_cons (#a:Type) (f:a -> Type) (hd:a) (tl:list a)
= assert (big_and' f (hd :: tl) == (f hd /\ big_and' f tl)) by (T.compute())
let big_and'_prop (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_and'_nil f
| hd::tl -> big_and'_cons f hd tl
let rec big_and'_forall (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_and'_nil f; ()
| hd::tl -> big_and'_cons f hd tl; big_and'_forall f tl
////////////////////////////////////////////////////////////////////////////////
let big_or'_nil (#a:Type) (f:a -> Type)
= assert (big_or' f [] == False) by (T.compute())
let big_or'_cons (#a:Type) (f:a -> Type) (hd:a) (tl:list a)
= assert (big_or' f (hd :: tl) == (f hd \/ big_or' f tl)) by (T.compute())
let big_or'_prop (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_or'_nil f
| hd::tl -> big_or'_cons f hd tl
let rec big_or'_exists (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_or'_nil f; ()
| hd::tl -> big_or'_cons f hd tl; big_or'_exists f tl
////////////////////////////////////////////////////////////////////////////////
let pairwise_and'_nil (#a:Type) (f:a -> a -> Type0)
= assert (pairwise_and' f [] == True) by (T.compute())
let pairwise_and'_cons (#a:Type) (f:a -> a -> Type) (hd:a) (tl:list a)
= assert (pairwise_and' f (hd::tl) == (big_and' (f hd) tl /\ pairwise_and' f tl))
by (T.trefl()) | false | false | FStar.BigOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pairwise_and'_prop (#a: Type) (f: (a -> a -> Type)) (l: list a)
: Lemma ((pairwise_and' f l) `subtype_of` unit) | [] | FStar.BigOps.pairwise_and'_prop | {
"file_name": "ulib/FStar.BigOps.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: a -> _: a -> Type0) -> l: Prims.list a
-> FStar.Pervasives.Lemma (ensures Prims.subtype_of (FStar.BigOps.pairwise_and' f l) Prims.unit) | {
"end_col": 42,
"end_line": 78,
"start_col": 4,
"start_line": 76
} |
FStar.Pervasives.Lemma | val pairwise_and'_forall_no_repeats (#a: Type) (f: (a -> a -> Type)) (l: list a)
: Lemma (requires symmetric f /\ L.no_repeats_p l)
(ensures (pairwise_and' f l <==> (forall x y. L.memP x l /\ L.memP y l /\ x =!= y ==> f x y))) | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec pairwise_and'_forall_no_repeats (#a:Type) (f: a -> a -> Type) (l:list a)
= match l with
| [] -> pairwise_and'_nil f
| hd::tl ->
pairwise_and'_cons f hd tl;
pairwise_and'_forall_no_repeats f tl;
big_and'_forall (f hd) tl | val pairwise_and'_forall_no_repeats (#a: Type) (f: (a -> a -> Type)) (l: list a)
: Lemma (requires symmetric f /\ L.no_repeats_p l)
(ensures (pairwise_and' f l <==> (forall x y. L.memP x l /\ L.memP y l /\ x =!= y ==> f x y)))
let rec pairwise_and'_forall_no_repeats (#a: Type) (f: (a -> a -> Type)) (l: list a) = | false | null | true | match l with
| [] -> pairwise_and'_nil f
| hd :: tl ->
pairwise_and'_cons f hd tl;
pairwise_and'_forall_no_repeats f tl;
big_and'_forall (f hd) tl | {
"checked_file": "FStar.BigOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.BigOps.fst"
} | [
"lemma"
] | [
"Prims.list",
"FStar.BigOps.pairwise_and'_nil",
"FStar.BigOps.big_and'_forall",
"Prims.unit",
"FStar.BigOps.pairwise_and'_forall_no_repeats",
"FStar.BigOps.pairwise_and'_cons"
] | [] | (*
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.BigOps
module T = FStar.Tactics.V2
let normal_eq (#a:Type) (f:a)
= ()
////////////////////////////////////////////////////////////////////////////////
let map_op'_nil
(#a:Type) (#b:Type) (#c:Type)
(op:b -> c -> GTot c) (f:a -> GTot b) (z:c)
: Lemma (map_op' op f [] z == z)
= ()
let map_op'_cons #a #b #c (op:b -> c -> GTot c) (f:a -> GTot b) (hd:a) (tl:list a) (z:c)
: Lemma (map_op' op f (hd::tl) z == f hd `op` map_op' op f tl z)
= ()
////////////////////////////////////////////////////////////////////////////////
let big_and'_nil (#a:Type) (f:a -> Type)
= assert (big_and' f [] == True) by (T.compute())
let big_and'_cons (#a:Type) (f:a -> Type) (hd:a) (tl:list a)
= assert (big_and' f (hd :: tl) == (f hd /\ big_and' f tl)) by (T.compute())
let big_and'_prop (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_and'_nil f
| hd::tl -> big_and'_cons f hd tl
let rec big_and'_forall (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_and'_nil f; ()
| hd::tl -> big_and'_cons f hd tl; big_and'_forall f tl
////////////////////////////////////////////////////////////////////////////////
let big_or'_nil (#a:Type) (f:a -> Type)
= assert (big_or' f [] == False) by (T.compute())
let big_or'_cons (#a:Type) (f:a -> Type) (hd:a) (tl:list a)
= assert (big_or' f (hd :: tl) == (f hd \/ big_or' f tl)) by (T.compute())
let big_or'_prop (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_or'_nil f
| hd::tl -> big_or'_cons f hd tl
let rec big_or'_exists (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_or'_nil f; ()
| hd::tl -> big_or'_cons f hd tl; big_or'_exists f tl
////////////////////////////////////////////////////////////////////////////////
let pairwise_and'_nil (#a:Type) (f:a -> a -> Type0)
= assert (pairwise_and' f [] == True) by (T.compute())
let pairwise_and'_cons (#a:Type) (f:a -> a -> Type) (hd:a) (tl:list a)
= assert (pairwise_and' f (hd::tl) == (big_and' (f hd) tl /\ pairwise_and' f tl))
by (T.trefl())
let pairwise_and'_prop (#a:Type) (f:a -> a -> Type) (l:list a)
= match l with
| [] -> pairwise_and'_nil f
| hd::tl -> pairwise_and'_cons f hd tl
(* Note, this is good example of where the difference between
the implicitly and explicitly reducing variants of the definitions
makes a difference.
Proving this lemma directly on the `pairwise_and` is much harder
since one has to reason about many partially reduced forms.
Instead, we first prove the lemma on the non-reducing primed
version of the definition, and then obtain the lemma we want
at the end using `normal_eq` *)
let rec pairwise_and'_forall (#a:Type) (f: a -> a -> Type) (l:list a)
= match l with
| [] -> pairwise_and'_nil f
| hd::tl ->
pairwise_and'_cons f hd tl;
pairwise_and'_forall f tl;
big_and'_forall (f hd) tl | false | false | FStar.BigOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pairwise_and'_forall_no_repeats (#a: Type) (f: (a -> a -> Type)) (l: list a)
: Lemma (requires symmetric f /\ L.no_repeats_p l)
(ensures (pairwise_and' f l <==> (forall x y. L.memP x l /\ L.memP y l /\ x =!= y ==> f x y))) | [
"recursion"
] | FStar.BigOps.pairwise_and'_forall_no_repeats | {
"file_name": "ulib/FStar.BigOps.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: a -> _: a -> Type0) -> l: Prims.list a
-> FStar.Pervasives.Lemma
(requires FStar.BigOps.symmetric f /\ FStar.List.Tot.Base.no_repeats_p l)
(ensures
FStar.BigOps.pairwise_and' f l <==>
(forall (x: a) (y: a).
FStar.List.Tot.Base.memP x l /\ FStar.List.Tot.Base.memP y l /\ ~(x == y) ==> f x y)) | {
"end_col": 31,
"end_line": 104,
"start_col": 4,
"start_line": 99
} |
FStar.Pervasives.Lemma | val big_and'_forall (#a: Type) (f: (a -> Type)) (l: list a)
: Lemma (big_and' f l <==> (forall x. L.memP x l ==> f x)) | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec big_and'_forall (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_and'_nil f; ()
| hd::tl -> big_and'_cons f hd tl; big_and'_forall f tl | val big_and'_forall (#a: Type) (f: (a -> Type)) (l: list a)
: Lemma (big_and' f l <==> (forall x. L.memP x l ==> f x))
let rec big_and'_forall (#a: Type) (f: (a -> Type)) (l: list a) = | false | null | true | match l with
| [] ->
big_and'_nil f;
()
| hd :: tl ->
big_and'_cons f hd tl;
big_and'_forall f tl | {
"checked_file": "FStar.BigOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.BigOps.fst"
} | [
"lemma"
] | [
"Prims.list",
"Prims.unit",
"FStar.BigOps.big_and'_nil",
"FStar.BigOps.big_and'_forall",
"FStar.BigOps.big_and'_cons"
] | [] | (*
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.BigOps
module T = FStar.Tactics.V2
let normal_eq (#a:Type) (f:a)
= ()
////////////////////////////////////////////////////////////////////////////////
let map_op'_nil
(#a:Type) (#b:Type) (#c:Type)
(op:b -> c -> GTot c) (f:a -> GTot b) (z:c)
: Lemma (map_op' op f [] z == z)
= ()
let map_op'_cons #a #b #c (op:b -> c -> GTot c) (f:a -> GTot b) (hd:a) (tl:list a) (z:c)
: Lemma (map_op' op f (hd::tl) z == f hd `op` map_op' op f tl z)
= ()
////////////////////////////////////////////////////////////////////////////////
let big_and'_nil (#a:Type) (f:a -> Type)
= assert (big_and' f [] == True) by (T.compute())
let big_and'_cons (#a:Type) (f:a -> Type) (hd:a) (tl:list a)
= assert (big_and' f (hd :: tl) == (f hd /\ big_and' f tl)) by (T.compute())
let big_and'_prop (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_and'_nil f
| hd::tl -> big_and'_cons f hd tl | false | false | FStar.BigOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val big_and'_forall (#a: Type) (f: (a -> Type)) (l: list a)
: Lemma (big_and' f l <==> (forall x. L.memP x l ==> f x)) | [
"recursion"
] | FStar.BigOps.big_and'_forall | {
"file_name": "ulib/FStar.BigOps.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: a -> Type0) -> l: Prims.list a
-> FStar.Pervasives.Lemma
(ensures FStar.BigOps.big_and' f l <==> (forall (x: a). FStar.List.Tot.Base.memP x l ==> f x)) | {
"end_col": 59,
"end_line": 48,
"start_col": 4,
"start_line": 46
} |
FStar.Pervasives.Lemma | val pairwise_or'_exists_no_repeats (#a: Type) (f: (a -> a -> Type)) (l: list a)
: Lemma (requires symmetric f /\ L.no_repeats_p l)
(ensures (pairwise_or' f l <==> (exists x y. L.memP x l /\ L.memP y l /\ x =!= y /\ f x y))) | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec pairwise_or'_exists_no_repeats (#a:Type) (f: a -> a -> Type) (l:list a)
= match l with
| [] -> pairwise_or'_nil f
| hd::tl ->
pairwise_or'_cons f hd tl;
pairwise_or'_exists_no_repeats f tl;
big_or'_exists (f hd) tl | val pairwise_or'_exists_no_repeats (#a: Type) (f: (a -> a -> Type)) (l: list a)
: Lemma (requires symmetric f /\ L.no_repeats_p l)
(ensures (pairwise_or' f l <==> (exists x y. L.memP x l /\ L.memP y l /\ x =!= y /\ f x y)))
let rec pairwise_or'_exists_no_repeats (#a: Type) (f: (a -> a -> Type)) (l: list a) = | false | null | true | match l with
| [] -> pairwise_or'_nil f
| hd :: tl ->
pairwise_or'_cons f hd tl;
pairwise_or'_exists_no_repeats f tl;
big_or'_exists (f hd) tl | {
"checked_file": "FStar.BigOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.BigOps.fst"
} | [
"lemma"
] | [
"Prims.list",
"FStar.BigOps.pairwise_or'_nil",
"FStar.BigOps.big_or'_exists",
"Prims.unit",
"FStar.BigOps.pairwise_or'_exists_no_repeats",
"FStar.BigOps.pairwise_or'_cons"
] | [] | (*
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.BigOps
module T = FStar.Tactics.V2
let normal_eq (#a:Type) (f:a)
= ()
////////////////////////////////////////////////////////////////////////////////
let map_op'_nil
(#a:Type) (#b:Type) (#c:Type)
(op:b -> c -> GTot c) (f:a -> GTot b) (z:c)
: Lemma (map_op' op f [] z == z)
= ()
let map_op'_cons #a #b #c (op:b -> c -> GTot c) (f:a -> GTot b) (hd:a) (tl:list a) (z:c)
: Lemma (map_op' op f (hd::tl) z == f hd `op` map_op' op f tl z)
= ()
////////////////////////////////////////////////////////////////////////////////
let big_and'_nil (#a:Type) (f:a -> Type)
= assert (big_and' f [] == True) by (T.compute())
let big_and'_cons (#a:Type) (f:a -> Type) (hd:a) (tl:list a)
= assert (big_and' f (hd :: tl) == (f hd /\ big_and' f tl)) by (T.compute())
let big_and'_prop (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_and'_nil f
| hd::tl -> big_and'_cons f hd tl
let rec big_and'_forall (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_and'_nil f; ()
| hd::tl -> big_and'_cons f hd tl; big_and'_forall f tl
////////////////////////////////////////////////////////////////////////////////
let big_or'_nil (#a:Type) (f:a -> Type)
= assert (big_or' f [] == False) by (T.compute())
let big_or'_cons (#a:Type) (f:a -> Type) (hd:a) (tl:list a)
= assert (big_or' f (hd :: tl) == (f hd \/ big_or' f tl)) by (T.compute())
let big_or'_prop (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_or'_nil f
| hd::tl -> big_or'_cons f hd tl
let rec big_or'_exists (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_or'_nil f; ()
| hd::tl -> big_or'_cons f hd tl; big_or'_exists f tl
////////////////////////////////////////////////////////////////////////////////
let pairwise_and'_nil (#a:Type) (f:a -> a -> Type0)
= assert (pairwise_and' f [] == True) by (T.compute())
let pairwise_and'_cons (#a:Type) (f:a -> a -> Type) (hd:a) (tl:list a)
= assert (pairwise_and' f (hd::tl) == (big_and' (f hd) tl /\ pairwise_and' f tl))
by (T.trefl())
let pairwise_and'_prop (#a:Type) (f:a -> a -> Type) (l:list a)
= match l with
| [] -> pairwise_and'_nil f
| hd::tl -> pairwise_and'_cons f hd tl
(* Note, this is good example of where the difference between
the implicitly and explicitly reducing variants of the definitions
makes a difference.
Proving this lemma directly on the `pairwise_and` is much harder
since one has to reason about many partially reduced forms.
Instead, we first prove the lemma on the non-reducing primed
version of the definition, and then obtain the lemma we want
at the end using `normal_eq` *)
let rec pairwise_and'_forall (#a:Type) (f: a -> a -> Type) (l:list a)
= match l with
| [] -> pairwise_and'_nil f
| hd::tl ->
pairwise_and'_cons f hd tl;
pairwise_and'_forall f tl;
big_and'_forall (f hd) tl
let rec pairwise_and'_forall_no_repeats (#a:Type) (f: a -> a -> Type) (l:list a)
= match l with
| [] -> pairwise_and'_nil f
| hd::tl ->
pairwise_and'_cons f hd tl;
pairwise_and'_forall_no_repeats f tl;
big_and'_forall (f hd) tl
////////////////////////////////////////////////////////////////////////////////
let pairwise_or'_nil (#a:Type) (f:a -> a -> Type0)
= assert (pairwise_or' f [] == False) by (T.compute())
let pairwise_or'_cons (#a:Type) (f:a -> a -> Type) (hd:a) (tl:list a)
= assert (pairwise_or' f (hd::tl) == (big_or' (f hd) tl \/ pairwise_or' f tl))
let pairwise_or'_prop (#a:Type) (f:a -> a -> Type) (l:list a)
= match l with
| [] -> pairwise_or'_nil f
| hd::tl -> pairwise_or'_cons f hd tl
let rec pairwise_or'_exists (#a:Type) (f: a -> a -> Type) (l:list a)
= match l with
| [] -> pairwise_or'_nil f
| hd::tl ->
pairwise_or'_cons f hd tl;
pairwise_or'_exists f tl;
big_or'_exists (f hd) tl | false | false | FStar.BigOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pairwise_or'_exists_no_repeats (#a: Type) (f: (a -> a -> Type)) (l: list a)
: Lemma (requires symmetric f /\ L.no_repeats_p l)
(ensures (pairwise_or' f l <==> (exists x y. L.memP x l /\ L.memP y l /\ x =!= y /\ f x y))) | [
"recursion"
] | FStar.BigOps.pairwise_or'_exists_no_repeats | {
"file_name": "ulib/FStar.BigOps.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: a -> _: a -> Type0) -> l: Prims.list a
-> FStar.Pervasives.Lemma
(requires FStar.BigOps.symmetric f /\ FStar.List.Tot.Base.no_repeats_p l)
(ensures
FStar.BigOps.pairwise_or' f l <==>
(exists (x: a) (y: a).
FStar.List.Tot.Base.memP x l /\ FStar.List.Tot.Base.memP y l /\ ~(x == y) /\ f x y)) | {
"end_col": 30,
"end_line": 132,
"start_col": 4,
"start_line": 127
} |
FStar.Pervasives.Lemma | val pairwise_or'_cons (#a: Type) (f: (a -> a -> Type0)) (hd: a) (tl: list a)
: Lemma (pairwise_or' f (hd :: tl) == (big_or' (f hd) tl \/ pairwise_or' f tl)) | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pairwise_or'_cons (#a:Type) (f:a -> a -> Type) (hd:a) (tl:list a)
= assert (pairwise_or' f (hd::tl) == (big_or' (f hd) tl \/ pairwise_or' f tl)) | val pairwise_or'_cons (#a: Type) (f: (a -> a -> Type0)) (hd: a) (tl: list a)
: Lemma (pairwise_or' f (hd :: tl) == (big_or' (f hd) tl \/ pairwise_or' f tl))
let pairwise_or'_cons (#a: Type) (f: (a -> a -> Type)) (hd: a) (tl: list a) = | false | null | true | assert (pairwise_or' f (hd :: tl) == (big_or' (f hd) tl \/ pairwise_or' f tl)) | {
"checked_file": "FStar.BigOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.BigOps.fst"
} | [
"lemma"
] | [
"Prims.list",
"Prims._assert",
"Prims.eq2",
"FStar.BigOps.pairwise_or'",
"Prims.Cons",
"Prims.l_or",
"FStar.BigOps.big_or'",
"Prims.unit"
] | [] | (*
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.BigOps
module T = FStar.Tactics.V2
let normal_eq (#a:Type) (f:a)
= ()
////////////////////////////////////////////////////////////////////////////////
let map_op'_nil
(#a:Type) (#b:Type) (#c:Type)
(op:b -> c -> GTot c) (f:a -> GTot b) (z:c)
: Lemma (map_op' op f [] z == z)
= ()
let map_op'_cons #a #b #c (op:b -> c -> GTot c) (f:a -> GTot b) (hd:a) (tl:list a) (z:c)
: Lemma (map_op' op f (hd::tl) z == f hd `op` map_op' op f tl z)
= ()
////////////////////////////////////////////////////////////////////////////////
let big_and'_nil (#a:Type) (f:a -> Type)
= assert (big_and' f [] == True) by (T.compute())
let big_and'_cons (#a:Type) (f:a -> Type) (hd:a) (tl:list a)
= assert (big_and' f (hd :: tl) == (f hd /\ big_and' f tl)) by (T.compute())
let big_and'_prop (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_and'_nil f
| hd::tl -> big_and'_cons f hd tl
let rec big_and'_forall (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_and'_nil f; ()
| hd::tl -> big_and'_cons f hd tl; big_and'_forall f tl
////////////////////////////////////////////////////////////////////////////////
let big_or'_nil (#a:Type) (f:a -> Type)
= assert (big_or' f [] == False) by (T.compute())
let big_or'_cons (#a:Type) (f:a -> Type) (hd:a) (tl:list a)
= assert (big_or' f (hd :: tl) == (f hd \/ big_or' f tl)) by (T.compute())
let big_or'_prop (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_or'_nil f
| hd::tl -> big_or'_cons f hd tl
let rec big_or'_exists (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_or'_nil f; ()
| hd::tl -> big_or'_cons f hd tl; big_or'_exists f tl
////////////////////////////////////////////////////////////////////////////////
let pairwise_and'_nil (#a:Type) (f:a -> a -> Type0)
= assert (pairwise_and' f [] == True) by (T.compute())
let pairwise_and'_cons (#a:Type) (f:a -> a -> Type) (hd:a) (tl:list a)
= assert (pairwise_and' f (hd::tl) == (big_and' (f hd) tl /\ pairwise_and' f tl))
by (T.trefl())
let pairwise_and'_prop (#a:Type) (f:a -> a -> Type) (l:list a)
= match l with
| [] -> pairwise_and'_nil f
| hd::tl -> pairwise_and'_cons f hd tl
(* Note, this is good example of where the difference between
the implicitly and explicitly reducing variants of the definitions
makes a difference.
Proving this lemma directly on the `pairwise_and` is much harder
since one has to reason about many partially reduced forms.
Instead, we first prove the lemma on the non-reducing primed
version of the definition, and then obtain the lemma we want
at the end using `normal_eq` *)
let rec pairwise_and'_forall (#a:Type) (f: a -> a -> Type) (l:list a)
= match l with
| [] -> pairwise_and'_nil f
| hd::tl ->
pairwise_and'_cons f hd tl;
pairwise_and'_forall f tl;
big_and'_forall (f hd) tl
let rec pairwise_and'_forall_no_repeats (#a:Type) (f: a -> a -> Type) (l:list a)
= match l with
| [] -> pairwise_and'_nil f
| hd::tl ->
pairwise_and'_cons f hd tl;
pairwise_and'_forall_no_repeats f tl;
big_and'_forall (f hd) tl
////////////////////////////////////////////////////////////////////////////////
let pairwise_or'_nil (#a:Type) (f:a -> a -> Type0)
= assert (pairwise_or' f [] == False) by (T.compute()) | false | false | FStar.BigOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pairwise_or'_cons (#a: Type) (f: (a -> a -> Type0)) (hd: a) (tl: list a)
: Lemma (pairwise_or' f (hd :: tl) == (big_or' (f hd) tl \/ pairwise_or' f tl)) | [] | FStar.BigOps.pairwise_or'_cons | {
"file_name": "ulib/FStar.BigOps.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: a -> _: a -> Type0) -> hd: a -> tl: Prims.list a
-> FStar.Pervasives.Lemma
(ensures
FStar.BigOps.pairwise_or' f (hd :: tl) ==
(FStar.BigOps.big_or' (f hd) tl \/ FStar.BigOps.pairwise_or' f tl)) | {
"end_col": 80,
"end_line": 111,
"start_col": 4,
"start_line": 111
} |
FStar.Pervasives.Lemma | val pairwise_and'_forall (#a: Type) (f: (a -> a -> Type)) (l: list a)
: Lemma (requires symmetric f /\ reflexive f)
(ensures (pairwise_and' f l <==> (forall x y. L.memP x l /\ L.memP y l ==> f x y))) | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec pairwise_and'_forall (#a:Type) (f: a -> a -> Type) (l:list a)
= match l with
| [] -> pairwise_and'_nil f
| hd::tl ->
pairwise_and'_cons f hd tl;
pairwise_and'_forall f tl;
big_and'_forall (f hd) tl | val pairwise_and'_forall (#a: Type) (f: (a -> a -> Type)) (l: list a)
: Lemma (requires symmetric f /\ reflexive f)
(ensures (pairwise_and' f l <==> (forall x y. L.memP x l /\ L.memP y l ==> f x y)))
let rec pairwise_and'_forall (#a: Type) (f: (a -> a -> Type)) (l: list a) = | false | null | true | match l with
| [] -> pairwise_and'_nil f
| hd :: tl ->
pairwise_and'_cons f hd tl;
pairwise_and'_forall f tl;
big_and'_forall (f hd) tl | {
"checked_file": "FStar.BigOps.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.BigOps.fst"
} | [
"lemma"
] | [
"Prims.list",
"FStar.BigOps.pairwise_and'_nil",
"FStar.BigOps.big_and'_forall",
"Prims.unit",
"FStar.BigOps.pairwise_and'_forall",
"FStar.BigOps.pairwise_and'_cons"
] | [] | (*
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.BigOps
module T = FStar.Tactics.V2
let normal_eq (#a:Type) (f:a)
= ()
////////////////////////////////////////////////////////////////////////////////
let map_op'_nil
(#a:Type) (#b:Type) (#c:Type)
(op:b -> c -> GTot c) (f:a -> GTot b) (z:c)
: Lemma (map_op' op f [] z == z)
= ()
let map_op'_cons #a #b #c (op:b -> c -> GTot c) (f:a -> GTot b) (hd:a) (tl:list a) (z:c)
: Lemma (map_op' op f (hd::tl) z == f hd `op` map_op' op f tl z)
= ()
////////////////////////////////////////////////////////////////////////////////
let big_and'_nil (#a:Type) (f:a -> Type)
= assert (big_and' f [] == True) by (T.compute())
let big_and'_cons (#a:Type) (f:a -> Type) (hd:a) (tl:list a)
= assert (big_and' f (hd :: tl) == (f hd /\ big_and' f tl)) by (T.compute())
let big_and'_prop (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_and'_nil f
| hd::tl -> big_and'_cons f hd tl
let rec big_and'_forall (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_and'_nil f; ()
| hd::tl -> big_and'_cons f hd tl; big_and'_forall f tl
////////////////////////////////////////////////////////////////////////////////
let big_or'_nil (#a:Type) (f:a -> Type)
= assert (big_or' f [] == False) by (T.compute())
let big_or'_cons (#a:Type) (f:a -> Type) (hd:a) (tl:list a)
= assert (big_or' f (hd :: tl) == (f hd \/ big_or' f tl)) by (T.compute())
let big_or'_prop (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_or'_nil f
| hd::tl -> big_or'_cons f hd tl
let rec big_or'_exists (#a:Type) (f:a -> Type) (l:list a)
= match l with
| [] -> big_or'_nil f; ()
| hd::tl -> big_or'_cons f hd tl; big_or'_exists f tl
////////////////////////////////////////////////////////////////////////////////
let pairwise_and'_nil (#a:Type) (f:a -> a -> Type0)
= assert (pairwise_and' f [] == True) by (T.compute())
let pairwise_and'_cons (#a:Type) (f:a -> a -> Type) (hd:a) (tl:list a)
= assert (pairwise_and' f (hd::tl) == (big_and' (f hd) tl /\ pairwise_and' f tl))
by (T.trefl())
let pairwise_and'_prop (#a:Type) (f:a -> a -> Type) (l:list a)
= match l with
| [] -> pairwise_and'_nil f
| hd::tl -> pairwise_and'_cons f hd tl
(* Note, this is good example of where the difference between
the implicitly and explicitly reducing variants of the definitions
makes a difference.
Proving this lemma directly on the `pairwise_and` is much harder
since one has to reason about many partially reduced forms.
Instead, we first prove the lemma on the non-reducing primed
version of the definition, and then obtain the lemma we want
at the end using `normal_eq` *) | false | false | FStar.BigOps.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pairwise_and'_forall (#a: Type) (f: (a -> a -> Type)) (l: list a)
: Lemma (requires symmetric f /\ reflexive f)
(ensures (pairwise_and' f l <==> (forall x y. L.memP x l /\ L.memP y l ==> f x y))) | [
"recursion"
] | FStar.BigOps.pairwise_and'_forall | {
"file_name": "ulib/FStar.BigOps.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: a -> _: a -> Type0) -> l: Prims.list a
-> FStar.Pervasives.Lemma (requires FStar.BigOps.symmetric f /\ FStar.BigOps.reflexive f)
(ensures
FStar.BigOps.pairwise_and' f l <==>
(forall (x: a) (y: a).
FStar.List.Tot.Base.memP x l /\ FStar.List.Tot.Base.memP y l ==> f x y)) | {
"end_col": 31,
"end_line": 96,
"start_col": 4,
"start_line": 91
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let qelem4 = uint64 & uint64 & uint64 & uint64 | let qelem4 = | false | null | false | uint64 & uint64 & uint64 & uint64 | {
"checked_file": "Hacl.Spec.K256.Scalar.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.fst"
} | [
"total"
] | [
"FStar.Pervasives.Native.tuple4",
"Lib.IntTypes.uint64"
] | [] | module Hacl.Spec.K256.Scalar
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module BSeq = Lib.ByteSequence
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
module S = Spec.K256
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0" | false | true | Hacl.Spec.K256.Scalar.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val qelem4 : Type0 | [] | Hacl.Spec.K256.Scalar.qelem4 | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 46,
"end_line": 17,
"start_col": 13,
"start_line": 17
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_qelem_lt_pow2_128_vartime4 ((a0,a1,a2,a3): qelem4) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 a2 =. 0uL && u64_to_UInt64 a3 =. 0uL | let is_qelem_lt_pow2_128_vartime4 (a0, a1, a2, a3: qelem4) : bool = | false | null | false | let open Lib.RawIntTypes in u64_to_UInt64 a2 =. 0uL && u64_to_UInt64 a3 =. 0uL | {
"checked_file": "Hacl.Spec.K256.Scalar.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.fst"
} | [
"total"
] | [
"Hacl.Spec.K256.Scalar.qelem4",
"Lib.IntTypes.uint64",
"Prims.op_AmpAmp",
"Lib.IntTypes.op_Equals_Dot",
"Lib.IntTypes.U64",
"Lib.RawIntTypes.u64_to_UInt64",
"FStar.UInt64.__uint_to_t",
"Prims.bool"
] | [] | module Hacl.Spec.K256.Scalar
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module BSeq = Lib.ByteSequence
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
module S = Spec.K256
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let qelem4 = uint64 & uint64 & uint64 & uint64
inline_for_extraction noextract
let qelem_lseq = lseq uint64 4
noextract
let qas_nat4 (f:qelem4) =
let (f0, f1, f2, f3) = f in
v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192
inline_for_extraction noextract
val make_pow2_256_minus_order_k256: unit -> Pure qelem4
(requires True)
(ensures fun r -> qas_nat4 r = pow2 256 - S.q)
let make_pow2_256_minus_order_k256 () =
[@inline_let]
let r =
(u64 0x402da1732fc9bebf,
u64 0x4551231950b75fc4,
u64 0x1,
u64 0x0) in
assert_norm (qas_nat4 r = pow2 256 - S.q);
r
inline_for_extraction noextract
let is_qelem_zero_vartime4 ((f0,f1,f2,f3): qelem4) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 =. 0uL &&
u64_to_UInt64 f1 =. 0uL &&
u64_to_UInt64 f2 =. 0uL &&
u64_to_UInt64 f3 =. 0uL
inline_for_extraction noextract
let is_qelem_lt_q_vartime4 ((a0,a1,a2,a3): qelem4) : bool =
let open Lib.RawIntTypes in
if u64_to_UInt64 a3 <. 0xffffffffffffffffuL then true
else begin
if u64_to_UInt64 a2 <. 0xfffffffffffffffeuL then true
else begin
if u64_to_UInt64 a2 >. 0xfffffffffffffffeuL then false
else begin
if u64_to_UInt64 a1 <. 0xbaaedce6af48a03buL then true
else begin
if u64_to_UInt64 a1 >. 0xbaaedce6af48a03buL then false
else u64_to_UInt64 a0 <. 0xbfd25e8cd0364141uL
end
end
end
end
inline_for_extraction noextract
let is_qelem_le_q_halved_vartime4 ((a0,a1,a2,a3): qelem4) : bool =
let open Lib.RawIntTypes in
if u64_to_UInt64 a3 <. 0x7fffffffffffffffuL then true
else begin
if u64_to_UInt64 a3 >. 0x7fffffffffffffffuL then false
else begin
if u64_to_UInt64 a2 <. 0xffffffffffffffffuL then true
else begin
if u64_to_UInt64 a2 >. 0xffffffffffffffffuL then false
else begin
if u64_to_UInt64 a1 <. 0x5d576e7357a4501duL then true
else begin
if u64_to_UInt64 a1 >. 0x5d576e7357a4501duL then false
else u64_to_UInt64 a0 <=. 0xdfe92f46681b20a0uL
end
end
end
end
end
inline_for_extraction noextract
let is_qelem_eq_vartime4 ((a0,a1,a2,a3): qelem4) ((b0,b1,b2,b3): qelem4) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 a0 =. u64_to_UInt64 b0 &&
u64_to_UInt64 a1 =. u64_to_UInt64 b1 &&
u64_to_UInt64 a2 =. u64_to_UInt64 b2 &&
u64_to_UInt64 a3 =. u64_to_UInt64 b3
inline_for_extraction noextract | false | true | Hacl.Spec.K256.Scalar.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_qelem_lt_pow2_128_vartime4 : _: Hacl.Spec.K256.Scalar.qelem4 -> Prims.bool | [] | Hacl.Spec.K256.Scalar.is_qelem_lt_pow2_128_vartime4 | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Hacl.Spec.K256.Scalar.qelem4 -> Prims.bool | {
"end_col": 52,
"end_line": 106,
"start_col": 2,
"start_line": 105
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let qas_nat4 (f:qelem4) =
let (f0, f1, f2, f3) = f in
v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 | let qas_nat4 (f: qelem4) = | false | null | false | let f0, f1, f2, f3 = f in
v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 | {
"checked_file": "Hacl.Spec.K256.Scalar.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.fst"
} | [
"total"
] | [
"Hacl.Spec.K256.Scalar.qelem4",
"Lib.IntTypes.uint64",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.Mul.op_Star",
"Prims.pow2",
"Prims.int"
] | [] | module Hacl.Spec.K256.Scalar
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module BSeq = Lib.ByteSequence
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
module S = Spec.K256
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let qelem4 = uint64 & uint64 & uint64 & uint64
inline_for_extraction noextract
let qelem_lseq = lseq uint64 4 | false | true | Hacl.Spec.K256.Scalar.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val qas_nat4 : f: Hacl.Spec.K256.Scalar.qelem4 -> Prims.int | [] | Hacl.Spec.K256.Scalar.qas_nat4 | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f: Hacl.Spec.K256.Scalar.qelem4 -> Prims.int | {
"end_col": 59,
"end_line": 24,
"start_col": 25,
"start_line": 22
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_qelem_zero_vartime4 ((f0,f1,f2,f3): qelem4) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 =. 0uL &&
u64_to_UInt64 f1 =. 0uL &&
u64_to_UInt64 f2 =. 0uL &&
u64_to_UInt64 f3 =. 0uL | let is_qelem_zero_vartime4 (f0, f1, f2, f3: qelem4) : bool = | false | null | false | let open Lib.RawIntTypes in
u64_to_UInt64 f0 =. 0uL && u64_to_UInt64 f1 =. 0uL && u64_to_UInt64 f2 =. 0uL &&
u64_to_UInt64 f3 =. 0uL | {
"checked_file": "Hacl.Spec.K256.Scalar.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.fst"
} | [
"total"
] | [
"Hacl.Spec.K256.Scalar.qelem4",
"Lib.IntTypes.uint64",
"Prims.op_AmpAmp",
"Lib.IntTypes.op_Equals_Dot",
"Lib.IntTypes.U64",
"Lib.RawIntTypes.u64_to_UInt64",
"FStar.UInt64.__uint_to_t",
"Prims.bool"
] | [] | module Hacl.Spec.K256.Scalar
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module BSeq = Lib.ByteSequence
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
module S = Spec.K256
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let qelem4 = uint64 & uint64 & uint64 & uint64
inline_for_extraction noextract
let qelem_lseq = lseq uint64 4
noextract
let qas_nat4 (f:qelem4) =
let (f0, f1, f2, f3) = f in
v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192
inline_for_extraction noextract
val make_pow2_256_minus_order_k256: unit -> Pure qelem4
(requires True)
(ensures fun r -> qas_nat4 r = pow2 256 - S.q)
let make_pow2_256_minus_order_k256 () =
[@inline_let]
let r =
(u64 0x402da1732fc9bebf,
u64 0x4551231950b75fc4,
u64 0x1,
u64 0x0) in
assert_norm (qas_nat4 r = pow2 256 - S.q);
r
inline_for_extraction noextract | false | true | Hacl.Spec.K256.Scalar.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_qelem_zero_vartime4 : _: Hacl.Spec.K256.Scalar.qelem4 -> Prims.bool | [] | Hacl.Spec.K256.Scalar.is_qelem_zero_vartime4 | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Hacl.Spec.K256.Scalar.qelem4 -> Prims.bool | {
"end_col": 25,
"end_line": 50,
"start_col": 2,
"start_line": 46
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_qelem_eq_vartime4 ((a0,a1,a2,a3): qelem4) ((b0,b1,b2,b3): qelem4) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 a0 =. u64_to_UInt64 b0 &&
u64_to_UInt64 a1 =. u64_to_UInt64 b1 &&
u64_to_UInt64 a2 =. u64_to_UInt64 b2 &&
u64_to_UInt64 a3 =. u64_to_UInt64 b3 | let is_qelem_eq_vartime4 (a0, a1, a2, a3: qelem4) (b0, b1, b2, b3: qelem4) : bool = | false | null | false | let open Lib.RawIntTypes in
u64_to_UInt64 a0 =. u64_to_UInt64 b0 && u64_to_UInt64 a1 =. u64_to_UInt64 b1 &&
u64_to_UInt64 a2 =. u64_to_UInt64 b2 &&
u64_to_UInt64 a3 =. u64_to_UInt64 b3 | {
"checked_file": "Hacl.Spec.K256.Scalar.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.fst"
} | [
"total"
] | [
"Hacl.Spec.K256.Scalar.qelem4",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.tuple4",
"Lib.IntTypes.uint64",
"Prims.op_AmpAmp",
"Lib.IntTypes.op_Equals_Dot",
"Lib.IntTypes.U64",
"Lib.RawIntTypes.u64_to_UInt64",
"Prims.bool"
] | [] | module Hacl.Spec.K256.Scalar
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module BSeq = Lib.ByteSequence
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
module S = Spec.K256
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let qelem4 = uint64 & uint64 & uint64 & uint64
inline_for_extraction noextract
let qelem_lseq = lseq uint64 4
noextract
let qas_nat4 (f:qelem4) =
let (f0, f1, f2, f3) = f in
v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192
inline_for_extraction noextract
val make_pow2_256_minus_order_k256: unit -> Pure qelem4
(requires True)
(ensures fun r -> qas_nat4 r = pow2 256 - S.q)
let make_pow2_256_minus_order_k256 () =
[@inline_let]
let r =
(u64 0x402da1732fc9bebf,
u64 0x4551231950b75fc4,
u64 0x1,
u64 0x0) in
assert_norm (qas_nat4 r = pow2 256 - S.q);
r
inline_for_extraction noextract
let is_qelem_zero_vartime4 ((f0,f1,f2,f3): qelem4) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 =. 0uL &&
u64_to_UInt64 f1 =. 0uL &&
u64_to_UInt64 f2 =. 0uL &&
u64_to_UInt64 f3 =. 0uL
inline_for_extraction noextract
let is_qelem_lt_q_vartime4 ((a0,a1,a2,a3): qelem4) : bool =
let open Lib.RawIntTypes in
if u64_to_UInt64 a3 <. 0xffffffffffffffffuL then true
else begin
if u64_to_UInt64 a2 <. 0xfffffffffffffffeuL then true
else begin
if u64_to_UInt64 a2 >. 0xfffffffffffffffeuL then false
else begin
if u64_to_UInt64 a1 <. 0xbaaedce6af48a03buL then true
else begin
if u64_to_UInt64 a1 >. 0xbaaedce6af48a03buL then false
else u64_to_UInt64 a0 <. 0xbfd25e8cd0364141uL
end
end
end
end
inline_for_extraction noextract
let is_qelem_le_q_halved_vartime4 ((a0,a1,a2,a3): qelem4) : bool =
let open Lib.RawIntTypes in
if u64_to_UInt64 a3 <. 0x7fffffffffffffffuL then true
else begin
if u64_to_UInt64 a3 >. 0x7fffffffffffffffuL then false
else begin
if u64_to_UInt64 a2 <. 0xffffffffffffffffuL then true
else begin
if u64_to_UInt64 a2 >. 0xffffffffffffffffuL then false
else begin
if u64_to_UInt64 a1 <. 0x5d576e7357a4501duL then true
else begin
if u64_to_UInt64 a1 >. 0x5d576e7357a4501duL then false
else u64_to_UInt64 a0 <=. 0xdfe92f46681b20a0uL
end
end
end
end
end
inline_for_extraction noextract | false | true | Hacl.Spec.K256.Scalar.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_qelem_eq_vartime4 : _: Hacl.Spec.K256.Scalar.qelem4 -> _: Hacl.Spec.K256.Scalar.qelem4 -> Prims.bool | [] | Hacl.Spec.K256.Scalar.is_qelem_eq_vartime4 | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Hacl.Spec.K256.Scalar.qelem4 -> _: Hacl.Spec.K256.Scalar.qelem4 -> Prims.bool | {
"end_col": 38,
"end_line": 100,
"start_col": 2,
"start_line": 96
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_qelem_le_q_halved_vartime4 ((a0,a1,a2,a3): qelem4) : bool =
let open Lib.RawIntTypes in
if u64_to_UInt64 a3 <. 0x7fffffffffffffffuL then true
else begin
if u64_to_UInt64 a3 >. 0x7fffffffffffffffuL then false
else begin
if u64_to_UInt64 a2 <. 0xffffffffffffffffuL then true
else begin
if u64_to_UInt64 a2 >. 0xffffffffffffffffuL then false
else begin
if u64_to_UInt64 a1 <. 0x5d576e7357a4501duL then true
else begin
if u64_to_UInt64 a1 >. 0x5d576e7357a4501duL then false
else u64_to_UInt64 a0 <=. 0xdfe92f46681b20a0uL
end
end
end
end
end | let is_qelem_le_q_halved_vartime4 (a0, a1, a2, a3: qelem4) : bool = | false | null | false | let open Lib.RawIntTypes in
if u64_to_UInt64 a3 <. 0x7fffffffffffffffuL
then true
else
if u64_to_UInt64 a3 >. 0x7fffffffffffffffuL
then false
else
if u64_to_UInt64 a2 <. 0xffffffffffffffffuL
then true
else
if u64_to_UInt64 a2 >. 0xffffffffffffffffuL
then false
else
if u64_to_UInt64 a1 <. 0x5d576e7357a4501duL
then true
else
if u64_to_UInt64 a1 >. 0x5d576e7357a4501duL
then false
else u64_to_UInt64 a0 <=. 0xdfe92f46681b20a0uL | {
"checked_file": "Hacl.Spec.K256.Scalar.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.fst"
} | [
"total"
] | [
"Hacl.Spec.K256.Scalar.qelem4",
"Lib.IntTypes.uint64",
"Lib.IntTypes.op_Less_Dot",
"Lib.IntTypes.U64",
"Lib.RawIntTypes.u64_to_UInt64",
"FStar.UInt64.__uint_to_t",
"Prims.bool",
"Lib.IntTypes.op_Greater_Dot",
"Lib.IntTypes.op_Less_Equals_Dot"
] | [] | module Hacl.Spec.K256.Scalar
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module BSeq = Lib.ByteSequence
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
module S = Spec.K256
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let qelem4 = uint64 & uint64 & uint64 & uint64
inline_for_extraction noextract
let qelem_lseq = lseq uint64 4
noextract
let qas_nat4 (f:qelem4) =
let (f0, f1, f2, f3) = f in
v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192
inline_for_extraction noextract
val make_pow2_256_minus_order_k256: unit -> Pure qelem4
(requires True)
(ensures fun r -> qas_nat4 r = pow2 256 - S.q)
let make_pow2_256_minus_order_k256 () =
[@inline_let]
let r =
(u64 0x402da1732fc9bebf,
u64 0x4551231950b75fc4,
u64 0x1,
u64 0x0) in
assert_norm (qas_nat4 r = pow2 256 - S.q);
r
inline_for_extraction noextract
let is_qelem_zero_vartime4 ((f0,f1,f2,f3): qelem4) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 =. 0uL &&
u64_to_UInt64 f1 =. 0uL &&
u64_to_UInt64 f2 =. 0uL &&
u64_to_UInt64 f3 =. 0uL
inline_for_extraction noextract
let is_qelem_lt_q_vartime4 ((a0,a1,a2,a3): qelem4) : bool =
let open Lib.RawIntTypes in
if u64_to_UInt64 a3 <. 0xffffffffffffffffuL then true
else begin
if u64_to_UInt64 a2 <. 0xfffffffffffffffeuL then true
else begin
if u64_to_UInt64 a2 >. 0xfffffffffffffffeuL then false
else begin
if u64_to_UInt64 a1 <. 0xbaaedce6af48a03buL then true
else begin
if u64_to_UInt64 a1 >. 0xbaaedce6af48a03buL then false
else u64_to_UInt64 a0 <. 0xbfd25e8cd0364141uL
end
end
end
end
inline_for_extraction noextract | false | true | Hacl.Spec.K256.Scalar.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_qelem_le_q_halved_vartime4 : _: Hacl.Spec.K256.Scalar.qelem4 -> Prims.bool | [] | Hacl.Spec.K256.Scalar.is_qelem_le_q_halved_vartime4 | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Hacl.Spec.K256.Scalar.qelem4 -> Prims.bool | {
"end_col": 5,
"end_line": 91,
"start_col": 2,
"start_line": 74
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_qelem_lt_q_vartime4 ((a0,a1,a2,a3): qelem4) : bool =
let open Lib.RawIntTypes in
if u64_to_UInt64 a3 <. 0xffffffffffffffffuL then true
else begin
if u64_to_UInt64 a2 <. 0xfffffffffffffffeuL then true
else begin
if u64_to_UInt64 a2 >. 0xfffffffffffffffeuL then false
else begin
if u64_to_UInt64 a1 <. 0xbaaedce6af48a03buL then true
else begin
if u64_to_UInt64 a1 >. 0xbaaedce6af48a03buL then false
else u64_to_UInt64 a0 <. 0xbfd25e8cd0364141uL
end
end
end
end | let is_qelem_lt_q_vartime4 (a0, a1, a2, a3: qelem4) : bool = | false | null | false | let open Lib.RawIntTypes in
if u64_to_UInt64 a3 <. 0xffffffffffffffffuL
then true
else
if u64_to_UInt64 a2 <. 0xfffffffffffffffeuL
then true
else
if u64_to_UInt64 a2 >. 0xfffffffffffffffeuL
then false
else
if u64_to_UInt64 a1 <. 0xbaaedce6af48a03buL
then true
else
if u64_to_UInt64 a1 >. 0xbaaedce6af48a03buL
then false
else u64_to_UInt64 a0 <. 0xbfd25e8cd0364141uL | {
"checked_file": "Hacl.Spec.K256.Scalar.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.fst"
} | [
"total"
] | [
"Hacl.Spec.K256.Scalar.qelem4",
"Lib.IntTypes.uint64",
"Lib.IntTypes.op_Less_Dot",
"Lib.IntTypes.U64",
"Lib.RawIntTypes.u64_to_UInt64",
"FStar.UInt64.__uint_to_t",
"Prims.bool",
"Lib.IntTypes.op_Greater_Dot"
] | [] | module Hacl.Spec.K256.Scalar
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module BSeq = Lib.ByteSequence
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
module S = Spec.K256
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let qelem4 = uint64 & uint64 & uint64 & uint64
inline_for_extraction noextract
let qelem_lseq = lseq uint64 4
noextract
let qas_nat4 (f:qelem4) =
let (f0, f1, f2, f3) = f in
v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192
inline_for_extraction noextract
val make_pow2_256_minus_order_k256: unit -> Pure qelem4
(requires True)
(ensures fun r -> qas_nat4 r = pow2 256 - S.q)
let make_pow2_256_minus_order_k256 () =
[@inline_let]
let r =
(u64 0x402da1732fc9bebf,
u64 0x4551231950b75fc4,
u64 0x1,
u64 0x0) in
assert_norm (qas_nat4 r = pow2 256 - S.q);
r
inline_for_extraction noextract
let is_qelem_zero_vartime4 ((f0,f1,f2,f3): qelem4) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 =. 0uL &&
u64_to_UInt64 f1 =. 0uL &&
u64_to_UInt64 f2 =. 0uL &&
u64_to_UInt64 f3 =. 0uL
inline_for_extraction noextract | false | true | Hacl.Spec.K256.Scalar.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_qelem_lt_q_vartime4 : _: Hacl.Spec.K256.Scalar.qelem4 -> Prims.bool | [] | Hacl.Spec.K256.Scalar.is_qelem_lt_q_vartime4 | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Hacl.Spec.K256.Scalar.qelem4 -> Prims.bool | {
"end_col": 5,
"end_line": 69,
"start_col": 2,
"start_line": 55
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let qelem_lseq = lseq uint64 4 | let qelem_lseq = | false | null | false | lseq uint64 4 | {
"checked_file": "Hacl.Spec.K256.Scalar.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.fst"
} | [
"total"
] | [
"Lib.Sequence.lseq",
"Lib.IntTypes.uint64"
] | [] | module Hacl.Spec.K256.Scalar
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module BSeq = Lib.ByteSequence
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
module S = Spec.K256
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let qelem4 = uint64 & uint64 & uint64 & uint64 | false | true | Hacl.Spec.K256.Scalar.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val qelem_lseq : Type0 | [] | Hacl.Spec.K256.Scalar.qelem_lseq | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 30,
"end_line": 19,
"start_col": 17,
"start_line": 19
} |
|
Prims.Tot | val mod_short_lseq: a:qelem_lseq -> qelem_lseq | [
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mod_short_lseq a =
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
let tmp = create4 t0 t1 t2 t3 in
let c, out = SB.bn_add a tmp in
let mask = u64 0 -. c in
map2 (BB.mask_select mask) out a | val mod_short_lseq: a:qelem_lseq -> qelem_lseq
let mod_short_lseq a = | false | null | false | let t0, t1, t2, t3 = make_pow2_256_minus_order_k256 () in
let tmp = create4 t0 t1 t2 t3 in
let c, out = SB.bn_add a tmp in
let mask = u64 0 -. c in
map2 (BB.mask_select mask) out a | {
"checked_file": "Hacl.Spec.K256.Scalar.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.fst"
} | [
"total"
] | [
"Hacl.Spec.K256.Scalar.qelem_lseq",
"Lib.IntTypes.uint64",
"Hacl.Spec.Bignum.Base.carry",
"Lib.IntTypes.U64",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Lib.Sequence.map2",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.Base.mask_select",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Subtraction_Dot",
"Lib.IntTypes.u64",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.Bignum.bn_add",
"Lib.Sequence.lseq",
"Lib.Sequence.create4",
"Hacl.Spec.K256.Scalar.qelem4",
"Hacl.Spec.K256.Scalar.make_pow2_256_minus_order_k256"
] | [] | module Hacl.Spec.K256.Scalar
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module BSeq = Lib.ByteSequence
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
module S = Spec.K256
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let qelem4 = uint64 & uint64 & uint64 & uint64
inline_for_extraction noextract
let qelem_lseq = lseq uint64 4
noextract
let qas_nat4 (f:qelem4) =
let (f0, f1, f2, f3) = f in
v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192
inline_for_extraction noextract
val make_pow2_256_minus_order_k256: unit -> Pure qelem4
(requires True)
(ensures fun r -> qas_nat4 r = pow2 256 - S.q)
let make_pow2_256_minus_order_k256 () =
[@inline_let]
let r =
(u64 0x402da1732fc9bebf,
u64 0x4551231950b75fc4,
u64 0x1,
u64 0x0) in
assert_norm (qas_nat4 r = pow2 256 - S.q);
r
inline_for_extraction noextract
let is_qelem_zero_vartime4 ((f0,f1,f2,f3): qelem4) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 =. 0uL &&
u64_to_UInt64 f1 =. 0uL &&
u64_to_UInt64 f2 =. 0uL &&
u64_to_UInt64 f3 =. 0uL
inline_for_extraction noextract
let is_qelem_lt_q_vartime4 ((a0,a1,a2,a3): qelem4) : bool =
let open Lib.RawIntTypes in
if u64_to_UInt64 a3 <. 0xffffffffffffffffuL then true
else begin
if u64_to_UInt64 a2 <. 0xfffffffffffffffeuL then true
else begin
if u64_to_UInt64 a2 >. 0xfffffffffffffffeuL then false
else begin
if u64_to_UInt64 a1 <. 0xbaaedce6af48a03buL then true
else begin
if u64_to_UInt64 a1 >. 0xbaaedce6af48a03buL then false
else u64_to_UInt64 a0 <. 0xbfd25e8cd0364141uL
end
end
end
end
inline_for_extraction noextract
let is_qelem_le_q_halved_vartime4 ((a0,a1,a2,a3): qelem4) : bool =
let open Lib.RawIntTypes in
if u64_to_UInt64 a3 <. 0x7fffffffffffffffuL then true
else begin
if u64_to_UInt64 a3 >. 0x7fffffffffffffffuL then false
else begin
if u64_to_UInt64 a2 <. 0xffffffffffffffffuL then true
else begin
if u64_to_UInt64 a2 >. 0xffffffffffffffffuL then false
else begin
if u64_to_UInt64 a1 <. 0x5d576e7357a4501duL then true
else begin
if u64_to_UInt64 a1 >. 0x5d576e7357a4501duL then false
else u64_to_UInt64 a0 <=. 0xdfe92f46681b20a0uL
end
end
end
end
end
inline_for_extraction noextract
let is_qelem_eq_vartime4 ((a0,a1,a2,a3): qelem4) ((b0,b1,b2,b3): qelem4) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 a0 =. u64_to_UInt64 b0 &&
u64_to_UInt64 a1 =. u64_to_UInt64 b1 &&
u64_to_UInt64 a2 =. u64_to_UInt64 b2 &&
u64_to_UInt64 a3 =. u64_to_UInt64 b3
inline_for_extraction noextract
let is_qelem_lt_pow2_128_vartime4 ((a0,a1,a2,a3): qelem4) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 a2 =. 0uL && u64_to_UInt64 a3 =. 0uL
noextract | false | true | Hacl.Spec.K256.Scalar.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mod_short_lseq: a:qelem_lseq -> qelem_lseq | [] | Hacl.Spec.K256.Scalar.mod_short_lseq | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Hacl.Spec.K256.Scalar.qelem_lseq -> Hacl.Spec.K256.Scalar.qelem_lseq | {
"end_col": 34,
"end_line": 117,
"start_col": 22,
"start_line": 111
} |
Prims.Pure | val make_pow2_256_minus_order_k256: unit -> Pure qelem4
(requires True)
(ensures fun r -> qas_nat4 r = pow2 256 - S.q) | [
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let make_pow2_256_minus_order_k256 () =
[@inline_let]
let r =
(u64 0x402da1732fc9bebf,
u64 0x4551231950b75fc4,
u64 0x1,
u64 0x0) in
assert_norm (qas_nat4 r = pow2 256 - S.q);
r | val make_pow2_256_minus_order_k256: unit -> Pure qelem4
(requires True)
(ensures fun r -> qas_nat4 r = pow2 256 - S.q)
let make_pow2_256_minus_order_k256 () = | false | null | false | [@@ inline_let ]let r = (u64 0x402da1732fc9bebf, u64 0x4551231950b75fc4, u64 0x1, u64 0x0) in
assert_norm (qas_nat4 r = pow2 256 - S.q);
r | {
"checked_file": "Hacl.Spec.K256.Scalar.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.fst"
} | [] | [
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Hacl.Spec.K256.Scalar.qas_nat4",
"Prims.op_Subtraction",
"Prims.pow2",
"Spec.K256.PointOps.q",
"FStar.Pervasives.Native.tuple4",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.Pervasives.Native.Mktuple4",
"Lib.IntTypes.uint64",
"Lib.IntTypes.u64",
"Hacl.Spec.K256.Scalar.qelem4"
] | [] | module Hacl.Spec.K256.Scalar
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module BSeq = Lib.ByteSequence
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
module S = Spec.K256
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let qelem4 = uint64 & uint64 & uint64 & uint64
inline_for_extraction noextract
let qelem_lseq = lseq uint64 4
noextract
let qas_nat4 (f:qelem4) =
let (f0, f1, f2, f3) = f in
v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192
inline_for_extraction noextract
val make_pow2_256_minus_order_k256: unit -> Pure qelem4
(requires True)
(ensures fun r -> qas_nat4 r = pow2 256 - S.q) | false | false | Hacl.Spec.K256.Scalar.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val make_pow2_256_minus_order_k256: unit -> Pure qelem4
(requires True)
(ensures fun r -> qas_nat4 r = pow2 256 - S.q) | [] | Hacl.Spec.K256.Scalar.make_pow2_256_minus_order_k256 | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Prims.unit -> Prims.Pure Hacl.Spec.K256.Scalar.qelem4 | {
"end_col": 3,
"end_line": 41,
"start_col": 2,
"start_line": 33
} |
Prims.Tot | val mul_pow2_256_minus_q_lseq:
len:size_nat -> resLen:size_nat{2 + len <= resLen}
-> a:lseq uint64 len -> BB.carry U64 & lseq uint64 resLen | [
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mul_pow2_256_minus_q_lseq len resLen a =
let t0 = u64 0x402da1732fc9bebf in
let t1 = u64 0x4551231950b75fc4 in
let t01 = create2 t0 t1 in
let m0 = SB.bn_mul a t01 in // a * t01
let m1 = create resLen (u64 0) in
let m1 = update_sub m1 2 len a in // a * t2 * pow2 128
SB.bn_add m1 m0 | val mul_pow2_256_minus_q_lseq:
len:size_nat -> resLen:size_nat{2 + len <= resLen}
-> a:lseq uint64 len -> BB.carry U64 & lseq uint64 resLen
let mul_pow2_256_minus_q_lseq len resLen a = | false | null | false | let t0 = u64 0x402da1732fc9bebf in
let t1 = u64 0x4551231950b75fc4 in
let t01 = create2 t0 t1 in
let m0 = SB.bn_mul a t01 in
let m1 = create resLen (u64 0) in
let m1 = update_sub m1 2 len a in
SB.bn_add m1 m0 | {
"checked_file": "Hacl.Spec.K256.Scalar.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint64",
"Hacl.Spec.Bignum.bn_add",
"Lib.IntTypes.U64",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"Prims.l_and",
"Prims.eq2",
"Lib.Sequence.sub",
"Prims.l_Forall",
"Prims.nat",
"Prims.l_or",
"Prims.op_LessThan",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.Sequence.index",
"Lib.Sequence.update_sub",
"FStar.Seq.Base.seq",
"FStar.Seq.Base.create",
"Lib.IntTypes.mk_int",
"Prims.l_imp",
"Lib.Sequence.create",
"Lib.IntTypes.u64",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Hacl.Spec.Bignum.bn_mul",
"Hacl.Spec.Bignum.Definitions.limb",
"Lib.Sequence.create2",
"Prims.int",
"Lib.IntTypes.range",
"Lib.IntTypes.v",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.Bignum.Base.carry"
] | [] | module Hacl.Spec.K256.Scalar
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module BSeq = Lib.ByteSequence
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
module S = Spec.K256
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let qelem4 = uint64 & uint64 & uint64 & uint64
inline_for_extraction noextract
let qelem_lseq = lseq uint64 4
noextract
let qas_nat4 (f:qelem4) =
let (f0, f1, f2, f3) = f in
v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192
inline_for_extraction noextract
val make_pow2_256_minus_order_k256: unit -> Pure qelem4
(requires True)
(ensures fun r -> qas_nat4 r = pow2 256 - S.q)
let make_pow2_256_minus_order_k256 () =
[@inline_let]
let r =
(u64 0x402da1732fc9bebf,
u64 0x4551231950b75fc4,
u64 0x1,
u64 0x0) in
assert_norm (qas_nat4 r = pow2 256 - S.q);
r
inline_for_extraction noextract
let is_qelem_zero_vartime4 ((f0,f1,f2,f3): qelem4) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 =. 0uL &&
u64_to_UInt64 f1 =. 0uL &&
u64_to_UInt64 f2 =. 0uL &&
u64_to_UInt64 f3 =. 0uL
inline_for_extraction noextract
let is_qelem_lt_q_vartime4 ((a0,a1,a2,a3): qelem4) : bool =
let open Lib.RawIntTypes in
if u64_to_UInt64 a3 <. 0xffffffffffffffffuL then true
else begin
if u64_to_UInt64 a2 <. 0xfffffffffffffffeuL then true
else begin
if u64_to_UInt64 a2 >. 0xfffffffffffffffeuL then false
else begin
if u64_to_UInt64 a1 <. 0xbaaedce6af48a03buL then true
else begin
if u64_to_UInt64 a1 >. 0xbaaedce6af48a03buL then false
else u64_to_UInt64 a0 <. 0xbfd25e8cd0364141uL
end
end
end
end
inline_for_extraction noextract
let is_qelem_le_q_halved_vartime4 ((a0,a1,a2,a3): qelem4) : bool =
let open Lib.RawIntTypes in
if u64_to_UInt64 a3 <. 0x7fffffffffffffffuL then true
else begin
if u64_to_UInt64 a3 >. 0x7fffffffffffffffuL then false
else begin
if u64_to_UInt64 a2 <. 0xffffffffffffffffuL then true
else begin
if u64_to_UInt64 a2 >. 0xffffffffffffffffuL then false
else begin
if u64_to_UInt64 a1 <. 0x5d576e7357a4501duL then true
else begin
if u64_to_UInt64 a1 >. 0x5d576e7357a4501duL then false
else u64_to_UInt64 a0 <=. 0xdfe92f46681b20a0uL
end
end
end
end
end
inline_for_extraction noextract
let is_qelem_eq_vartime4 ((a0,a1,a2,a3): qelem4) ((b0,b1,b2,b3): qelem4) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 a0 =. u64_to_UInt64 b0 &&
u64_to_UInt64 a1 =. u64_to_UInt64 b1 &&
u64_to_UInt64 a2 =. u64_to_UInt64 b2 &&
u64_to_UInt64 a3 =. u64_to_UInt64 b3
inline_for_extraction noextract
let is_qelem_lt_pow2_128_vartime4 ((a0,a1,a2,a3): qelem4) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 a2 =. 0uL && u64_to_UInt64 a3 =. 0uL
noextract
val mod_short_lseq: a:qelem_lseq -> qelem_lseq
let mod_short_lseq a =
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
let tmp = create4 t0 t1 t2 t3 in
let c, out = SB.bn_add a tmp in
let mask = u64 0 -. c in
map2 (BB.mask_select mask) out a
noextract
val mul_pow2_256_minus_q_lseq:
len:size_nat -> resLen:size_nat{2 + len <= resLen}
-> a:lseq uint64 len -> BB.carry U64 & lseq uint64 resLen | false | false | Hacl.Spec.K256.Scalar.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mul_pow2_256_minus_q_lseq:
len:size_nat -> resLen:size_nat{2 + len <= resLen}
-> a:lseq uint64 len -> BB.carry U64 & lseq uint64 resLen | [] | Hacl.Spec.K256.Scalar.mul_pow2_256_minus_q_lseq | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len: Lib.IntTypes.size_nat ->
resLen: Lib.IntTypes.size_nat{2 + len <= resLen} ->
a: Lib.Sequence.lseq Lib.IntTypes.uint64 len
-> Hacl.Spec.Bignum.Base.carry Lib.IntTypes.U64 * Lib.Sequence.lseq Lib.IntTypes.uint64 resLen | {
"end_col": 17,
"end_line": 133,
"start_col": 44,
"start_line": 125
} |
Prims.Tot | val qmul_shift_384 (a b: qelem_lseq) : qelem_lseq | [
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let qmul_shift_384 (a b:qelem_lseq) : qelem_lseq =
let l = SB.bn_mul a b in
let res_b = SB.bn_rshift l 6 in
let res_b_padded = create 4 (u64 0) in
let res_b_padded = update_sub res_b_padded 0 2 res_b in
let _, res1_b = SB.bn_add1 res_b_padded (u64 1) in
let flag = l.[5] >>. 63ul in
let mask = u64 0 -. flag in // mask = if flag is set then ones_v U64 else 0
map2 (BB.mask_select mask) res1_b res_b_padded | val qmul_shift_384 (a b: qelem_lseq) : qelem_lseq
let qmul_shift_384 (a b: qelem_lseq) : qelem_lseq = | false | null | false | let l = SB.bn_mul a b in
let res_b = SB.bn_rshift l 6 in
let res_b_padded = create 4 (u64 0) in
let res_b_padded = update_sub res_b_padded 0 2 res_b in
let _, res1_b = SB.bn_add1 res_b_padded (u64 1) in
let flag = l.[ 5 ] >>. 63ul in
let mask = u64 0 -. flag in
map2 (BB.mask_select mask) res1_b res_b_padded | {
"checked_file": "Hacl.Spec.K256.Scalar.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.fst"
} | [
"total"
] | [
"Hacl.Spec.K256.Scalar.qelem_lseq",
"Hacl.Spec.Bignum.Base.carry",
"Lib.IntTypes.U64",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Lib.Sequence.map2",
"Hacl.Spec.Bignum.Definitions.limb",
"Lib.IntTypes.uint64",
"Hacl.Spec.Bignum.Base.mask_select",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Subtraction_Dot",
"Lib.IntTypes.u64",
"Lib.IntTypes.op_Greater_Greater_Dot",
"Lib.Sequence.op_String_Access",
"Prims.op_Addition",
"FStar.UInt32.__uint_to_t",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.Bignum.bn_add1",
"Lib.Sequence.lseq",
"Prims.l_and",
"Prims.eq2",
"Lib.Sequence.sub",
"Prims.l_Forall",
"Prims.nat",
"Prims.l_or",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.Sequence.index",
"Lib.Sequence.update_sub",
"FStar.Seq.Base.seq",
"FStar.Seq.Base.create",
"Lib.IntTypes.mk_int",
"Prims.l_imp",
"Lib.Sequence.create",
"Prims.op_Subtraction",
"Hacl.Spec.Bignum.bn_rshift",
"Hacl.Spec.Bignum.bn_mul"
] | [] | module Hacl.Spec.K256.Scalar
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module BSeq = Lib.ByteSequence
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
module S = Spec.K256
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let qelem4 = uint64 & uint64 & uint64 & uint64
inline_for_extraction noextract
let qelem_lseq = lseq uint64 4
noextract
let qas_nat4 (f:qelem4) =
let (f0, f1, f2, f3) = f in
v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192
inline_for_extraction noextract
val make_pow2_256_minus_order_k256: unit -> Pure qelem4
(requires True)
(ensures fun r -> qas_nat4 r = pow2 256 - S.q)
let make_pow2_256_minus_order_k256 () =
[@inline_let]
let r =
(u64 0x402da1732fc9bebf,
u64 0x4551231950b75fc4,
u64 0x1,
u64 0x0) in
assert_norm (qas_nat4 r = pow2 256 - S.q);
r
inline_for_extraction noextract
let is_qelem_zero_vartime4 ((f0,f1,f2,f3): qelem4) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 =. 0uL &&
u64_to_UInt64 f1 =. 0uL &&
u64_to_UInt64 f2 =. 0uL &&
u64_to_UInt64 f3 =. 0uL
inline_for_extraction noextract
let is_qelem_lt_q_vartime4 ((a0,a1,a2,a3): qelem4) : bool =
let open Lib.RawIntTypes in
if u64_to_UInt64 a3 <. 0xffffffffffffffffuL then true
else begin
if u64_to_UInt64 a2 <. 0xfffffffffffffffeuL then true
else begin
if u64_to_UInt64 a2 >. 0xfffffffffffffffeuL then false
else begin
if u64_to_UInt64 a1 <. 0xbaaedce6af48a03buL then true
else begin
if u64_to_UInt64 a1 >. 0xbaaedce6af48a03buL then false
else u64_to_UInt64 a0 <. 0xbfd25e8cd0364141uL
end
end
end
end
inline_for_extraction noextract
let is_qelem_le_q_halved_vartime4 ((a0,a1,a2,a3): qelem4) : bool =
let open Lib.RawIntTypes in
if u64_to_UInt64 a3 <. 0x7fffffffffffffffuL then true
else begin
if u64_to_UInt64 a3 >. 0x7fffffffffffffffuL then false
else begin
if u64_to_UInt64 a2 <. 0xffffffffffffffffuL then true
else begin
if u64_to_UInt64 a2 >. 0xffffffffffffffffuL then false
else begin
if u64_to_UInt64 a1 <. 0x5d576e7357a4501duL then true
else begin
if u64_to_UInt64 a1 >. 0x5d576e7357a4501duL then false
else u64_to_UInt64 a0 <=. 0xdfe92f46681b20a0uL
end
end
end
end
end
inline_for_extraction noextract
let is_qelem_eq_vartime4 ((a0,a1,a2,a3): qelem4) ((b0,b1,b2,b3): qelem4) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 a0 =. u64_to_UInt64 b0 &&
u64_to_UInt64 a1 =. u64_to_UInt64 b1 &&
u64_to_UInt64 a2 =. u64_to_UInt64 b2 &&
u64_to_UInt64 a3 =. u64_to_UInt64 b3
inline_for_extraction noextract
let is_qelem_lt_pow2_128_vartime4 ((a0,a1,a2,a3): qelem4) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 a2 =. 0uL && u64_to_UInt64 a3 =. 0uL
noextract
val mod_short_lseq: a:qelem_lseq -> qelem_lseq
let mod_short_lseq a =
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
let tmp = create4 t0 t1 t2 t3 in
let c, out = SB.bn_add a tmp in
let mask = u64 0 -. c in
map2 (BB.mask_select mask) out a
noextract
val mul_pow2_256_minus_q_lseq:
len:size_nat -> resLen:size_nat{2 + len <= resLen}
-> a:lseq uint64 len -> BB.carry U64 & lseq uint64 resLen
let mul_pow2_256_minus_q_lseq len resLen a =
let t0 = u64 0x402da1732fc9bebf in
let t1 = u64 0x4551231950b75fc4 in
let t01 = create2 t0 t1 in
let m0 = SB.bn_mul a t01 in // a * t01
let m1 = create resLen (u64 0) in
let m1 = update_sub m1 2 len a in // a * t2 * pow2 128
SB.bn_add m1 m0 // a * SECP256K1_N_C
noextract
val mul_pow2_256_minus_q_lseq_add:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen}
-> a:lseq uint64 len -> e:lseq uint64 4 -> BB.carry U64 & lseq uint64 resLen
let mul_pow2_256_minus_q_lseq_add len resLen a e =
let _, m = mul_pow2_256_minus_q_lseq len resLen a in // a * SECP256K1_N_C
SB.bn_add m e // e + a * SECP256K1_N_C
noextract
val mod_lseq_before_final: a:lseq uint64 8 -> BB.carry U64 & qelem_lseq
let mod_lseq_before_final a =
// Reduce 512 bits into 385.
// m[0..6] = a[0..3] + a[4..7] * SECP256K1_N_C.
// Reduce 385 bits into 258.
// p[0..4] = m[0..3] + m[4..6] * SECP256K1_N_C.
// Reduce 258 bits into 256.
// c, r[0..3] = p[0..3] + p[4] * SECP256K1_N_C.
// Final reduction of r.
// secp256k1_scalar_reduce(r, c + secp256k1_scalar_check_overflow(r));
// 385 // 64 = 7
let _, m = mul_pow2_256_minus_q_lseq_add 4 7 (sub a 4 4) (sub a 0 4) in // a[0..3] + a[4..7] * SECP256K1_N_C
// 258 // 64 = 5
let _, p = mul_pow2_256_minus_q_lseq_add 3 5 (sub m 4 3) (sub m 0 4) in // m[0..3] + m[4..6] * SECP256K1_N_C
mul_pow2_256_minus_q_lseq_add 1 4 (sub p 4 1) (sub p 0 4) // p[0..3] + p[4] * SECP256K1_N_C
noextract
val mod_lseq: a:lseq uint64 8 -> qelem_lseq
let mod_lseq a =
let c0, r = mod_lseq_before_final a in
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
let tmp = create4 t0 t1 t2 t3 in
let c1, out = SB.bn_add r tmp in
let mask = u64 0 -. (c0 +. c1) in
map2 (BB.mask_select mask) out r | false | true | Hacl.Spec.K256.Scalar.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val qmul_shift_384 (a b: qelem_lseq) : qelem_lseq | [] | Hacl.Spec.K256.Scalar.qmul_shift_384 | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Hacl.Spec.K256.Scalar.qelem_lseq -> b: Hacl.Spec.K256.Scalar.qelem_lseq
-> Hacl.Spec.K256.Scalar.qelem_lseq | {
"end_col": 48,
"end_line": 191,
"start_col": 50,
"start_line": 182
} |
Prims.Tot | val mul_pow2_256_minus_q_lseq_add:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen}
-> a:lseq uint64 len -> e:lseq uint64 4 -> BB.carry U64 & lseq uint64 resLen | [
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mul_pow2_256_minus_q_lseq_add len resLen a e =
let _, m = mul_pow2_256_minus_q_lseq len resLen a in // a * SECP256K1_N_C
SB.bn_add m e | val mul_pow2_256_minus_q_lseq_add:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen}
-> a:lseq uint64 len -> e:lseq uint64 4 -> BB.carry U64 & lseq uint64 resLen
let mul_pow2_256_minus_q_lseq_add len resLen a e = | false | null | false | let _, m = mul_pow2_256_minus_q_lseq len resLen a in
SB.bn_add m e | {
"checked_file": "Hacl.Spec.K256.Scalar.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.fst"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint64",
"Hacl.Spec.Bignum.Base.carry",
"Lib.IntTypes.U64",
"Hacl.Spec.Bignum.bn_add",
"FStar.Pervasives.Native.tuple2",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"Hacl.Spec.K256.Scalar.mul_pow2_256_minus_q_lseq"
] | [] | module Hacl.Spec.K256.Scalar
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module BSeq = Lib.ByteSequence
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
module S = Spec.K256
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let qelem4 = uint64 & uint64 & uint64 & uint64
inline_for_extraction noextract
let qelem_lseq = lseq uint64 4
noextract
let qas_nat4 (f:qelem4) =
let (f0, f1, f2, f3) = f in
v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192
inline_for_extraction noextract
val make_pow2_256_minus_order_k256: unit -> Pure qelem4
(requires True)
(ensures fun r -> qas_nat4 r = pow2 256 - S.q)
let make_pow2_256_minus_order_k256 () =
[@inline_let]
let r =
(u64 0x402da1732fc9bebf,
u64 0x4551231950b75fc4,
u64 0x1,
u64 0x0) in
assert_norm (qas_nat4 r = pow2 256 - S.q);
r
inline_for_extraction noextract
let is_qelem_zero_vartime4 ((f0,f1,f2,f3): qelem4) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 =. 0uL &&
u64_to_UInt64 f1 =. 0uL &&
u64_to_UInt64 f2 =. 0uL &&
u64_to_UInt64 f3 =. 0uL
inline_for_extraction noextract
let is_qelem_lt_q_vartime4 ((a0,a1,a2,a3): qelem4) : bool =
let open Lib.RawIntTypes in
if u64_to_UInt64 a3 <. 0xffffffffffffffffuL then true
else begin
if u64_to_UInt64 a2 <. 0xfffffffffffffffeuL then true
else begin
if u64_to_UInt64 a2 >. 0xfffffffffffffffeuL then false
else begin
if u64_to_UInt64 a1 <. 0xbaaedce6af48a03buL then true
else begin
if u64_to_UInt64 a1 >. 0xbaaedce6af48a03buL then false
else u64_to_UInt64 a0 <. 0xbfd25e8cd0364141uL
end
end
end
end
inline_for_extraction noextract
let is_qelem_le_q_halved_vartime4 ((a0,a1,a2,a3): qelem4) : bool =
let open Lib.RawIntTypes in
if u64_to_UInt64 a3 <. 0x7fffffffffffffffuL then true
else begin
if u64_to_UInt64 a3 >. 0x7fffffffffffffffuL then false
else begin
if u64_to_UInt64 a2 <. 0xffffffffffffffffuL then true
else begin
if u64_to_UInt64 a2 >. 0xffffffffffffffffuL then false
else begin
if u64_to_UInt64 a1 <. 0x5d576e7357a4501duL then true
else begin
if u64_to_UInt64 a1 >. 0x5d576e7357a4501duL then false
else u64_to_UInt64 a0 <=. 0xdfe92f46681b20a0uL
end
end
end
end
end
inline_for_extraction noextract
let is_qelem_eq_vartime4 ((a0,a1,a2,a3): qelem4) ((b0,b1,b2,b3): qelem4) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 a0 =. u64_to_UInt64 b0 &&
u64_to_UInt64 a1 =. u64_to_UInt64 b1 &&
u64_to_UInt64 a2 =. u64_to_UInt64 b2 &&
u64_to_UInt64 a3 =. u64_to_UInt64 b3
inline_for_extraction noextract
let is_qelem_lt_pow2_128_vartime4 ((a0,a1,a2,a3): qelem4) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 a2 =. 0uL && u64_to_UInt64 a3 =. 0uL
noextract
val mod_short_lseq: a:qelem_lseq -> qelem_lseq
let mod_short_lseq a =
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
let tmp = create4 t0 t1 t2 t3 in
let c, out = SB.bn_add a tmp in
let mask = u64 0 -. c in
map2 (BB.mask_select mask) out a
noextract
val mul_pow2_256_minus_q_lseq:
len:size_nat -> resLen:size_nat{2 + len <= resLen}
-> a:lseq uint64 len -> BB.carry U64 & lseq uint64 resLen
let mul_pow2_256_minus_q_lseq len resLen a =
let t0 = u64 0x402da1732fc9bebf in
let t1 = u64 0x4551231950b75fc4 in
let t01 = create2 t0 t1 in
let m0 = SB.bn_mul a t01 in // a * t01
let m1 = create resLen (u64 0) in
let m1 = update_sub m1 2 len a in // a * t2 * pow2 128
SB.bn_add m1 m0 // a * SECP256K1_N_C
noextract
val mul_pow2_256_minus_q_lseq_add:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen}
-> a:lseq uint64 len -> e:lseq uint64 4 -> BB.carry U64 & lseq uint64 resLen | false | false | Hacl.Spec.K256.Scalar.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mul_pow2_256_minus_q_lseq_add:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen}
-> a:lseq uint64 len -> e:lseq uint64 4 -> BB.carry U64 & lseq uint64 resLen | [] | Hacl.Spec.K256.Scalar.mul_pow2_256_minus_q_lseq_add | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len: Lib.IntTypes.size_nat ->
resLen: Lib.IntTypes.size_nat{2 + len <= resLen /\ 4 <= resLen} ->
a: Lib.Sequence.lseq Lib.IntTypes.uint64 len ->
e: Lib.Sequence.lseq Lib.IntTypes.uint64 4
-> Hacl.Spec.Bignum.Base.carry Lib.IntTypes.U64 * Lib.Sequence.lseq Lib.IntTypes.uint64 resLen | {
"end_col": 15,
"end_line": 143,
"start_col": 50,
"start_line": 141
} |
Prims.Tot | val mod_lseq_before_final: a:lseq uint64 8 -> BB.carry U64 & qelem_lseq | [
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mod_lseq_before_final a =
// Reduce 512 bits into 385.
// m[0..6] = a[0..3] + a[4..7] * SECP256K1_N_C.
// Reduce 385 bits into 258.
// p[0..4] = m[0..3] + m[4..6] * SECP256K1_N_C.
// Reduce 258 bits into 256.
// c, r[0..3] = p[0..3] + p[4] * SECP256K1_N_C.
// Final reduction of r.
// secp256k1_scalar_reduce(r, c + secp256k1_scalar_check_overflow(r));
// 385 // 64 = 7
let _, m = mul_pow2_256_minus_q_lseq_add 4 7 (sub a 4 4) (sub a 0 4) in // a[0..3] + a[4..7] * SECP256K1_N_C
// 258 // 64 = 5
let _, p = mul_pow2_256_minus_q_lseq_add 3 5 (sub m 4 3) (sub m 0 4) in // m[0..3] + m[4..6] * SECP256K1_N_C
mul_pow2_256_minus_q_lseq_add 1 4 (sub p 4 1) (sub p 0 4) | val mod_lseq_before_final: a:lseq uint64 8 -> BB.carry U64 & qelem_lseq
let mod_lseq_before_final a = | false | null | false | let _, m = mul_pow2_256_minus_q_lseq_add 4 7 (sub a 4 4) (sub a 0 4) in
let _, p = mul_pow2_256_minus_q_lseq_add 3 5 (sub m 4 3) (sub m 0 4) in
mul_pow2_256_minus_q_lseq_add 1 4 (sub p 4 1) (sub p 0 4) | {
"checked_file": "Hacl.Spec.K256.Scalar.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.fst"
} | [
"total"
] | [
"Lib.Sequence.lseq",
"Lib.IntTypes.uint64",
"Hacl.Spec.Bignum.Base.carry",
"Lib.IntTypes.U64",
"Hacl.Spec.K256.Scalar.mul_pow2_256_minus_q_lseq_add",
"Lib.Sequence.sub",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.K256.Scalar.qelem_lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC"
] | [] | module Hacl.Spec.K256.Scalar
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module BSeq = Lib.ByteSequence
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
module S = Spec.K256
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let qelem4 = uint64 & uint64 & uint64 & uint64
inline_for_extraction noextract
let qelem_lseq = lseq uint64 4
noextract
let qas_nat4 (f:qelem4) =
let (f0, f1, f2, f3) = f in
v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192
inline_for_extraction noextract
val make_pow2_256_minus_order_k256: unit -> Pure qelem4
(requires True)
(ensures fun r -> qas_nat4 r = pow2 256 - S.q)
let make_pow2_256_minus_order_k256 () =
[@inline_let]
let r =
(u64 0x402da1732fc9bebf,
u64 0x4551231950b75fc4,
u64 0x1,
u64 0x0) in
assert_norm (qas_nat4 r = pow2 256 - S.q);
r
inline_for_extraction noextract
let is_qelem_zero_vartime4 ((f0,f1,f2,f3): qelem4) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 =. 0uL &&
u64_to_UInt64 f1 =. 0uL &&
u64_to_UInt64 f2 =. 0uL &&
u64_to_UInt64 f3 =. 0uL
inline_for_extraction noextract
let is_qelem_lt_q_vartime4 ((a0,a1,a2,a3): qelem4) : bool =
let open Lib.RawIntTypes in
if u64_to_UInt64 a3 <. 0xffffffffffffffffuL then true
else begin
if u64_to_UInt64 a2 <. 0xfffffffffffffffeuL then true
else begin
if u64_to_UInt64 a2 >. 0xfffffffffffffffeuL then false
else begin
if u64_to_UInt64 a1 <. 0xbaaedce6af48a03buL then true
else begin
if u64_to_UInt64 a1 >. 0xbaaedce6af48a03buL then false
else u64_to_UInt64 a0 <. 0xbfd25e8cd0364141uL
end
end
end
end
inline_for_extraction noextract
let is_qelem_le_q_halved_vartime4 ((a0,a1,a2,a3): qelem4) : bool =
let open Lib.RawIntTypes in
if u64_to_UInt64 a3 <. 0x7fffffffffffffffuL then true
else begin
if u64_to_UInt64 a3 >. 0x7fffffffffffffffuL then false
else begin
if u64_to_UInt64 a2 <. 0xffffffffffffffffuL then true
else begin
if u64_to_UInt64 a2 >. 0xffffffffffffffffuL then false
else begin
if u64_to_UInt64 a1 <. 0x5d576e7357a4501duL then true
else begin
if u64_to_UInt64 a1 >. 0x5d576e7357a4501duL then false
else u64_to_UInt64 a0 <=. 0xdfe92f46681b20a0uL
end
end
end
end
end
inline_for_extraction noextract
let is_qelem_eq_vartime4 ((a0,a1,a2,a3): qelem4) ((b0,b1,b2,b3): qelem4) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 a0 =. u64_to_UInt64 b0 &&
u64_to_UInt64 a1 =. u64_to_UInt64 b1 &&
u64_to_UInt64 a2 =. u64_to_UInt64 b2 &&
u64_to_UInt64 a3 =. u64_to_UInt64 b3
inline_for_extraction noextract
let is_qelem_lt_pow2_128_vartime4 ((a0,a1,a2,a3): qelem4) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 a2 =. 0uL && u64_to_UInt64 a3 =. 0uL
noextract
val mod_short_lseq: a:qelem_lseq -> qelem_lseq
let mod_short_lseq a =
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
let tmp = create4 t0 t1 t2 t3 in
let c, out = SB.bn_add a tmp in
let mask = u64 0 -. c in
map2 (BB.mask_select mask) out a
noextract
val mul_pow2_256_minus_q_lseq:
len:size_nat -> resLen:size_nat{2 + len <= resLen}
-> a:lseq uint64 len -> BB.carry U64 & lseq uint64 resLen
let mul_pow2_256_minus_q_lseq len resLen a =
let t0 = u64 0x402da1732fc9bebf in
let t1 = u64 0x4551231950b75fc4 in
let t01 = create2 t0 t1 in
let m0 = SB.bn_mul a t01 in // a * t01
let m1 = create resLen (u64 0) in
let m1 = update_sub m1 2 len a in // a * t2 * pow2 128
SB.bn_add m1 m0 // a * SECP256K1_N_C
noextract
val mul_pow2_256_minus_q_lseq_add:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen}
-> a:lseq uint64 len -> e:lseq uint64 4 -> BB.carry U64 & lseq uint64 resLen
let mul_pow2_256_minus_q_lseq_add len resLen a e =
let _, m = mul_pow2_256_minus_q_lseq len resLen a in // a * SECP256K1_N_C
SB.bn_add m e // e + a * SECP256K1_N_C
noextract | false | false | Hacl.Spec.K256.Scalar.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mod_lseq_before_final: a:lseq uint64 8 -> BB.carry U64 & qelem_lseq | [] | Hacl.Spec.K256.Scalar.mod_lseq_before_final | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Lib.Sequence.lseq Lib.IntTypes.uint64 8
-> Hacl.Spec.Bignum.Base.carry Lib.IntTypes.U64 * Hacl.Spec.K256.Scalar.qelem_lseq | {
"end_col": 59,
"end_line": 165,
"start_col": 29,
"start_line": 148
} |
Prims.Tot | val mod_lseq: a:lseq uint64 8 -> qelem_lseq | [
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mod_lseq a =
let c0, r = mod_lseq_before_final a in
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
let tmp = create4 t0 t1 t2 t3 in
let c1, out = SB.bn_add r tmp in
let mask = u64 0 -. (c0 +. c1) in
map2 (BB.mask_select mask) out r | val mod_lseq: a:lseq uint64 8 -> qelem_lseq
let mod_lseq a = | false | null | false | let c0, r = mod_lseq_before_final a in
let t0, t1, t2, t3 = make_pow2_256_minus_order_k256 () in
let tmp = create4 t0 t1 t2 t3 in
let c1, out = SB.bn_add r tmp in
let mask = u64 0 -. (c0 +. c1) in
map2 (BB.mask_select mask) out r | {
"checked_file": "Hacl.Spec.K256.Scalar.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Scalar.fst"
} | [
"total"
] | [
"Lib.Sequence.lseq",
"Lib.IntTypes.uint64",
"Hacl.Spec.Bignum.Base.carry",
"Lib.IntTypes.U64",
"Hacl.Spec.K256.Scalar.qelem_lseq",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Lib.Sequence.map2",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.Base.mask_select",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Subtraction_Dot",
"Lib.IntTypes.u64",
"Lib.IntTypes.op_Plus_Dot",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.Bignum.bn_add",
"Lib.Sequence.create4",
"Hacl.Spec.K256.Scalar.qelem4",
"Hacl.Spec.K256.Scalar.make_pow2_256_minus_order_k256",
"Hacl.Spec.K256.Scalar.mod_lseq_before_final"
] | [] | module Hacl.Spec.K256.Scalar
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module BSeq = Lib.ByteSequence
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
module S = Spec.K256
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let qelem4 = uint64 & uint64 & uint64 & uint64
inline_for_extraction noextract
let qelem_lseq = lseq uint64 4
noextract
let qas_nat4 (f:qelem4) =
let (f0, f1, f2, f3) = f in
v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192
inline_for_extraction noextract
val make_pow2_256_minus_order_k256: unit -> Pure qelem4
(requires True)
(ensures fun r -> qas_nat4 r = pow2 256 - S.q)
let make_pow2_256_minus_order_k256 () =
[@inline_let]
let r =
(u64 0x402da1732fc9bebf,
u64 0x4551231950b75fc4,
u64 0x1,
u64 0x0) in
assert_norm (qas_nat4 r = pow2 256 - S.q);
r
inline_for_extraction noextract
let is_qelem_zero_vartime4 ((f0,f1,f2,f3): qelem4) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 f0 =. 0uL &&
u64_to_UInt64 f1 =. 0uL &&
u64_to_UInt64 f2 =. 0uL &&
u64_to_UInt64 f3 =. 0uL
inline_for_extraction noextract
let is_qelem_lt_q_vartime4 ((a0,a1,a2,a3): qelem4) : bool =
let open Lib.RawIntTypes in
if u64_to_UInt64 a3 <. 0xffffffffffffffffuL then true
else begin
if u64_to_UInt64 a2 <. 0xfffffffffffffffeuL then true
else begin
if u64_to_UInt64 a2 >. 0xfffffffffffffffeuL then false
else begin
if u64_to_UInt64 a1 <. 0xbaaedce6af48a03buL then true
else begin
if u64_to_UInt64 a1 >. 0xbaaedce6af48a03buL then false
else u64_to_UInt64 a0 <. 0xbfd25e8cd0364141uL
end
end
end
end
inline_for_extraction noextract
let is_qelem_le_q_halved_vartime4 ((a0,a1,a2,a3): qelem4) : bool =
let open Lib.RawIntTypes in
if u64_to_UInt64 a3 <. 0x7fffffffffffffffuL then true
else begin
if u64_to_UInt64 a3 >. 0x7fffffffffffffffuL then false
else begin
if u64_to_UInt64 a2 <. 0xffffffffffffffffuL then true
else begin
if u64_to_UInt64 a2 >. 0xffffffffffffffffuL then false
else begin
if u64_to_UInt64 a1 <. 0x5d576e7357a4501duL then true
else begin
if u64_to_UInt64 a1 >. 0x5d576e7357a4501duL then false
else u64_to_UInt64 a0 <=. 0xdfe92f46681b20a0uL
end
end
end
end
end
inline_for_extraction noextract
let is_qelem_eq_vartime4 ((a0,a1,a2,a3): qelem4) ((b0,b1,b2,b3): qelem4) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 a0 =. u64_to_UInt64 b0 &&
u64_to_UInt64 a1 =. u64_to_UInt64 b1 &&
u64_to_UInt64 a2 =. u64_to_UInt64 b2 &&
u64_to_UInt64 a3 =. u64_to_UInt64 b3
inline_for_extraction noextract
let is_qelem_lt_pow2_128_vartime4 ((a0,a1,a2,a3): qelem4) : bool =
let open Lib.RawIntTypes in
u64_to_UInt64 a2 =. 0uL && u64_to_UInt64 a3 =. 0uL
noextract
val mod_short_lseq: a:qelem_lseq -> qelem_lseq
let mod_short_lseq a =
let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in
let tmp = create4 t0 t1 t2 t3 in
let c, out = SB.bn_add a tmp in
let mask = u64 0 -. c in
map2 (BB.mask_select mask) out a
noextract
val mul_pow2_256_minus_q_lseq:
len:size_nat -> resLen:size_nat{2 + len <= resLen}
-> a:lseq uint64 len -> BB.carry U64 & lseq uint64 resLen
let mul_pow2_256_minus_q_lseq len resLen a =
let t0 = u64 0x402da1732fc9bebf in
let t1 = u64 0x4551231950b75fc4 in
let t01 = create2 t0 t1 in
let m0 = SB.bn_mul a t01 in // a * t01
let m1 = create resLen (u64 0) in
let m1 = update_sub m1 2 len a in // a * t2 * pow2 128
SB.bn_add m1 m0 // a * SECP256K1_N_C
noextract
val mul_pow2_256_minus_q_lseq_add:
len:size_nat -> resLen:size_nat{2 + len <= resLen /\ 4 <= resLen}
-> a:lseq uint64 len -> e:lseq uint64 4 -> BB.carry U64 & lseq uint64 resLen
let mul_pow2_256_minus_q_lseq_add len resLen a e =
let _, m = mul_pow2_256_minus_q_lseq len resLen a in // a * SECP256K1_N_C
SB.bn_add m e // e + a * SECP256K1_N_C
noextract
val mod_lseq_before_final: a:lseq uint64 8 -> BB.carry U64 & qelem_lseq
let mod_lseq_before_final a =
// Reduce 512 bits into 385.
// m[0..6] = a[0..3] + a[4..7] * SECP256K1_N_C.
// Reduce 385 bits into 258.
// p[0..4] = m[0..3] + m[4..6] * SECP256K1_N_C.
// Reduce 258 bits into 256.
// c, r[0..3] = p[0..3] + p[4] * SECP256K1_N_C.
// Final reduction of r.
// secp256k1_scalar_reduce(r, c + secp256k1_scalar_check_overflow(r));
// 385 // 64 = 7
let _, m = mul_pow2_256_minus_q_lseq_add 4 7 (sub a 4 4) (sub a 0 4) in // a[0..3] + a[4..7] * SECP256K1_N_C
// 258 // 64 = 5
let _, p = mul_pow2_256_minus_q_lseq_add 3 5 (sub m 4 3) (sub m 0 4) in // m[0..3] + m[4..6] * SECP256K1_N_C
mul_pow2_256_minus_q_lseq_add 1 4 (sub p 4 1) (sub p 0 4) // p[0..3] + p[4] * SECP256K1_N_C
noextract | false | false | Hacl.Spec.K256.Scalar.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mod_lseq: a:lseq uint64 8 -> qelem_lseq | [] | Hacl.Spec.K256.Scalar.mod_lseq | {
"file_name": "code/k256/Hacl.Spec.K256.Scalar.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Lib.Sequence.lseq Lib.IntTypes.uint64 8 -> Hacl.Spec.K256.Scalar.qelem_lseq | {
"end_col": 34,
"end_line": 178,
"start_col": 16,
"start_line": 170
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.IntegerIntervals",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Algebra.CommMonoid.Equiv",
"short_module": "CE"
},
{
"abbrev": true,
"full_module": "FStar.Algebra.CommMonoid.Fold",
"short_module": "CF"
},
{
"abbrev": false,
"full_module": "FStar.IntegerIntervals",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Algebra.CommMonoid.Equiv",
"short_module": "CE"
},
{
"abbrev": true,
"full_module": "FStar.Algebra.CommMonoid.Fold",
"short_module": "CF"
},
{
"abbrev": false,
"full_module": "FStar.Algebra.CommMonoid.Fold",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Algebra.CommMonoid.Fold",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let matrix_seq #c #m #r (generator: matrix_generator c m r) =
seq_of_matrix (Matrix.init generator) | let matrix_seq #c #m #r (generator: matrix_generator c m r) = | false | null | false | seq_of_matrix (Matrix.init generator) | {
"checked_file": "FStar.Algebra.CommMonoid.Fold.Nested.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Seq.Permutation.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Matrix.fsti.checked",
"FStar.IntegerIntervals.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Algebra.CommMonoid.Fold.fsti.checked",
"FStar.Algebra.CommMonoid.Equiv.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Algebra.CommMonoid.Fold.Nested.fst"
} | [
"total"
] | [
"Prims.pos",
"FStar.Matrix.matrix_generator",
"FStar.Matrix.seq_of_matrix",
"FStar.Matrix.init",
"FStar.Seq.Base.seq",
"Prims.l_and",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"Prims.op_Multiply",
"Prims.l_Forall",
"FStar.IntegerIntervals.under",
"Prims.eq2",
"FStar.Seq.Base.index",
"FStar.Matrix.get_ij",
"FStar.Matrix.get_i",
"FStar.Matrix.get_j"
] | [] | (*
Copyright 2022 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Author: A. Rozanov
*)
(*
Here we reason about nested folds of functions over arbitrary
integer intervals. We call such functions generators.
*)
module FStar.Algebra.CommMonoid.Fold.Nested
module CF = FStar.Algebra.CommMonoid.Fold
module CE = FStar.Algebra.CommMonoid.Equiv
open FStar.IntegerIntervals
open FStar.Matrix
(* Auxiliary utility that casts (matrix c m n) to seq of length (m*n) *) | false | false | FStar.Algebra.CommMonoid.Fold.Nested.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val matrix_seq : generator: FStar.Matrix.matrix_generator c m r
-> s:
FStar.Seq.Base.seq c
{ FStar.Seq.Base.length s = m * r /\
(forall (ij: FStar.IntegerIntervals.under (m * r)).
FStar.Seq.Base.index s ij ==
FStar.Seq.Base.index s
(FStar.Matrix.get_ij m r (FStar.Matrix.get_i m r ij) (FStar.Matrix.get_j m r ij))) } | [] | FStar.Algebra.CommMonoid.Fold.Nested.matrix_seq | {
"file_name": "ulib/FStar.Algebra.CommMonoid.Fold.Nested.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | generator: FStar.Matrix.matrix_generator c m r
-> s:
FStar.Seq.Base.seq c
{ FStar.Seq.Base.length s = m * r /\
(forall (ij: FStar.IntegerIntervals.under (m * r)).
FStar.Seq.Base.index s ij ==
FStar.Seq.Base.index s
(FStar.Matrix.get_ij m r (FStar.Matrix.get_i m r ij) (FStar.Matrix.get_j m r ij))) } | {
"end_col": 39,
"end_line": 34,
"start_col": 2,
"start_line": 34
} |
|
FStar.Pervasives.Lemma | val double_fold_transpose_lemma (#c:_) (#eq: _)
(#m0: int) (#mk: not_less_than m0)
(#n0: int) (#nk: not_less_than n0)
(cm: CE.cm c eq)
(offset_gen: ifrom_ito m0 mk -> ifrom_ito n0 nk -> c)
: Lemma (double_fold cm offset_gen
`eq.eq`
double_fold cm (transpose_generator offset_gen)) | [
{
"abbrev": false,
"full_module": "FStar.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.IntegerIntervals",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Algebra.CommMonoid.Equiv",
"short_module": "CE"
},
{
"abbrev": true,
"full_module": "FStar.Algebra.CommMonoid.Fold",
"short_module": "CF"
},
{
"abbrev": false,
"full_module": "FStar.IntegerIntervals",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Algebra.CommMonoid.Equiv",
"short_module": "CE"
},
{
"abbrev": true,
"full_module": "FStar.Algebra.CommMonoid.Fold",
"short_module": "CF"
},
{
"abbrev": false,
"full_module": "FStar.Algebra.CommMonoid.Fold",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Algebra.CommMonoid.Fold",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let double_fold_transpose_lemma #c #eq
(#m0: int) (#mk: not_less_than m0)
(#n0: int) (#nk: not_less_than n0)
(cm: CE.cm c eq)
(offset_gen: ifrom_ito m0 mk -> ifrom_ito n0 nk -> c)
: Lemma (double_fold cm offset_gen
`eq.eq`
double_fold cm (transpose_generator offset_gen)) =
let m = interval_size (ifrom_ito m0 mk) in
let n = interval_size (ifrom_ito n0 nk) in
let gen : matrix_generator c m n = fun i j -> offset_gen (m0+i) (n0+j) in
let trans #c #a #b (f: matrix_generator c a b) = transposed_matrix_gen f in
let trans_ofs #c (#a1 #a2 #b1 #b2:int) (f: ifrom_ito a1 a2 -> ifrom_ito b1 b2 -> c)
= transpose_generator f in
// Here, F* agrees that (n-1) == (nk-n0).
// But, replace (n-1) with (nk-n0) below, and the proof will fail :)
let subfold_lhs_base0 (i: under m) = CF.fold cm 0 (n-1) (gen i) in
let subfold_rhs_base0 (j: under n) = CF.fold cm 0 (m-1) (trans gen j) in
let subfold_lhs_precise (i: ifrom_ito m0 mk)
= CF.fold cm n0 nk (offset_gen i) in
let subfold_rhs_precise (j: ifrom_ito n0 nk)
= CF.fold cm m0 mk (trans_ofs offset_gen j) in
let lhs = CF.fold cm m0 mk subfold_lhs_precise in
let rhs = CF.fold cm n0 nk subfold_rhs_precise in
let aux_lhs (i: under m) : Lemma
(CF.fold cm n0 nk (offset_gen (m0+i)) == CF.fold cm 0 (n-1) (gen i)) =
CF.fold_offset_irrelevance_lemma cm n0 nk (offset_gen (m0+i)) 0 (n-1) (gen i) in
let aux_rhs (j: under n) : Lemma
(CF.fold cm m0 mk (trans_ofs offset_gen (n0+j)) ==
CF.fold cm 0 (m-1) (trans gen j))
= CF.fold_offset_irrelevance_lemma cm m0 mk (trans_ofs offset_gen (n0+j))
0 (m-1) (trans gen j) in
FStar.Classical.forall_intro aux_lhs;
FStar.Classical.forall_intro aux_rhs;
FStar.Classical.forall_intro eq.reflexivity;
matrix_fold_equals_func_double_fold cm gen;
matrix_fold_equals_func_double_fold cm (trans gen);
let matrix_mn = matrix_seq gen in
let matrix_nm = matrix_seq (trans gen) in
CF.fold_offset_elimination_lemma cm m0 mk subfold_lhs_precise subfold_lhs_base0;
CF.fold_offset_elimination_lemma cm n0 nk subfold_rhs_precise subfold_rhs_base0;
FStar.Classical.forall_intro_2 (FStar.Classical.move_requires_2 eq.symmetry);
FStar.Classical.forall_intro_3 (FStar.Classical.move_requires_3 eq.transitivity);
matrix_fold_equals_fold_of_transpose cm gen;
matrix_fold_equals_func_double_fold cm gen;
matrix_fold_equals_func_double_fold cm (transposed_matrix_gen gen);
assert_norm (double_fold cm (transpose_generator offset_gen) == rhs);
eq.transitivity (FStar.Seq.Permutation.foldm_snoc cm matrix_mn) lhs rhs | val double_fold_transpose_lemma (#c:_) (#eq: _)
(#m0: int) (#mk: not_less_than m0)
(#n0: int) (#nk: not_less_than n0)
(cm: CE.cm c eq)
(offset_gen: ifrom_ito m0 mk -> ifrom_ito n0 nk -> c)
: Lemma (double_fold cm offset_gen
`eq.eq`
double_fold cm (transpose_generator offset_gen))
let double_fold_transpose_lemma
#c
#eq
(#m0: int)
(#mk: not_less_than m0)
(#n0: int)
(#nk: not_less_than n0)
(cm: CE.cm c eq)
(offset_gen: (ifrom_ito m0 mk -> ifrom_ito n0 nk -> c))
: Lemma ((double_fold cm offset_gen) `eq.eq` (double_fold cm (transpose_generator offset_gen))) = | false | null | true | let m = interval_size (ifrom_ito m0 mk) in
let n = interval_size (ifrom_ito n0 nk) in
let gen:matrix_generator c m n = fun i j -> offset_gen (m0 + i) (n0 + j) in
let trans #c #a #b (f: matrix_generator c a b) = transposed_matrix_gen f in
let trans_ofs
#c
(#a1: int)
(#a2: int)
(#b1: int)
(#b2: int)
(f: (ifrom_ito a1 a2 -> ifrom_ito b1 b2 -> c))
=
transpose_generator f
in
let subfold_lhs_base0 (i: under m) = CF.fold cm 0 (n - 1) (gen i) in
let subfold_rhs_base0 (j: under n) = CF.fold cm 0 (m - 1) (trans gen j) in
let subfold_lhs_precise (i: ifrom_ito m0 mk) = CF.fold cm n0 nk (offset_gen i) in
let subfold_rhs_precise (j: ifrom_ito n0 nk) = CF.fold cm m0 mk (trans_ofs offset_gen j) in
let lhs = CF.fold cm m0 mk subfold_lhs_precise in
let rhs = CF.fold cm n0 nk subfold_rhs_precise in
let aux_lhs (i: under m)
: Lemma (CF.fold cm n0 nk (offset_gen (m0 + i)) == CF.fold cm 0 (n - 1) (gen i)) =
CF.fold_offset_irrelevance_lemma cm n0 nk (offset_gen (m0 + i)) 0 (n - 1) (gen i)
in
let aux_rhs (j: under n)
: Lemma (CF.fold cm m0 mk (trans_ofs offset_gen (n0 + j)) == CF.fold cm 0 (m - 1) (trans gen j))
=
CF.fold_offset_irrelevance_lemma cm m0 mk (trans_ofs offset_gen (n0 + j)) 0 (m - 1) (trans gen j)
in
FStar.Classical.forall_intro aux_lhs;
FStar.Classical.forall_intro aux_rhs;
FStar.Classical.forall_intro eq.reflexivity;
matrix_fold_equals_func_double_fold cm gen;
matrix_fold_equals_func_double_fold cm (trans gen);
let matrix_mn = matrix_seq gen in
let matrix_nm = matrix_seq (trans gen) in
CF.fold_offset_elimination_lemma cm m0 mk subfold_lhs_precise subfold_lhs_base0;
CF.fold_offset_elimination_lemma cm n0 nk subfold_rhs_precise subfold_rhs_base0;
FStar.Classical.forall_intro_2 (FStar.Classical.move_requires_2 eq.symmetry);
FStar.Classical.forall_intro_3 (FStar.Classical.move_requires_3 eq.transitivity);
matrix_fold_equals_fold_of_transpose cm gen;
matrix_fold_equals_func_double_fold cm gen;
matrix_fold_equals_func_double_fold cm (transposed_matrix_gen gen);
assert_norm (double_fold cm (transpose_generator offset_gen) == rhs);
eq.transitivity (FStar.Seq.Permutation.foldm_snoc cm matrix_mn) lhs rhs | {
"checked_file": "FStar.Algebra.CommMonoid.Fold.Nested.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Seq.Permutation.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Matrix.fsti.checked",
"FStar.IntegerIntervals.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Algebra.CommMonoid.Fold.fsti.checked",
"FStar.Algebra.CommMonoid.Equiv.fst.checked"
],
"interface_file": true,
"source_file": "FStar.Algebra.CommMonoid.Fold.Nested.fst"
} | [
"lemma"
] | [
"FStar.Algebra.CommMonoid.Equiv.equiv",
"Prims.int",
"FStar.IntegerIntervals.not_less_than",
"FStar.Algebra.CommMonoid.Equiv.cm",
"FStar.IntegerIntervals.ifrom_ito",
"FStar.Algebra.CommMonoid.Equiv.__proj__EQ__item__transitivity",
"FStar.Seq.Permutation.foldm_snoc",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"FStar.Algebra.CommMonoid.Fold.Nested.double_fold",
"FStar.Algebra.CommMonoid.Fold.Nested.transpose_generator",
"FStar.Matrix.matrix_fold_equals_func_double_fold",
"FStar.Matrix.transposed_matrix_gen",
"FStar.Matrix.matrix_fold_equals_fold_of_transpose",
"FStar.Classical.forall_intro_3",
"Prims.l_imp",
"Prims.l_and",
"FStar.Algebra.CommMonoid.Equiv.__proj__EQ__item__eq",
"FStar.Classical.move_requires_3",
"FStar.Classical.forall_intro_2",
"FStar.Classical.move_requires_2",
"FStar.Algebra.CommMonoid.Equiv.__proj__EQ__item__symmetry",
"FStar.Algebra.CommMonoid.Fold.fold_offset_elimination_lemma",
"FStar.Seq.Base.seq",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Seq.Base.length",
"Prims.op_Multiply",
"Prims.l_Forall",
"FStar.IntegerIntervals.under",
"FStar.Seq.Base.index",
"FStar.Matrix.get_ij",
"FStar.Matrix.get_i",
"FStar.Matrix.get_j",
"FStar.Algebra.CommMonoid.Fold.Nested.matrix_seq",
"FStar.Classical.forall_intro",
"FStar.Algebra.CommMonoid.Equiv.__proj__EQ__item__reflexivity",
"FStar.Algebra.CommMonoid.Fold.fold",
"Prims.op_Addition",
"Prims.op_Subtraction",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"FStar.Algebra.CommMonoid.Fold.fold_offset_irrelevance_lemma",
"Prims.pos",
"FStar.Matrix.matrix_generator",
"Prims.nat",
"FStar.IntegerIntervals.interval_size"
] | [] | (*
Copyright 2022 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Author: A. Rozanov
*)
(*
Here we reason about nested folds of functions over arbitrary
integer intervals. We call such functions generators.
*)
module FStar.Algebra.CommMonoid.Fold.Nested
module CF = FStar.Algebra.CommMonoid.Fold
module CE = FStar.Algebra.CommMonoid.Equiv
open FStar.IntegerIntervals
open FStar.Matrix
(* Auxiliary utility that casts (matrix c m n) to seq of length (m*n) *)
let matrix_seq #c #m #r (generator: matrix_generator c m r) =
seq_of_matrix (Matrix.init generator)
(*
Most general form of nested fold swap theorem. Here we prove that we can
exchange the order of nested foldings over any suitable generator function.
We use the previously proved weaker version (for zero-based indices) in
order to prove this, because this way the two proofs together are way shorter.
I keep the argument types explicit in order to make the proof easier to read.
*)
let double_fold_transpose_lemma #c #eq
(#m0: int) (#mk: not_less_than m0)
(#n0: int) (#nk: not_less_than n0)
(cm: CE.cm c eq)
(offset_gen: ifrom_ito m0 mk -> ifrom_ito n0 nk -> c)
: Lemma (double_fold cm offset_gen | false | false | FStar.Algebra.CommMonoid.Fold.Nested.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val double_fold_transpose_lemma (#c:_) (#eq: _)
(#m0: int) (#mk: not_less_than m0)
(#n0: int) (#nk: not_less_than n0)
(cm: CE.cm c eq)
(offset_gen: ifrom_ito m0 mk -> ifrom_ito n0 nk -> c)
: Lemma (double_fold cm offset_gen
`eq.eq`
double_fold cm (transpose_generator offset_gen)) | [] | FStar.Algebra.CommMonoid.Fold.Nested.double_fold_transpose_lemma | {
"file_name": "ulib/FStar.Algebra.CommMonoid.Fold.Nested.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
cm: FStar.Algebra.CommMonoid.Equiv.cm c eq ->
offset_gen:
(_: FStar.IntegerIntervals.ifrom_ito m0 mk -> _: FStar.IntegerIntervals.ifrom_ito n0 nk -> c)
-> FStar.Pervasives.Lemma
(ensures
EQ?.eq eq
(FStar.Algebra.CommMonoid.Fold.Nested.double_fold cm offset_gen)
(FStar.Algebra.CommMonoid.Fold.Nested.double_fold cm
(FStar.Algebra.CommMonoid.Fold.Nested.transpose_generator offset_gen))) | {
"end_col": 73,
"end_line": 92,
"start_col": 61,
"start_line": 52
} |
Prims.GTot | val mt_root_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs0:hashes #hsz {S.length hs0 > 0} ->
acc:hash #hsz -> actd:bool ->
rt:hash #hsz ->
GTot Type0 | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mt_root_inv #_ #f hs0 acc actd rt =
MTS.mt_get_root #_ #f #(log2c (S.length hs0))
(hash_seq_spec_full #_ #f hs0 acc actd) == MTS.HRaw rt | val mt_root_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs0:hashes #hsz {S.length hs0 > 0} ->
acc:hash #hsz -> actd:bool ->
rt:hash #hsz ->
GTot Type0
let mt_root_inv #_ #f hs0 acc actd rt = | false | null | false | MTS.mt_get_root #_ #f #(log2c (S.length hs0)) (hash_seq_spec_full #_ #f hs0 acc actd) == MTS.HRaw rt | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"sometrivial"
] | [
"Prims.pos",
"MerkleTree.Spec.hash_fun_t",
"MerkleTree.New.High.hashes",
"Prims.b2t",
"Prims.op_GreaterThan",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hash",
"Prims.bool",
"Prims.eq2",
"MerkleTree.Spec.padded_hash",
"MerkleTree.Spec.mt_get_root",
"MerkleTree.New.High.Correct.Base.log2c",
"MerkleTree.New.High.Correct.Base.hash_seq_spec_full",
"MerkleTree.Spec.HRaw"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j)
val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i)
let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2
val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_olds_inv #hsz lv i olds =
if lv = 32 then true
else (let ofs = offset_of i in
S.length (S.index olds lv) == ofs /\
mt_olds_inv #hsz (lv + 1) (i / 2) olds)
val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv))
let rec mt_olds_inv_equiv #hsz #f lv i olds1 olds2 =
if lv = 32 then ()
else (assert (S.index olds1 lv == S.index olds2 lv);
mt_olds_inv_equiv #_ #f (lv + 1) (i / 2) olds1 olds2)
val mt_olds_hs_lth_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs))
(decreases (32 - lv))
let rec mt_olds_hs_lth_inv_ok #hsz #f lv i j olds hs =
if lv = 32 then ()
else (mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs)
val mt_olds_hs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
GTot Type0
let mt_olds_hs_inv #hsz #f lv i j olds hs =
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs)
// Relation between valid internal hashes (satisfying `mt_olds_hs_inv`) and
// the spec. While giving such relation, all rightmost hashes are recovered.
// Note that `MT?.rhs` after `construct_rhs` does NOT contain all rightmost
// hashes; it has partial rightmost hashes that are enough to calculate
// Merkle paths.
val log2: n:nat{n > 0} -> GTot (c:nat{pow2 c <= n && n < pow2 (c+1)})
let rec log2 n =
if n = 1 then 0
else 1 + log2 (n / 2)
val log2_bound:
n:nat{n > 0} -> c:nat{n < pow2 c} ->
Lemma (log2 n <= c-1)
let rec log2_bound n c =
if n = 1 then ()
else log2_bound (n / 2) (c - 1)
val log2_div:
n:nat{n > 1} ->
Lemma (log2 (n / 2) = log2 n - 1)
let log2_div n = ()
val log2c:
n:nat ->
GTot (c:nat{c = 0 || (pow2 (c-1) <= n && n < pow2 c)})
let log2c n =
if n = 0 then 0 else (log2 n + 1)
val log2c_div:
n:nat{n > 0} ->
Lemma (log2c (n / 2) = log2c n - 1)
let log2c_div n = ()
val log2c_bound:
n:nat -> c:nat{n < pow2 c} ->
Lemma (log2c n <= c)
let rec log2c_bound n c =
if n = 0 then ()
else log2c_bound (n / 2) (c - 1)
val mt_hashes_lth_inv_log:
#hsz:pos ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
GTot Type0 (decreases j)
let rec mt_hashes_lth_inv_log #hsz j fhs =
if j = 0 then true
else (S.length (S.head fhs) == j /\
mt_hashes_lth_inv_log #hsz (j / 2) (S.tail fhs))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_lth_inv_log_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
Lemma (requires mt_hashes_lth_inv_log #hsz j fhs)
(ensures S.length (S.head fhs) == j /\
S.length (S.head (S.tail fhs)) == j / 2)
let mt_hashes_lth_inv_log_next #_ #_ _ _ = ()
val mt_hashes_inv_log:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j /\ mt_hashes_lth_inv_log #hsz j fhs} ->
GTot Type0 (decreases j)
let rec mt_hashes_inv_log #hsz #f j fhs =
if j <= 1 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs 0) (S.index fhs 1) /\
mt_hashes_inv_log #_ #f (j / 2) (S.tail fhs))
val mt_hashes_lth_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log #hsz j (S.slice fhs lv (lv + log2c j))))
(decreases j)
let rec mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs =
if j = 0 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log #hsz j (S.slice fhs 0 (log2c j))))
let mt_hashes_lth_inv_log_converted #_ #f j fhs =
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs
val mt_hashes_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j > 0 && j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz lv j fhs} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs lv (lv + log2c j))))
(decreases j)
#pop-options
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
let rec mt_hashes_inv_log_converted_ #_ #f lv j fhs =
if j = 1 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs;
mt_hashes_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
#pop-options
val mt_hashes_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 0 && j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz 0 j fhs} ->
Lemma (requires mt_hashes_inv #_ #f 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs 0 (log2c j))))
let mt_hashes_inv_log_converted #_ #f j fhs =
mt_hashes_inv_log_converted_ #_ #f 0 j fhs
val hash_seq_lift:
#hsz:pos ->
hs:hashes #hsz ->
GTot (shs:MTS.hashes #hsz {S.length shs = S.length hs})
(decreases (S.length hs))
let rec hash_seq_lift #hsz hs =
if S.length hs = 0 then S.empty
else S.cons (MTS.HRaw (S.head hs)) (hash_seq_lift #hsz (S.tail hs))
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
val hash_seq_lift_index:
#hsz:pos ->
hs:hashes #hsz ->
Lemma (requires True)
(ensures forall (i:nat{i < S.length hs}).
S.index (hash_seq_lift #hsz hs) i == MTS.HRaw (S.index hs i))
(decreases (S.length hs))
let rec hash_seq_lift_index #hsz hs =
if S.length hs = 0 then ()
else hash_seq_lift_index #hsz (S.tail hs)
#pop-options
val create_pads: #hsz:pos -> len:nat -> GTot (pads:MTS.hashes #hsz {S.length pads = len})
let create_pads #hsz len = S.create len (MTS.HPad #hsz)
val hash_seq_spec:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
GTot (MTS.merkle_tree #hsz (log2c (S.length hs)))
let hash_seq_spec #hsz hs =
S.append (hash_seq_lift #hsz hs)
(create_pads (pow2 (log2c (S.length hs)) - S.length hs))
val hash_seq_spec_index_raw:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
i:nat{i < S.length hs} ->
Lemma (S.index (hash_seq_spec #hsz hs) i == MTS.HRaw #hsz (S.index hs i))
let hash_seq_spec_index_raw #hsz hs i =
hash_seq_lift_index #hsz hs
// Now about recovering rightmost hashes
#push-options "--z3rlimit 50 --initial_fuel 1 --max_fuel 1"
val mt_hashes_next_rel_lift_even:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures MTS.mt_next_rel #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs))
let mt_hashes_next_rel_lift_even #hsz #_ j hs nhs =
hash_seq_lift_index #hsz hs;
hash_seq_lift_index #hsz nhs
val mt_hashes_next_rel_lift_odd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 1 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures MTS.mt_next_rel #_ #f (log2c j)
(hash_seq_spec #hsz hs)
(S.upd (hash_seq_spec #hsz nhs)
(S.length nhs) (MTS.HRaw (S.last hs))))
let mt_hashes_next_rel_lift_odd #hsz #_ j hs nhs =
log2c_div j;
hash_seq_lift_index #hsz hs;
hash_seq_lift_index #hsz nhs
val mt_hashes_next_rel_next_even:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures S.equal (hash_seq_spec #hsz nhs)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec #hsz hs)))
let mt_hashes_next_rel_next_even #hsz #f j hs nhs =
log2c_div j;
mt_hashes_next_rel_lift_even #_ #f j hs nhs;
MTS.mt_next_rel_next_lv #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs)
val hash_seq_spec_full:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs:hashes #hsz {S.length hs > 0} ->
acc:hash #hsz -> actd:bool ->
GTot (MTS.merkle_tree #hsz (log2c (S.length hs)))
let hash_seq_spec_full #hsz #f hs acc actd =
if actd
then (S.upd (hash_seq_spec #hsz hs) (S.length hs) (MTS.HRaw acc))
else hash_seq_spec #hsz hs
val hash_seq_spec_full_index_raw:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs:hashes #hsz {S.length hs > 0} ->
acc:hash #hsz -> actd:bool -> i:nat{i < S.length hs} ->
Lemma (S.index (hash_seq_spec_full #_ #f hs acc actd) i ==
MTS.HRaw (S.index hs i))
let hash_seq_spec_full_index_raw #hsz #_ hs acc actd i =
hash_seq_spec_index_raw #hsz hs i
val hash_seq_spec_full_case_true:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs:hashes #hsz {S.length hs > 0} -> acc:hash #hsz ->
Lemma (S.index (hash_seq_spec_full #_ #f hs acc true) (S.length hs) == MTS.HRaw acc)
let hash_seq_spec_full_case_true #_ #_ _ _ = ()
val hash_seq_spec_full_even_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 0} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
acc:hash #hsz -> actd:bool ->
Lemma
(requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures S.equal (hash_seq_spec_full #_ #f nhs acc actd)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f hs acc actd)))
#restart-solver
#push-options "--quake 1/3 --z3rlimit 100 --fuel 2 --ifuel 1"
let hash_seq_spec_full_even_next #hsz #f j hs nhs acc actd =
log2c_div j;
mt_hashes_next_rel_lift_even #_ #f j hs nhs;
if actd
then begin
MTS.mt_next_rel_upd_even_pad #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs) (S.length hs / 2) (MTS.HRaw acc);
let n = log2c j in
let mt = S.upd (hash_seq_spec #hsz hs) (S.length hs) (MTS.HRaw acc) in
let nmt = S.upd (hash_seq_spec #hsz nhs) (S.length nhs) (MTS.HRaw acc) in
// assume (MTS.mt_next_rel #_ #f n mt nmt);
MTS.mt_next_rel_next_lv #_ #f n mt nmt
end
else MTS.mt_next_rel_next_lv #_ #f (log2c j)
(hash_seq_spec_full #_ #f hs acc actd)
(hash_seq_spec_full #_ #f nhs acc actd)
#pop-options
#push-options "--z3rlimit 80"
val hash_seq_spec_full_odd_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
acc:hash #hsz -> actd:bool -> nacc:hash #hsz ->
Lemma
(requires j % 2 = 1 /\
mt_hashes_next_rel #_ #f j hs nhs /\
nacc == (if actd then f (S.last hs) acc else S.last hs))
(ensures S.equal (hash_seq_spec_full #_ #f nhs nacc true)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f hs acc actd)))
let hash_seq_spec_full_odd_next #hsz #f j hs nhs acc actd nacc =
log2c_div j;
mt_hashes_next_rel_lift_odd #_ #f j hs nhs;
if actd
then begin
MTS.mt_next_rel_upd_odd #_ #f (log2c j)
(hash_seq_spec #hsz hs)
(S.upd (hash_seq_spec #hsz nhs) (S.length nhs) (MTS.HRaw (S.last hs)))
(S.length nhs) (MTS.HRaw acc);
MTS.mt_next_rel_next_lv #_ #f (log2c j)
(S.upd (hash_seq_spec #hsz hs) (S.length hs) (MTS.HRaw acc))
(S.upd (hash_seq_spec #hsz nhs) (S.length nhs) (MTS.HRaw (f (S.last hs) acc)))
end
else MTS.mt_next_rel_next_lv #_ #f (log2c j)
(hash_seq_spec_full #_ #f hs acc actd)
(hash_seq_spec_full #_ #f nhs nacc true)
#pop-options
val hash_seq_spec_full_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
acc:hash #hsz -> actd:bool -> nacc:hash #hsz -> nactd:bool ->
Lemma
(requires mt_hashes_next_rel #_ #f j hs nhs /\
nacc == (if j % 2 = 0 then acc
else if actd
then f (S.last hs) acc
else S.last hs) /\
nactd == (actd || j % 2 = 1))
(ensures S.equal (hash_seq_spec_full #_ #f nhs nacc nactd)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f hs acc actd)))
let hash_seq_spec_full_next #_ #f j hs nhs acc actd nacc nactd =
if j % 2 = 0
then hash_seq_spec_full_even_next #_ #f j hs nhs acc actd
else hash_seq_spec_full_odd_next #_ #f j hs nhs acc actd nacc
val mt_rhs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
smt:MTS.merkle_tree #hsz (log2c j) ->
rhs:hashes #hsz {S.length rhs = log2c j} ->
actd:bool ->
GTot Type0 (decreases j)
let rec mt_rhs_inv #_ #f j smt rhs actd =
if j = 0 then true
else begin
(if j % 2 = 1 && actd
then (S.index smt j == MTS.HRaw (S.head rhs))
else true) /\
mt_rhs_inv #_ #f (j / 2) (MTS.mt_next_lv #_ #f #(log2c j) smt) (S.tail rhs)
(actd || (j % 2 = 1))
end
val mt_root_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs0:hashes #hsz {S.length hs0 > 0} ->
acc:hash #hsz -> actd:bool ->
rt:hash #hsz ->
GTot Type0 | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mt_root_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs0:hashes #hsz {S.length hs0 > 0} ->
acc:hash #hsz -> actd:bool ->
rt:hash #hsz ->
GTot Type0 | [] | MerkleTree.New.High.Correct.Base.mt_root_inv | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
hs0: MerkleTree.New.High.hashes{FStar.Seq.Base.length hs0 > 0} ->
acc: MerkleTree.New.High.hash ->
actd: Prims.bool ->
rt: MerkleTree.New.High.hash
-> Prims.GTot Type0 | {
"end_col": 58,
"end_line": 622,
"start_col": 2,
"start_line": 621
} |
Prims.GTot | val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0 | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1)) | val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 = | false | null | false | S.equal s1 (S.slice s2 0 (S.length s1)) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"sometrivial"
] | [
"FStar.Seq.Base.seq",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Seq.Base.length",
"FStar.Seq.Base.equal",
"FStar.Seq.Base.slice"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0 | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0 | [] | MerkleTree.New.High.Correct.Base.seq_prefix | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
s1: FStar.Seq.Base.seq a ->
s2: FStar.Seq.Base.seq a {FStar.Seq.Base.length s1 <= FStar.Seq.Base.length s2}
-> Prims.GTot Type0 | {
"end_col": 41,
"end_line": 21,
"start_col": 2,
"start_line": 21
} |
Prims.GTot | val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv)) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec mt_olds_inv #hsz lv i olds =
if lv = 32 then true
else (let ofs = offset_of i in
S.length (S.index olds lv) == ofs /\
mt_olds_inv #hsz (lv + 1) (i / 2) olds) | val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_olds_inv #hsz lv i olds = | false | null | false | if lv = 32
then true
else
(let ofs = offset_of i in
S.length (S.index olds lv) == ofs /\ mt_olds_inv #hsz (lv + 1) (i / 2) olds) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"sometrivial",
""
] | [
"Prims.pos",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"MerkleTree.New.High.hashess",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hashes",
"Prims.bool",
"Prims.l_and",
"Prims.eq2",
"MerkleTree.New.High.hash",
"FStar.Seq.Base.index",
"MerkleTree.New.High.Correct.Base.mt_olds_inv",
"Prims.op_Addition",
"Prims.op_Division",
"MerkleTree.New.High.offset_of"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j)
val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i)
let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2
val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv)) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv)) | [
"recursion"
] | MerkleTree.New.High.Correct.Base.mt_olds_inv | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
lv: Prims.nat{lv <= 32} ->
i: Prims.nat ->
olds: MerkleTree.New.High.hashess{FStar.Seq.Base.length olds = 32}
-> Prims.GTot Type0 | {
"end_col": 46,
"end_line": 234,
"start_col": 2,
"start_line": 231
} |
Prims.GTot | val mt_spec:
#hsz:pos ->
mt:merkle_tree #hsz {mt_wf_elts mt /\ MT?.j mt > 0} ->
olds:hashess{S.length olds = 32 /\ mt_olds_inv #hsz 0 (MT?.i mt) olds} ->
GTot (MTS.merkle_tree #hsz (log2c (MT?.j mt))) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mt_spec #hsz mt olds =
hash_seq_spec #_ (mt_base mt olds) | val mt_spec:
#hsz:pos ->
mt:merkle_tree #hsz {mt_wf_elts mt /\ MT?.j mt > 0} ->
olds:hashess{S.length olds = 32 /\ mt_olds_inv #hsz 0 (MT?.i mt) olds} ->
GTot (MTS.merkle_tree #hsz (log2c (MT?.j mt)))
let mt_spec #hsz mt olds = | false | null | false | hash_seq_spec #_ (mt_base mt olds) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"sometrivial"
] | [
"Prims.pos",
"MerkleTree.New.High.merkle_tree",
"Prims.l_and",
"MerkleTree.New.High.mt_wf_elts",
"Prims.b2t",
"Prims.op_GreaterThan",
"MerkleTree.New.High.__proj__MT__item__j",
"MerkleTree.New.High.hashess",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hashes",
"MerkleTree.New.High.Correct.Base.mt_olds_inv",
"MerkleTree.New.High.__proj__MT__item__i",
"MerkleTree.New.High.Correct.Base.hash_seq_spec",
"MerkleTree.New.High.Correct.Base.mt_base",
"MerkleTree.Spec.merkle_tree",
"MerkleTree.New.High.Correct.Base.log2c"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j)
val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i)
let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2
val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_olds_inv #hsz lv i olds =
if lv = 32 then true
else (let ofs = offset_of i in
S.length (S.index olds lv) == ofs /\
mt_olds_inv #hsz (lv + 1) (i / 2) olds)
val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv))
let rec mt_olds_inv_equiv #hsz #f lv i olds1 olds2 =
if lv = 32 then ()
else (assert (S.index olds1 lv == S.index olds2 lv);
mt_olds_inv_equiv #_ #f (lv + 1) (i / 2) olds1 olds2)
val mt_olds_hs_lth_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs))
(decreases (32 - lv))
let rec mt_olds_hs_lth_inv_ok #hsz #f lv i j olds hs =
if lv = 32 then ()
else (mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs)
val mt_olds_hs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
GTot Type0
let mt_olds_hs_inv #hsz #f lv i j olds hs =
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs)
// Relation between valid internal hashes (satisfying `mt_olds_hs_inv`) and
// the spec. While giving such relation, all rightmost hashes are recovered.
// Note that `MT?.rhs` after `construct_rhs` does NOT contain all rightmost
// hashes; it has partial rightmost hashes that are enough to calculate
// Merkle paths.
val log2: n:nat{n > 0} -> GTot (c:nat{pow2 c <= n && n < pow2 (c+1)})
let rec log2 n =
if n = 1 then 0
else 1 + log2 (n / 2)
val log2_bound:
n:nat{n > 0} -> c:nat{n < pow2 c} ->
Lemma (log2 n <= c-1)
let rec log2_bound n c =
if n = 1 then ()
else log2_bound (n / 2) (c - 1)
val log2_div:
n:nat{n > 1} ->
Lemma (log2 (n / 2) = log2 n - 1)
let log2_div n = ()
val log2c:
n:nat ->
GTot (c:nat{c = 0 || (pow2 (c-1) <= n && n < pow2 c)})
let log2c n =
if n = 0 then 0 else (log2 n + 1)
val log2c_div:
n:nat{n > 0} ->
Lemma (log2c (n / 2) = log2c n - 1)
let log2c_div n = ()
val log2c_bound:
n:nat -> c:nat{n < pow2 c} ->
Lemma (log2c n <= c)
let rec log2c_bound n c =
if n = 0 then ()
else log2c_bound (n / 2) (c - 1)
val mt_hashes_lth_inv_log:
#hsz:pos ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
GTot Type0 (decreases j)
let rec mt_hashes_lth_inv_log #hsz j fhs =
if j = 0 then true
else (S.length (S.head fhs) == j /\
mt_hashes_lth_inv_log #hsz (j / 2) (S.tail fhs))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_lth_inv_log_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
Lemma (requires mt_hashes_lth_inv_log #hsz j fhs)
(ensures S.length (S.head fhs) == j /\
S.length (S.head (S.tail fhs)) == j / 2)
let mt_hashes_lth_inv_log_next #_ #_ _ _ = ()
val mt_hashes_inv_log:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j /\ mt_hashes_lth_inv_log #hsz j fhs} ->
GTot Type0 (decreases j)
let rec mt_hashes_inv_log #hsz #f j fhs =
if j <= 1 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs 0) (S.index fhs 1) /\
mt_hashes_inv_log #_ #f (j / 2) (S.tail fhs))
val mt_hashes_lth_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log #hsz j (S.slice fhs lv (lv + log2c j))))
(decreases j)
let rec mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs =
if j = 0 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log #hsz j (S.slice fhs 0 (log2c j))))
let mt_hashes_lth_inv_log_converted #_ #f j fhs =
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs
val mt_hashes_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j > 0 && j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz lv j fhs} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs lv (lv + log2c j))))
(decreases j)
#pop-options
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
let rec mt_hashes_inv_log_converted_ #_ #f lv j fhs =
if j = 1 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs;
mt_hashes_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
#pop-options
val mt_hashes_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 0 && j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz 0 j fhs} ->
Lemma (requires mt_hashes_inv #_ #f 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs 0 (log2c j))))
let mt_hashes_inv_log_converted #_ #f j fhs =
mt_hashes_inv_log_converted_ #_ #f 0 j fhs
val hash_seq_lift:
#hsz:pos ->
hs:hashes #hsz ->
GTot (shs:MTS.hashes #hsz {S.length shs = S.length hs})
(decreases (S.length hs))
let rec hash_seq_lift #hsz hs =
if S.length hs = 0 then S.empty
else S.cons (MTS.HRaw (S.head hs)) (hash_seq_lift #hsz (S.tail hs))
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
val hash_seq_lift_index:
#hsz:pos ->
hs:hashes #hsz ->
Lemma (requires True)
(ensures forall (i:nat{i < S.length hs}).
S.index (hash_seq_lift #hsz hs) i == MTS.HRaw (S.index hs i))
(decreases (S.length hs))
let rec hash_seq_lift_index #hsz hs =
if S.length hs = 0 then ()
else hash_seq_lift_index #hsz (S.tail hs)
#pop-options
val create_pads: #hsz:pos -> len:nat -> GTot (pads:MTS.hashes #hsz {S.length pads = len})
let create_pads #hsz len = S.create len (MTS.HPad #hsz)
val hash_seq_spec:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
GTot (MTS.merkle_tree #hsz (log2c (S.length hs)))
let hash_seq_spec #hsz hs =
S.append (hash_seq_lift #hsz hs)
(create_pads (pow2 (log2c (S.length hs)) - S.length hs))
val hash_seq_spec_index_raw:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
i:nat{i < S.length hs} ->
Lemma (S.index (hash_seq_spec #hsz hs) i == MTS.HRaw #hsz (S.index hs i))
let hash_seq_spec_index_raw #hsz hs i =
hash_seq_lift_index #hsz hs
// Now about recovering rightmost hashes
#push-options "--z3rlimit 50 --initial_fuel 1 --max_fuel 1"
val mt_hashes_next_rel_lift_even:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures MTS.mt_next_rel #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs))
let mt_hashes_next_rel_lift_even #hsz #_ j hs nhs =
hash_seq_lift_index #hsz hs;
hash_seq_lift_index #hsz nhs
val mt_hashes_next_rel_lift_odd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 1 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures MTS.mt_next_rel #_ #f (log2c j)
(hash_seq_spec #hsz hs)
(S.upd (hash_seq_spec #hsz nhs)
(S.length nhs) (MTS.HRaw (S.last hs))))
let mt_hashes_next_rel_lift_odd #hsz #_ j hs nhs =
log2c_div j;
hash_seq_lift_index #hsz hs;
hash_seq_lift_index #hsz nhs
val mt_hashes_next_rel_next_even:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures S.equal (hash_seq_spec #hsz nhs)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec #hsz hs)))
let mt_hashes_next_rel_next_even #hsz #f j hs nhs =
log2c_div j;
mt_hashes_next_rel_lift_even #_ #f j hs nhs;
MTS.mt_next_rel_next_lv #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs)
val hash_seq_spec_full:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs:hashes #hsz {S.length hs > 0} ->
acc:hash #hsz -> actd:bool ->
GTot (MTS.merkle_tree #hsz (log2c (S.length hs)))
let hash_seq_spec_full #hsz #f hs acc actd =
if actd
then (S.upd (hash_seq_spec #hsz hs) (S.length hs) (MTS.HRaw acc))
else hash_seq_spec #hsz hs
val hash_seq_spec_full_index_raw:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs:hashes #hsz {S.length hs > 0} ->
acc:hash #hsz -> actd:bool -> i:nat{i < S.length hs} ->
Lemma (S.index (hash_seq_spec_full #_ #f hs acc actd) i ==
MTS.HRaw (S.index hs i))
let hash_seq_spec_full_index_raw #hsz #_ hs acc actd i =
hash_seq_spec_index_raw #hsz hs i
val hash_seq_spec_full_case_true:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs:hashes #hsz {S.length hs > 0} -> acc:hash #hsz ->
Lemma (S.index (hash_seq_spec_full #_ #f hs acc true) (S.length hs) == MTS.HRaw acc)
let hash_seq_spec_full_case_true #_ #_ _ _ = ()
val hash_seq_spec_full_even_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 0} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
acc:hash #hsz -> actd:bool ->
Lemma
(requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures S.equal (hash_seq_spec_full #_ #f nhs acc actd)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f hs acc actd)))
#restart-solver
#push-options "--quake 1/3 --z3rlimit 100 --fuel 2 --ifuel 1"
let hash_seq_spec_full_even_next #hsz #f j hs nhs acc actd =
log2c_div j;
mt_hashes_next_rel_lift_even #_ #f j hs nhs;
if actd
then begin
MTS.mt_next_rel_upd_even_pad #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs) (S.length hs / 2) (MTS.HRaw acc);
let n = log2c j in
let mt = S.upd (hash_seq_spec #hsz hs) (S.length hs) (MTS.HRaw acc) in
let nmt = S.upd (hash_seq_spec #hsz nhs) (S.length nhs) (MTS.HRaw acc) in
// assume (MTS.mt_next_rel #_ #f n mt nmt);
MTS.mt_next_rel_next_lv #_ #f n mt nmt
end
else MTS.mt_next_rel_next_lv #_ #f (log2c j)
(hash_seq_spec_full #_ #f hs acc actd)
(hash_seq_spec_full #_ #f nhs acc actd)
#pop-options
#push-options "--z3rlimit 80"
val hash_seq_spec_full_odd_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
acc:hash #hsz -> actd:bool -> nacc:hash #hsz ->
Lemma
(requires j % 2 = 1 /\
mt_hashes_next_rel #_ #f j hs nhs /\
nacc == (if actd then f (S.last hs) acc else S.last hs))
(ensures S.equal (hash_seq_spec_full #_ #f nhs nacc true)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f hs acc actd)))
let hash_seq_spec_full_odd_next #hsz #f j hs nhs acc actd nacc =
log2c_div j;
mt_hashes_next_rel_lift_odd #_ #f j hs nhs;
if actd
then begin
MTS.mt_next_rel_upd_odd #_ #f (log2c j)
(hash_seq_spec #hsz hs)
(S.upd (hash_seq_spec #hsz nhs) (S.length nhs) (MTS.HRaw (S.last hs)))
(S.length nhs) (MTS.HRaw acc);
MTS.mt_next_rel_next_lv #_ #f (log2c j)
(S.upd (hash_seq_spec #hsz hs) (S.length hs) (MTS.HRaw acc))
(S.upd (hash_seq_spec #hsz nhs) (S.length nhs) (MTS.HRaw (f (S.last hs) acc)))
end
else MTS.mt_next_rel_next_lv #_ #f (log2c j)
(hash_seq_spec_full #_ #f hs acc actd)
(hash_seq_spec_full #_ #f nhs nacc true)
#pop-options
val hash_seq_spec_full_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
acc:hash #hsz -> actd:bool -> nacc:hash #hsz -> nactd:bool ->
Lemma
(requires mt_hashes_next_rel #_ #f j hs nhs /\
nacc == (if j % 2 = 0 then acc
else if actd
then f (S.last hs) acc
else S.last hs) /\
nactd == (actd || j % 2 = 1))
(ensures S.equal (hash_seq_spec_full #_ #f nhs nacc nactd)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f hs acc actd)))
let hash_seq_spec_full_next #_ #f j hs nhs acc actd nacc nactd =
if j % 2 = 0
then hash_seq_spec_full_even_next #_ #f j hs nhs acc actd
else hash_seq_spec_full_odd_next #_ #f j hs nhs acc actd nacc
val mt_rhs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
smt:MTS.merkle_tree #hsz (log2c j) ->
rhs:hashes #hsz {S.length rhs = log2c j} ->
actd:bool ->
GTot Type0 (decreases j)
let rec mt_rhs_inv #_ #f j smt rhs actd =
if j = 0 then true
else begin
(if j % 2 = 1 && actd
then (S.index smt j == MTS.HRaw (S.head rhs))
else true) /\
mt_rhs_inv #_ #f (j / 2) (MTS.mt_next_lv #_ #f #(log2c j) smt) (S.tail rhs)
(actd || (j % 2 = 1))
end
val mt_root_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs0:hashes #hsz {S.length hs0 > 0} ->
acc:hash #hsz -> actd:bool ->
rt:hash #hsz ->
GTot Type0
let mt_root_inv #_ #f hs0 acc actd rt =
MTS.mt_get_root #_ #f #(log2c (S.length hs0))
(hash_seq_spec_full #_ #f hs0 acc actd) == MTS.HRaw rt
val mt_base:
#hsz:pos ->
mt:merkle_tree #hsz {mt_wf_elts mt} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz 0 (MT?.i mt) olds} ->
GTot (bhs:hashes #hsz {S.length bhs = MT?.j mt})
let mt_base #hsz mt olds =
S.head (merge_hs #hsz #(MT?.hash_fun mt) olds (MT?.hs mt))
#pop-options // --max_fuel 1
val mt_spec:
#hsz:pos ->
mt:merkle_tree #hsz {mt_wf_elts mt /\ MT?.j mt > 0} ->
olds:hashess{S.length olds = 32 /\ mt_olds_inv #hsz 0 (MT?.i mt) olds} ->
GTot (MTS.merkle_tree #hsz (log2c (MT?.j mt))) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mt_spec:
#hsz:pos ->
mt:merkle_tree #hsz {mt_wf_elts mt /\ MT?.j mt > 0} ->
olds:hashess{S.length olds = 32 /\ mt_olds_inv #hsz 0 (MT?.i mt) olds} ->
GTot (MTS.merkle_tree #hsz (log2c (MT?.j mt))) | [] | MerkleTree.New.High.Correct.Base.mt_spec | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
mt: MerkleTree.New.High.merkle_tree{MerkleTree.New.High.mt_wf_elts mt /\ MT?.j mt > 0} ->
olds:
MerkleTree.New.High.hashess
{ FStar.Seq.Base.length olds = 32 /\
MerkleTree.New.High.Correct.Base.mt_olds_inv 0 (MT?.i mt) olds }
-> Prims.GTot (MerkleTree.Spec.merkle_tree (MerkleTree.New.High.Correct.Base.log2c (MT?.j mt))) | {
"end_col": 36,
"end_line": 640,
"start_col": 2,
"start_line": 640
} |
Prims.GTot | val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0 | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1)) | val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs = | false | null | false | forall (i: nat{i < j / 2}).
S.index nhs i == f (S.index hs (op_Multiply 2 i)) (S.index hs (op_Multiply 2 i + 1)) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"sometrivial"
] | [
"Prims.pos",
"MerkleTree.Spec.hash_fun_t",
"Prims.nat",
"MerkleTree.New.High.hashes",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hash",
"Prims.int",
"Prims.op_Division",
"Prims.l_Forall",
"Prims.op_LessThan",
"Prims.eq2",
"Spec.Hash.Definitions.bytes",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"Prims.op_GreaterThan",
"Lib.IntTypes.uint8",
"FStar.Seq.Base.index",
"Prims.op_Multiply",
"Prims.op_Addition"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0 | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0 | [] | MerkleTree.New.High.Correct.Base.mt_hashes_next_rel | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
j: Prims.nat ->
hs: MerkleTree.New.High.hashes{FStar.Seq.Base.length hs = j} ->
nhs: MerkleTree.New.High.hashes{FStar.Seq.Base.length nhs = j / 2}
-> Prims.GTot Type0 | {
"end_col": 45,
"end_line": 87,
"start_col": 2,
"start_line": 84
} |
Prims.GTot | val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len}) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let empty_hashes #hsz len = S.create len S.empty | val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = | false | null | false | S.create len S.empty | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"sometrivial"
] | [
"Prims.pos",
"Prims.nat",
"FStar.Seq.Base.create",
"MerkleTree.New.High.hashes",
"FStar.Seq.Base.empty",
"MerkleTree.New.High.hash",
"MerkleTree.New.High.hashess",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Seq.Base.length"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len}) | [] | MerkleTree.New.High.Correct.Base.empty_hashes | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | len: Prims.nat -> Prims.GTot (hs: MerkleTree.New.High.hashess{FStar.Seq.Base.length hs = len}) | {
"end_col": 48,
"end_line": 40,
"start_col": 28,
"start_line": 40
} |
Prims.GTot | val mt_inv:
#hsz:pos ->
mt:merkle_tree #hsz {mt_wf_elts mt} ->
olds:hashess{S.length olds = 32 /\ mt_olds_inv #hsz 0 (MT?.i mt) olds} ->
GTot Type0 | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mt_inv #hsz mt olds =
let i = MT?.i mt in
let j = MT?.j mt in
let hs = MT?.hs mt in
let rhs = MT?.rhs mt in
let f = MT?.hash_fun mt in
let fhs = merge_hs #hsz #f olds hs in
let rt = MT?.mroot mt in
log2c_bound j 32;
mt_olds_hs_inv #_ #f 0 i j olds hs /\
(if j > 0 && MT?.rhs_ok mt
then (mt_olds_hs_lth_inv_ok #_ #f 0 i j olds hs;
mt_hashes_lth_inv_log_converted #_ #f j fhs;
(mt_rhs_inv #_ #f j (mt_spec mt olds) (S.slice rhs 0 (log2c j)) false /\
mt_root_inv #_ #f (mt_base mt olds) hash_init false rt))
else true) | val mt_inv:
#hsz:pos ->
mt:merkle_tree #hsz {mt_wf_elts mt} ->
olds:hashess{S.length olds = 32 /\ mt_olds_inv #hsz 0 (MT?.i mt) olds} ->
GTot Type0
let mt_inv #hsz mt olds = | false | null | false | let i = MT?.i mt in
let j = MT?.j mt in
let hs = MT?.hs mt in
let rhs = MT?.rhs mt in
let f = MT?.hash_fun mt in
let fhs = merge_hs #hsz #f olds hs in
let rt = MT?.mroot mt in
log2c_bound j 32;
mt_olds_hs_inv #_ #f 0 i j olds hs /\
(if j > 0 && MT?.rhs_ok mt
then
(mt_olds_hs_lth_inv_ok #_ #f 0 i j olds hs;
mt_hashes_lth_inv_log_converted #_ #f j fhs;
(mt_rhs_inv #_ #f j (mt_spec mt olds) (S.slice rhs 0 (log2c j)) false /\
mt_root_inv #_ #f (mt_base mt olds) hash_init false rt))
else true) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"sometrivial"
] | [
"Prims.pos",
"MerkleTree.New.High.merkle_tree",
"MerkleTree.New.High.mt_wf_elts",
"MerkleTree.New.High.hashess",
"Prims.l_and",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hashes",
"MerkleTree.New.High.Correct.Base.mt_olds_inv",
"MerkleTree.New.High.__proj__MT__item__i",
"MerkleTree.New.High.Correct.Base.mt_olds_hs_inv",
"Prims.op_AmpAmp",
"Prims.op_GreaterThan",
"MerkleTree.New.High.__proj__MT__item__rhs_ok",
"MerkleTree.New.High.Correct.Base.mt_rhs_inv",
"MerkleTree.New.High.Correct.Base.mt_spec",
"FStar.Seq.Base.slice",
"MerkleTree.New.High.hash",
"MerkleTree.New.High.Correct.Base.log2c",
"MerkleTree.New.High.Correct.Base.mt_root_inv",
"MerkleTree.New.High.Correct.Base.mt_base",
"MerkleTree.New.High.hash_init",
"Prims.unit",
"MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv_log_converted",
"MerkleTree.New.High.Correct.Base.mt_olds_hs_lth_inv_ok",
"Prims.bool",
"Prims.logical",
"MerkleTree.New.High.Correct.Base.log2c_bound",
"MerkleTree.New.High.__proj__MT__item__mroot",
"Prims.nat",
"MerkleTree.New.High.Correct.Base.merge_hs",
"MerkleTree.Spec.hash_fun_t",
"MerkleTree.New.High.__proj__MT__item__hash_fun",
"MerkleTree.New.High.__proj__MT__item__rhs",
"MerkleTree.New.High.__proj__MT__item__hs",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.pow2",
"MerkleTree.New.High.__proj__MT__item__j"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j)
val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i)
let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2
val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_olds_inv #hsz lv i olds =
if lv = 32 then true
else (let ofs = offset_of i in
S.length (S.index olds lv) == ofs /\
mt_olds_inv #hsz (lv + 1) (i / 2) olds)
val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv))
let rec mt_olds_inv_equiv #hsz #f lv i olds1 olds2 =
if lv = 32 then ()
else (assert (S.index olds1 lv == S.index olds2 lv);
mt_olds_inv_equiv #_ #f (lv + 1) (i / 2) olds1 olds2)
val mt_olds_hs_lth_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs))
(decreases (32 - lv))
let rec mt_olds_hs_lth_inv_ok #hsz #f lv i j olds hs =
if lv = 32 then ()
else (mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs)
val mt_olds_hs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
GTot Type0
let mt_olds_hs_inv #hsz #f lv i j olds hs =
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs)
// Relation between valid internal hashes (satisfying `mt_olds_hs_inv`) and
// the spec. While giving such relation, all rightmost hashes are recovered.
// Note that `MT?.rhs` after `construct_rhs` does NOT contain all rightmost
// hashes; it has partial rightmost hashes that are enough to calculate
// Merkle paths.
val log2: n:nat{n > 0} -> GTot (c:nat{pow2 c <= n && n < pow2 (c+1)})
let rec log2 n =
if n = 1 then 0
else 1 + log2 (n / 2)
val log2_bound:
n:nat{n > 0} -> c:nat{n < pow2 c} ->
Lemma (log2 n <= c-1)
let rec log2_bound n c =
if n = 1 then ()
else log2_bound (n / 2) (c - 1)
val log2_div:
n:nat{n > 1} ->
Lemma (log2 (n / 2) = log2 n - 1)
let log2_div n = ()
val log2c:
n:nat ->
GTot (c:nat{c = 0 || (pow2 (c-1) <= n && n < pow2 c)})
let log2c n =
if n = 0 then 0 else (log2 n + 1)
val log2c_div:
n:nat{n > 0} ->
Lemma (log2c (n / 2) = log2c n - 1)
let log2c_div n = ()
val log2c_bound:
n:nat -> c:nat{n < pow2 c} ->
Lemma (log2c n <= c)
let rec log2c_bound n c =
if n = 0 then ()
else log2c_bound (n / 2) (c - 1)
val mt_hashes_lth_inv_log:
#hsz:pos ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
GTot Type0 (decreases j)
let rec mt_hashes_lth_inv_log #hsz j fhs =
if j = 0 then true
else (S.length (S.head fhs) == j /\
mt_hashes_lth_inv_log #hsz (j / 2) (S.tail fhs))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_lth_inv_log_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
Lemma (requires mt_hashes_lth_inv_log #hsz j fhs)
(ensures S.length (S.head fhs) == j /\
S.length (S.head (S.tail fhs)) == j / 2)
let mt_hashes_lth_inv_log_next #_ #_ _ _ = ()
val mt_hashes_inv_log:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j /\ mt_hashes_lth_inv_log #hsz j fhs} ->
GTot Type0 (decreases j)
let rec mt_hashes_inv_log #hsz #f j fhs =
if j <= 1 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs 0) (S.index fhs 1) /\
mt_hashes_inv_log #_ #f (j / 2) (S.tail fhs))
val mt_hashes_lth_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log #hsz j (S.slice fhs lv (lv + log2c j))))
(decreases j)
let rec mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs =
if j = 0 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log #hsz j (S.slice fhs 0 (log2c j))))
let mt_hashes_lth_inv_log_converted #_ #f j fhs =
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs
val mt_hashes_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j > 0 && j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz lv j fhs} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs lv (lv + log2c j))))
(decreases j)
#pop-options
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
let rec mt_hashes_inv_log_converted_ #_ #f lv j fhs =
if j = 1 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs;
mt_hashes_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
#pop-options
val mt_hashes_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 0 && j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz 0 j fhs} ->
Lemma (requires mt_hashes_inv #_ #f 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs 0 (log2c j))))
let mt_hashes_inv_log_converted #_ #f j fhs =
mt_hashes_inv_log_converted_ #_ #f 0 j fhs
val hash_seq_lift:
#hsz:pos ->
hs:hashes #hsz ->
GTot (shs:MTS.hashes #hsz {S.length shs = S.length hs})
(decreases (S.length hs))
let rec hash_seq_lift #hsz hs =
if S.length hs = 0 then S.empty
else S.cons (MTS.HRaw (S.head hs)) (hash_seq_lift #hsz (S.tail hs))
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
val hash_seq_lift_index:
#hsz:pos ->
hs:hashes #hsz ->
Lemma (requires True)
(ensures forall (i:nat{i < S.length hs}).
S.index (hash_seq_lift #hsz hs) i == MTS.HRaw (S.index hs i))
(decreases (S.length hs))
let rec hash_seq_lift_index #hsz hs =
if S.length hs = 0 then ()
else hash_seq_lift_index #hsz (S.tail hs)
#pop-options
val create_pads: #hsz:pos -> len:nat -> GTot (pads:MTS.hashes #hsz {S.length pads = len})
let create_pads #hsz len = S.create len (MTS.HPad #hsz)
val hash_seq_spec:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
GTot (MTS.merkle_tree #hsz (log2c (S.length hs)))
let hash_seq_spec #hsz hs =
S.append (hash_seq_lift #hsz hs)
(create_pads (pow2 (log2c (S.length hs)) - S.length hs))
val hash_seq_spec_index_raw:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
i:nat{i < S.length hs} ->
Lemma (S.index (hash_seq_spec #hsz hs) i == MTS.HRaw #hsz (S.index hs i))
let hash_seq_spec_index_raw #hsz hs i =
hash_seq_lift_index #hsz hs
// Now about recovering rightmost hashes
#push-options "--z3rlimit 50 --initial_fuel 1 --max_fuel 1"
val mt_hashes_next_rel_lift_even:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures MTS.mt_next_rel #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs))
let mt_hashes_next_rel_lift_even #hsz #_ j hs nhs =
hash_seq_lift_index #hsz hs;
hash_seq_lift_index #hsz nhs
val mt_hashes_next_rel_lift_odd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 1 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures MTS.mt_next_rel #_ #f (log2c j)
(hash_seq_spec #hsz hs)
(S.upd (hash_seq_spec #hsz nhs)
(S.length nhs) (MTS.HRaw (S.last hs))))
let mt_hashes_next_rel_lift_odd #hsz #_ j hs nhs =
log2c_div j;
hash_seq_lift_index #hsz hs;
hash_seq_lift_index #hsz nhs
val mt_hashes_next_rel_next_even:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures S.equal (hash_seq_spec #hsz nhs)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec #hsz hs)))
let mt_hashes_next_rel_next_even #hsz #f j hs nhs =
log2c_div j;
mt_hashes_next_rel_lift_even #_ #f j hs nhs;
MTS.mt_next_rel_next_lv #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs)
val hash_seq_spec_full:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs:hashes #hsz {S.length hs > 0} ->
acc:hash #hsz -> actd:bool ->
GTot (MTS.merkle_tree #hsz (log2c (S.length hs)))
let hash_seq_spec_full #hsz #f hs acc actd =
if actd
then (S.upd (hash_seq_spec #hsz hs) (S.length hs) (MTS.HRaw acc))
else hash_seq_spec #hsz hs
val hash_seq_spec_full_index_raw:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs:hashes #hsz {S.length hs > 0} ->
acc:hash #hsz -> actd:bool -> i:nat{i < S.length hs} ->
Lemma (S.index (hash_seq_spec_full #_ #f hs acc actd) i ==
MTS.HRaw (S.index hs i))
let hash_seq_spec_full_index_raw #hsz #_ hs acc actd i =
hash_seq_spec_index_raw #hsz hs i
val hash_seq_spec_full_case_true:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs:hashes #hsz {S.length hs > 0} -> acc:hash #hsz ->
Lemma (S.index (hash_seq_spec_full #_ #f hs acc true) (S.length hs) == MTS.HRaw acc)
let hash_seq_spec_full_case_true #_ #_ _ _ = ()
val hash_seq_spec_full_even_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 0} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
acc:hash #hsz -> actd:bool ->
Lemma
(requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures S.equal (hash_seq_spec_full #_ #f nhs acc actd)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f hs acc actd)))
#restart-solver
#push-options "--quake 1/3 --z3rlimit 100 --fuel 2 --ifuel 1"
let hash_seq_spec_full_even_next #hsz #f j hs nhs acc actd =
log2c_div j;
mt_hashes_next_rel_lift_even #_ #f j hs nhs;
if actd
then begin
MTS.mt_next_rel_upd_even_pad #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs) (S.length hs / 2) (MTS.HRaw acc);
let n = log2c j in
let mt = S.upd (hash_seq_spec #hsz hs) (S.length hs) (MTS.HRaw acc) in
let nmt = S.upd (hash_seq_spec #hsz nhs) (S.length nhs) (MTS.HRaw acc) in
// assume (MTS.mt_next_rel #_ #f n mt nmt);
MTS.mt_next_rel_next_lv #_ #f n mt nmt
end
else MTS.mt_next_rel_next_lv #_ #f (log2c j)
(hash_seq_spec_full #_ #f hs acc actd)
(hash_seq_spec_full #_ #f nhs acc actd)
#pop-options
#push-options "--z3rlimit 80"
val hash_seq_spec_full_odd_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
acc:hash #hsz -> actd:bool -> nacc:hash #hsz ->
Lemma
(requires j % 2 = 1 /\
mt_hashes_next_rel #_ #f j hs nhs /\
nacc == (if actd then f (S.last hs) acc else S.last hs))
(ensures S.equal (hash_seq_spec_full #_ #f nhs nacc true)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f hs acc actd)))
let hash_seq_spec_full_odd_next #hsz #f j hs nhs acc actd nacc =
log2c_div j;
mt_hashes_next_rel_lift_odd #_ #f j hs nhs;
if actd
then begin
MTS.mt_next_rel_upd_odd #_ #f (log2c j)
(hash_seq_spec #hsz hs)
(S.upd (hash_seq_spec #hsz nhs) (S.length nhs) (MTS.HRaw (S.last hs)))
(S.length nhs) (MTS.HRaw acc);
MTS.mt_next_rel_next_lv #_ #f (log2c j)
(S.upd (hash_seq_spec #hsz hs) (S.length hs) (MTS.HRaw acc))
(S.upd (hash_seq_spec #hsz nhs) (S.length nhs) (MTS.HRaw (f (S.last hs) acc)))
end
else MTS.mt_next_rel_next_lv #_ #f (log2c j)
(hash_seq_spec_full #_ #f hs acc actd)
(hash_seq_spec_full #_ #f nhs nacc true)
#pop-options
val hash_seq_spec_full_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
acc:hash #hsz -> actd:bool -> nacc:hash #hsz -> nactd:bool ->
Lemma
(requires mt_hashes_next_rel #_ #f j hs nhs /\
nacc == (if j % 2 = 0 then acc
else if actd
then f (S.last hs) acc
else S.last hs) /\
nactd == (actd || j % 2 = 1))
(ensures S.equal (hash_seq_spec_full #_ #f nhs nacc nactd)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f hs acc actd)))
let hash_seq_spec_full_next #_ #f j hs nhs acc actd nacc nactd =
if j % 2 = 0
then hash_seq_spec_full_even_next #_ #f j hs nhs acc actd
else hash_seq_spec_full_odd_next #_ #f j hs nhs acc actd nacc
val mt_rhs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
smt:MTS.merkle_tree #hsz (log2c j) ->
rhs:hashes #hsz {S.length rhs = log2c j} ->
actd:bool ->
GTot Type0 (decreases j)
let rec mt_rhs_inv #_ #f j smt rhs actd =
if j = 0 then true
else begin
(if j % 2 = 1 && actd
then (S.index smt j == MTS.HRaw (S.head rhs))
else true) /\
mt_rhs_inv #_ #f (j / 2) (MTS.mt_next_lv #_ #f #(log2c j) smt) (S.tail rhs)
(actd || (j % 2 = 1))
end
val mt_root_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs0:hashes #hsz {S.length hs0 > 0} ->
acc:hash #hsz -> actd:bool ->
rt:hash #hsz ->
GTot Type0
let mt_root_inv #_ #f hs0 acc actd rt =
MTS.mt_get_root #_ #f #(log2c (S.length hs0))
(hash_seq_spec_full #_ #f hs0 acc actd) == MTS.HRaw rt
val mt_base:
#hsz:pos ->
mt:merkle_tree #hsz {mt_wf_elts mt} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz 0 (MT?.i mt) olds} ->
GTot (bhs:hashes #hsz {S.length bhs = MT?.j mt})
let mt_base #hsz mt olds =
S.head (merge_hs #hsz #(MT?.hash_fun mt) olds (MT?.hs mt))
#pop-options // --max_fuel 1
val mt_spec:
#hsz:pos ->
mt:merkle_tree #hsz {mt_wf_elts mt /\ MT?.j mt > 0} ->
olds:hashess{S.length olds = 32 /\ mt_olds_inv #hsz 0 (MT?.i mt) olds} ->
GTot (MTS.merkle_tree #hsz (log2c (MT?.j mt)))
let mt_spec #hsz mt olds =
hash_seq_spec #_ (mt_base mt olds)
val mt_inv:
#hsz:pos ->
mt:merkle_tree #hsz {mt_wf_elts mt} ->
olds:hashess{S.length olds = 32 /\ mt_olds_inv #hsz 0 (MT?.i mt) olds} -> | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mt_inv:
#hsz:pos ->
mt:merkle_tree #hsz {mt_wf_elts mt} ->
olds:hashess{S.length olds = 32 /\ mt_olds_inv #hsz 0 (MT?.i mt) olds} ->
GTot Type0 | [] | MerkleTree.New.High.Correct.Base.mt_inv | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
mt: MerkleTree.New.High.merkle_tree{MerkleTree.New.High.mt_wf_elts mt} ->
olds:
MerkleTree.New.High.hashess
{ FStar.Seq.Base.length olds = 32 /\
MerkleTree.New.High.Correct.Base.mt_olds_inv 0 (MT?.i mt) olds }
-> Prims.GTot Type0 | {
"end_col": 12,
"end_line": 662,
"start_col": 25,
"start_line": 647
} |
FStar.Pervasives.Lemma | val log2_bound:
n:nat{n > 0} -> c:nat{n < pow2 c} ->
Lemma (log2 n <= c-1) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec log2_bound n c =
if n = 1 then ()
else log2_bound (n / 2) (c - 1) | val log2_bound:
n:nat{n > 0} -> c:nat{n < pow2 c} ->
Lemma (log2 n <= c-1)
let rec log2_bound n c = | false | null | true | if n = 1 then () else log2_bound (n / 2) (c - 1) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"lemma"
] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_GreaterThan",
"Prims.op_LessThan",
"Prims.pow2",
"Prims.op_Equality",
"Prims.int",
"Prims.bool",
"MerkleTree.New.High.Correct.Base.log2_bound",
"Prims.op_Division",
"Prims.op_Subtraction",
"Prims.unit"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j)
val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i)
let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2
val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_olds_inv #hsz lv i olds =
if lv = 32 then true
else (let ofs = offset_of i in
S.length (S.index olds lv) == ofs /\
mt_olds_inv #hsz (lv + 1) (i / 2) olds)
val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv))
let rec mt_olds_inv_equiv #hsz #f lv i olds1 olds2 =
if lv = 32 then ()
else (assert (S.index olds1 lv == S.index olds2 lv);
mt_olds_inv_equiv #_ #f (lv + 1) (i / 2) olds1 olds2)
val mt_olds_hs_lth_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs))
(decreases (32 - lv))
let rec mt_olds_hs_lth_inv_ok #hsz #f lv i j olds hs =
if lv = 32 then ()
else (mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs)
val mt_olds_hs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
GTot Type0
let mt_olds_hs_inv #hsz #f lv i j olds hs =
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs)
// Relation between valid internal hashes (satisfying `mt_olds_hs_inv`) and
// the spec. While giving such relation, all rightmost hashes are recovered.
// Note that `MT?.rhs` after `construct_rhs` does NOT contain all rightmost
// hashes; it has partial rightmost hashes that are enough to calculate
// Merkle paths.
val log2: n:nat{n > 0} -> GTot (c:nat{pow2 c <= n && n < pow2 (c+1)})
let rec log2 n =
if n = 1 then 0
else 1 + log2 (n / 2)
val log2_bound:
n:nat{n > 0} -> c:nat{n < pow2 c} ->
Lemma (log2 n <= c-1) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val log2_bound:
n:nat{n > 0} -> c:nat{n < pow2 c} ->
Lemma (log2 n <= c-1) | [
"recursion"
] | MerkleTree.New.High.Correct.Base.log2_bound | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | n: Prims.nat{n > 0} -> c: Prims.nat{n < Prims.pow2 c}
-> FStar.Pervasives.Lemma (ensures MerkleTree.New.High.Correct.Base.log2 n <= c - 1) | {
"end_col": 33,
"end_line": 293,
"start_col": 2,
"start_line": 292
} |
Prims.GTot | val hash_seq_spec:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
GTot (MTS.merkle_tree #hsz (log2c (S.length hs))) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_seq_spec #hsz hs =
S.append (hash_seq_lift #hsz hs)
(create_pads (pow2 (log2c (S.length hs)) - S.length hs)) | val hash_seq_spec:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
GTot (MTS.merkle_tree #hsz (log2c (S.length hs)))
let hash_seq_spec #hsz hs = | false | null | false | S.append (hash_seq_lift #hsz hs) (create_pads (pow2 (log2c (S.length hs)) - S.length hs)) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"sometrivial"
] | [
"Prims.pos",
"MerkleTree.New.High.hashes",
"Prims.b2t",
"Prims.op_GreaterThan",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hash",
"FStar.Seq.Base.append",
"MerkleTree.Spec.padded_hash",
"MerkleTree.New.High.Correct.Base.hash_seq_lift",
"MerkleTree.New.High.Correct.Base.create_pads",
"Prims.op_Subtraction",
"Prims.pow2",
"MerkleTree.New.High.Correct.Base.log2c",
"MerkleTree.Spec.merkle_tree"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j)
val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i)
let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2
val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_olds_inv #hsz lv i olds =
if lv = 32 then true
else (let ofs = offset_of i in
S.length (S.index olds lv) == ofs /\
mt_olds_inv #hsz (lv + 1) (i / 2) olds)
val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv))
let rec mt_olds_inv_equiv #hsz #f lv i olds1 olds2 =
if lv = 32 then ()
else (assert (S.index olds1 lv == S.index olds2 lv);
mt_olds_inv_equiv #_ #f (lv + 1) (i / 2) olds1 olds2)
val mt_olds_hs_lth_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs))
(decreases (32 - lv))
let rec mt_olds_hs_lth_inv_ok #hsz #f lv i j olds hs =
if lv = 32 then ()
else (mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs)
val mt_olds_hs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
GTot Type0
let mt_olds_hs_inv #hsz #f lv i j olds hs =
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs)
// Relation between valid internal hashes (satisfying `mt_olds_hs_inv`) and
// the spec. While giving such relation, all rightmost hashes are recovered.
// Note that `MT?.rhs` after `construct_rhs` does NOT contain all rightmost
// hashes; it has partial rightmost hashes that are enough to calculate
// Merkle paths.
val log2: n:nat{n > 0} -> GTot (c:nat{pow2 c <= n && n < pow2 (c+1)})
let rec log2 n =
if n = 1 then 0
else 1 + log2 (n / 2)
val log2_bound:
n:nat{n > 0} -> c:nat{n < pow2 c} ->
Lemma (log2 n <= c-1)
let rec log2_bound n c =
if n = 1 then ()
else log2_bound (n / 2) (c - 1)
val log2_div:
n:nat{n > 1} ->
Lemma (log2 (n / 2) = log2 n - 1)
let log2_div n = ()
val log2c:
n:nat ->
GTot (c:nat{c = 0 || (pow2 (c-1) <= n && n < pow2 c)})
let log2c n =
if n = 0 then 0 else (log2 n + 1)
val log2c_div:
n:nat{n > 0} ->
Lemma (log2c (n / 2) = log2c n - 1)
let log2c_div n = ()
val log2c_bound:
n:nat -> c:nat{n < pow2 c} ->
Lemma (log2c n <= c)
let rec log2c_bound n c =
if n = 0 then ()
else log2c_bound (n / 2) (c - 1)
val mt_hashes_lth_inv_log:
#hsz:pos ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
GTot Type0 (decreases j)
let rec mt_hashes_lth_inv_log #hsz j fhs =
if j = 0 then true
else (S.length (S.head fhs) == j /\
mt_hashes_lth_inv_log #hsz (j / 2) (S.tail fhs))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_lth_inv_log_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
Lemma (requires mt_hashes_lth_inv_log #hsz j fhs)
(ensures S.length (S.head fhs) == j /\
S.length (S.head (S.tail fhs)) == j / 2)
let mt_hashes_lth_inv_log_next #_ #_ _ _ = ()
val mt_hashes_inv_log:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j /\ mt_hashes_lth_inv_log #hsz j fhs} ->
GTot Type0 (decreases j)
let rec mt_hashes_inv_log #hsz #f j fhs =
if j <= 1 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs 0) (S.index fhs 1) /\
mt_hashes_inv_log #_ #f (j / 2) (S.tail fhs))
val mt_hashes_lth_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log #hsz j (S.slice fhs lv (lv + log2c j))))
(decreases j)
let rec mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs =
if j = 0 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log #hsz j (S.slice fhs 0 (log2c j))))
let mt_hashes_lth_inv_log_converted #_ #f j fhs =
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs
val mt_hashes_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j > 0 && j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz lv j fhs} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs lv (lv + log2c j))))
(decreases j)
#pop-options
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
let rec mt_hashes_inv_log_converted_ #_ #f lv j fhs =
if j = 1 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs;
mt_hashes_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
#pop-options
val mt_hashes_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 0 && j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz 0 j fhs} ->
Lemma (requires mt_hashes_inv #_ #f 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs 0 (log2c j))))
let mt_hashes_inv_log_converted #_ #f j fhs =
mt_hashes_inv_log_converted_ #_ #f 0 j fhs
val hash_seq_lift:
#hsz:pos ->
hs:hashes #hsz ->
GTot (shs:MTS.hashes #hsz {S.length shs = S.length hs})
(decreases (S.length hs))
let rec hash_seq_lift #hsz hs =
if S.length hs = 0 then S.empty
else S.cons (MTS.HRaw (S.head hs)) (hash_seq_lift #hsz (S.tail hs))
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
val hash_seq_lift_index:
#hsz:pos ->
hs:hashes #hsz ->
Lemma (requires True)
(ensures forall (i:nat{i < S.length hs}).
S.index (hash_seq_lift #hsz hs) i == MTS.HRaw (S.index hs i))
(decreases (S.length hs))
let rec hash_seq_lift_index #hsz hs =
if S.length hs = 0 then ()
else hash_seq_lift_index #hsz (S.tail hs)
#pop-options
val create_pads: #hsz:pos -> len:nat -> GTot (pads:MTS.hashes #hsz {S.length pads = len})
let create_pads #hsz len = S.create len (MTS.HPad #hsz)
val hash_seq_spec:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
GTot (MTS.merkle_tree #hsz (log2c (S.length hs))) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_seq_spec:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
GTot (MTS.merkle_tree #hsz (log2c (S.length hs))) | [] | MerkleTree.New.High.Correct.Base.hash_seq_spec | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | hs: MerkleTree.New.High.hashes{FStar.Seq.Base.length hs > 0}
-> Prims.GTot
(MerkleTree.Spec.merkle_tree (MerkleTree.New.High.Correct.Base.log2c (FStar.Seq.Base.length hs))
) | {
"end_col": 67,
"end_line": 435,
"start_col": 2,
"start_line": 434
} |
FStar.Pervasives.Lemma | val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len)) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1)) | val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len = | false | null | true | if len = 0
then ()
else
(empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty) (S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty (merge_hs #_ #f (empty_hashes (len - 1)) (empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1)) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"lemma"
] | [
"Prims.pos",
"MerkleTree.Spec.hash_fun_t",
"Prims.nat",
"Prims.op_Equality",
"Prims.int",
"Prims.bool",
"MerkleTree.New.High.Correct.Base.merge_hs_empty",
"Prims.op_Subtraction",
"Prims.unit",
"Prims._assert",
"FStar.Seq.Base.equal",
"MerkleTree.New.High.hashes",
"MerkleTree.New.High.Correct.Base.merge_hs",
"MerkleTree.New.High.Correct.Base.empty_hashes",
"FStar.Seq.Properties.cons",
"FStar.Seq.Base.empty",
"MerkleTree.New.High.hash",
"FStar.Seq.Base.append",
"MerkleTree.New.High.Correct.Base.empty_hashes_tail",
"MerkleTree.New.High.Correct.Base.empty_hashes_head"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len)) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len)) | [
"recursion"
] | MerkleTree.New.High.Correct.Base.merge_hs_empty | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | len: Prims.nat
-> FStar.Pervasives.Lemma
(ensures
FStar.Seq.Base.equal (MerkleTree.New.High.Correct.Base.merge_hs (MerkleTree.New.High.Correct.Base.empty_hashes
len)
(MerkleTree.New.High.Correct.Base.empty_hashes len))
(MerkleTree.New.High.Correct.Base.empty_hashes len)) | {
"end_col": 38,
"end_line": 173,
"start_col": 2,
"start_line": 164
} |
Prims.GTot | val create_pads: #hsz:pos -> len:nat -> GTot (pads:MTS.hashes #hsz {S.length pads = len}) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let create_pads #hsz len = S.create len (MTS.HPad #hsz) | val create_pads: #hsz:pos -> len:nat -> GTot (pads:MTS.hashes #hsz {S.length pads = len})
let create_pads #hsz len = | false | null | false | S.create len (MTS.HPad #hsz) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"sometrivial"
] | [
"Prims.pos",
"Prims.nat",
"FStar.Seq.Base.create",
"MerkleTree.Spec.padded_hash",
"MerkleTree.Spec.HPad",
"MerkleTree.Spec.hashes",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Seq.Base.length"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j)
val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i)
let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2
val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_olds_inv #hsz lv i olds =
if lv = 32 then true
else (let ofs = offset_of i in
S.length (S.index olds lv) == ofs /\
mt_olds_inv #hsz (lv + 1) (i / 2) olds)
val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv))
let rec mt_olds_inv_equiv #hsz #f lv i olds1 olds2 =
if lv = 32 then ()
else (assert (S.index olds1 lv == S.index olds2 lv);
mt_olds_inv_equiv #_ #f (lv + 1) (i / 2) olds1 olds2)
val mt_olds_hs_lth_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs))
(decreases (32 - lv))
let rec mt_olds_hs_lth_inv_ok #hsz #f lv i j olds hs =
if lv = 32 then ()
else (mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs)
val mt_olds_hs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
GTot Type0
let mt_olds_hs_inv #hsz #f lv i j olds hs =
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs)
// Relation between valid internal hashes (satisfying `mt_olds_hs_inv`) and
// the spec. While giving such relation, all rightmost hashes are recovered.
// Note that `MT?.rhs` after `construct_rhs` does NOT contain all rightmost
// hashes; it has partial rightmost hashes that are enough to calculate
// Merkle paths.
val log2: n:nat{n > 0} -> GTot (c:nat{pow2 c <= n && n < pow2 (c+1)})
let rec log2 n =
if n = 1 then 0
else 1 + log2 (n / 2)
val log2_bound:
n:nat{n > 0} -> c:nat{n < pow2 c} ->
Lemma (log2 n <= c-1)
let rec log2_bound n c =
if n = 1 then ()
else log2_bound (n / 2) (c - 1)
val log2_div:
n:nat{n > 1} ->
Lemma (log2 (n / 2) = log2 n - 1)
let log2_div n = ()
val log2c:
n:nat ->
GTot (c:nat{c = 0 || (pow2 (c-1) <= n && n < pow2 c)})
let log2c n =
if n = 0 then 0 else (log2 n + 1)
val log2c_div:
n:nat{n > 0} ->
Lemma (log2c (n / 2) = log2c n - 1)
let log2c_div n = ()
val log2c_bound:
n:nat -> c:nat{n < pow2 c} ->
Lemma (log2c n <= c)
let rec log2c_bound n c =
if n = 0 then ()
else log2c_bound (n / 2) (c - 1)
val mt_hashes_lth_inv_log:
#hsz:pos ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
GTot Type0 (decreases j)
let rec mt_hashes_lth_inv_log #hsz j fhs =
if j = 0 then true
else (S.length (S.head fhs) == j /\
mt_hashes_lth_inv_log #hsz (j / 2) (S.tail fhs))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_lth_inv_log_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
Lemma (requires mt_hashes_lth_inv_log #hsz j fhs)
(ensures S.length (S.head fhs) == j /\
S.length (S.head (S.tail fhs)) == j / 2)
let mt_hashes_lth_inv_log_next #_ #_ _ _ = ()
val mt_hashes_inv_log:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j /\ mt_hashes_lth_inv_log #hsz j fhs} ->
GTot Type0 (decreases j)
let rec mt_hashes_inv_log #hsz #f j fhs =
if j <= 1 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs 0) (S.index fhs 1) /\
mt_hashes_inv_log #_ #f (j / 2) (S.tail fhs))
val mt_hashes_lth_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log #hsz j (S.slice fhs lv (lv + log2c j))))
(decreases j)
let rec mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs =
if j = 0 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log #hsz j (S.slice fhs 0 (log2c j))))
let mt_hashes_lth_inv_log_converted #_ #f j fhs =
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs
val mt_hashes_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j > 0 && j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz lv j fhs} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs lv (lv + log2c j))))
(decreases j)
#pop-options
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
let rec mt_hashes_inv_log_converted_ #_ #f lv j fhs =
if j = 1 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs;
mt_hashes_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
#pop-options
val mt_hashes_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 0 && j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz 0 j fhs} ->
Lemma (requires mt_hashes_inv #_ #f 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs 0 (log2c j))))
let mt_hashes_inv_log_converted #_ #f j fhs =
mt_hashes_inv_log_converted_ #_ #f 0 j fhs
val hash_seq_lift:
#hsz:pos ->
hs:hashes #hsz ->
GTot (shs:MTS.hashes #hsz {S.length shs = S.length hs})
(decreases (S.length hs))
let rec hash_seq_lift #hsz hs =
if S.length hs = 0 then S.empty
else S.cons (MTS.HRaw (S.head hs)) (hash_seq_lift #hsz (S.tail hs))
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
val hash_seq_lift_index:
#hsz:pos ->
hs:hashes #hsz ->
Lemma (requires True)
(ensures forall (i:nat{i < S.length hs}).
S.index (hash_seq_lift #hsz hs) i == MTS.HRaw (S.index hs i))
(decreases (S.length hs))
let rec hash_seq_lift_index #hsz hs =
if S.length hs = 0 then ()
else hash_seq_lift_index #hsz (S.tail hs)
#pop-options | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val create_pads: #hsz:pos -> len:nat -> GTot (pads:MTS.hashes #hsz {S.length pads = len}) | [] | MerkleTree.New.High.Correct.Base.create_pads | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | len: Prims.nat -> Prims.GTot (pads: MerkleTree.Spec.hashes{FStar.Seq.Base.length pads = len}) | {
"end_col": 55,
"end_line": 427,
"start_col": 27,
"start_line": 427
} |
FStar.Pervasives.Lemma | val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv)) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1) | val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv = | false | null | true | if lv = 32 then () else mt_hashes_lth_inv_empty #hsz (lv + 1) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"lemma",
""
] | [
"Prims.pos",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Equality",
"Prims.int",
"Prims.bool",
"MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv_empty",
"Prims.op_Addition",
"Prims.unit"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv)) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv)) | [
"recursion"
] | MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv_empty | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | lv: Prims.nat{lv <= 32}
-> FStar.Pervasives.Lemma
(ensures
MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv lv
0
(MerkleTree.New.High.Correct.Base.empty_hashes 32)) (decreases 32 - lv) | {
"end_col": 44,
"end_line": 75,
"start_col": 2,
"start_line": 74
} |
Prims.GTot | val log2: n:nat{n > 0} -> GTot (c:nat{pow2 c <= n && n < pow2 (c+1)}) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec log2 n =
if n = 1 then 0
else 1 + log2 (n / 2) | val log2: n:nat{n > 0} -> GTot (c:nat{pow2 c <= n && n < pow2 (c+1)})
let rec log2 n = | false | null | false | if n = 1 then 0 else 1 + log2 (n / 2) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"sometrivial"
] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_GreaterThan",
"Prims.op_Equality",
"Prims.int",
"Prims.bool",
"Prims.op_Addition",
"MerkleTree.New.High.Correct.Base.log2",
"Prims.op_Division",
"Prims.op_AmpAmp",
"Prims.op_LessThanOrEqual",
"Prims.pow2",
"Prims.op_LessThan"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j)
val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i)
let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2
val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_olds_inv #hsz lv i olds =
if lv = 32 then true
else (let ofs = offset_of i in
S.length (S.index olds lv) == ofs /\
mt_olds_inv #hsz (lv + 1) (i / 2) olds)
val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv))
let rec mt_olds_inv_equiv #hsz #f lv i olds1 olds2 =
if lv = 32 then ()
else (assert (S.index olds1 lv == S.index olds2 lv);
mt_olds_inv_equiv #_ #f (lv + 1) (i / 2) olds1 olds2)
val mt_olds_hs_lth_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs))
(decreases (32 - lv))
let rec mt_olds_hs_lth_inv_ok #hsz #f lv i j olds hs =
if lv = 32 then ()
else (mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs)
val mt_olds_hs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
GTot Type0
let mt_olds_hs_inv #hsz #f lv i j olds hs =
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs)
// Relation between valid internal hashes (satisfying `mt_olds_hs_inv`) and
// the spec. While giving such relation, all rightmost hashes are recovered.
// Note that `MT?.rhs` after `construct_rhs` does NOT contain all rightmost
// hashes; it has partial rightmost hashes that are enough to calculate
// Merkle paths.
val log2: n:nat{n > 0} -> GTot (c:nat{pow2 c <= n && n < pow2 (c+1)}) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val log2: n:nat{n > 0} -> GTot (c:nat{pow2 c <= n && n < pow2 (c+1)}) | [
"recursion"
] | MerkleTree.New.High.Correct.Base.log2 | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | n: Prims.nat{n > 0} -> Prims.GTot (c: Prims.nat{Prims.pow2 c <= n && n < Prims.pow2 (c + 1)}) | {
"end_col": 23,
"end_line": 286,
"start_col": 2,
"start_line": 285
} |
Prims.GTot | val log2c:
n:nat ->
GTot (c:nat{c = 0 || (pow2 (c-1) <= n && n < pow2 c)}) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let log2c n =
if n = 0 then 0 else (log2 n + 1) | val log2c:
n:nat ->
GTot (c:nat{c = 0 || (pow2 (c-1) <= n && n < pow2 c)})
let log2c n = | false | null | false | if n = 0 then 0 else (log2 n + 1) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"sometrivial"
] | [
"Prims.nat",
"Prims.op_Equality",
"Prims.int",
"Prims.bool",
"Prims.op_Addition",
"MerkleTree.New.High.Correct.Base.log2",
"Prims.b2t",
"Prims.op_BarBar",
"Prims.op_AmpAmp",
"Prims.op_LessThanOrEqual",
"Prims.pow2",
"Prims.op_Subtraction",
"Prims.op_LessThan"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j)
val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i)
let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2
val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_olds_inv #hsz lv i olds =
if lv = 32 then true
else (let ofs = offset_of i in
S.length (S.index olds lv) == ofs /\
mt_olds_inv #hsz (lv + 1) (i / 2) olds)
val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv))
let rec mt_olds_inv_equiv #hsz #f lv i olds1 olds2 =
if lv = 32 then ()
else (assert (S.index olds1 lv == S.index olds2 lv);
mt_olds_inv_equiv #_ #f (lv + 1) (i / 2) olds1 olds2)
val mt_olds_hs_lth_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs))
(decreases (32 - lv))
let rec mt_olds_hs_lth_inv_ok #hsz #f lv i j olds hs =
if lv = 32 then ()
else (mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs)
val mt_olds_hs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
GTot Type0
let mt_olds_hs_inv #hsz #f lv i j olds hs =
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs)
// Relation between valid internal hashes (satisfying `mt_olds_hs_inv`) and
// the spec. While giving such relation, all rightmost hashes are recovered.
// Note that `MT?.rhs` after `construct_rhs` does NOT contain all rightmost
// hashes; it has partial rightmost hashes that are enough to calculate
// Merkle paths.
val log2: n:nat{n > 0} -> GTot (c:nat{pow2 c <= n && n < pow2 (c+1)})
let rec log2 n =
if n = 1 then 0
else 1 + log2 (n / 2)
val log2_bound:
n:nat{n > 0} -> c:nat{n < pow2 c} ->
Lemma (log2 n <= c-1)
let rec log2_bound n c =
if n = 1 then ()
else log2_bound (n / 2) (c - 1)
val log2_div:
n:nat{n > 1} ->
Lemma (log2 (n / 2) = log2 n - 1)
let log2_div n = ()
val log2c:
n:nat ->
GTot (c:nat{c = 0 || (pow2 (c-1) <= n && n < pow2 c)}) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val log2c:
n:nat ->
GTot (c:nat{c = 0 || (pow2 (c-1) <= n && n < pow2 c)}) | [] | MerkleTree.New.High.Correct.Base.log2c | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | n: Prims.nat -> Prims.GTot (c: Prims.nat{c = 0 || Prims.pow2 (c - 1) <= n && n < Prims.pow2 c}) | {
"end_col": 35,
"end_line": 304,
"start_col": 2,
"start_line": 304
} |
FStar.Pervasives.Lemma | val hash_seq_spec_index_raw:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
i:nat{i < S.length hs} ->
Lemma (S.index (hash_seq_spec #hsz hs) i == MTS.HRaw #hsz (S.index hs i)) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_seq_spec_index_raw #hsz hs i =
hash_seq_lift_index #hsz hs | val hash_seq_spec_index_raw:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
i:nat{i < S.length hs} ->
Lemma (S.index (hash_seq_spec #hsz hs) i == MTS.HRaw #hsz (S.index hs i))
let hash_seq_spec_index_raw #hsz hs i = | false | null | true | hash_seq_lift_index #hsz hs | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"lemma"
] | [
"Prims.pos",
"MerkleTree.New.High.hashes",
"Prims.b2t",
"Prims.op_GreaterThan",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hash",
"Prims.nat",
"Prims.op_LessThan",
"MerkleTree.New.High.Correct.Base.hash_seq_lift_index",
"Prims.unit"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j)
val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i)
let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2
val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_olds_inv #hsz lv i olds =
if lv = 32 then true
else (let ofs = offset_of i in
S.length (S.index olds lv) == ofs /\
mt_olds_inv #hsz (lv + 1) (i / 2) olds)
val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv))
let rec mt_olds_inv_equiv #hsz #f lv i olds1 olds2 =
if lv = 32 then ()
else (assert (S.index olds1 lv == S.index olds2 lv);
mt_olds_inv_equiv #_ #f (lv + 1) (i / 2) olds1 olds2)
val mt_olds_hs_lth_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs))
(decreases (32 - lv))
let rec mt_olds_hs_lth_inv_ok #hsz #f lv i j olds hs =
if lv = 32 then ()
else (mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs)
val mt_olds_hs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
GTot Type0
let mt_olds_hs_inv #hsz #f lv i j olds hs =
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs)
// Relation between valid internal hashes (satisfying `mt_olds_hs_inv`) and
// the spec. While giving such relation, all rightmost hashes are recovered.
// Note that `MT?.rhs` after `construct_rhs` does NOT contain all rightmost
// hashes; it has partial rightmost hashes that are enough to calculate
// Merkle paths.
val log2: n:nat{n > 0} -> GTot (c:nat{pow2 c <= n && n < pow2 (c+1)})
let rec log2 n =
if n = 1 then 0
else 1 + log2 (n / 2)
val log2_bound:
n:nat{n > 0} -> c:nat{n < pow2 c} ->
Lemma (log2 n <= c-1)
let rec log2_bound n c =
if n = 1 then ()
else log2_bound (n / 2) (c - 1)
val log2_div:
n:nat{n > 1} ->
Lemma (log2 (n / 2) = log2 n - 1)
let log2_div n = ()
val log2c:
n:nat ->
GTot (c:nat{c = 0 || (pow2 (c-1) <= n && n < pow2 c)})
let log2c n =
if n = 0 then 0 else (log2 n + 1)
val log2c_div:
n:nat{n > 0} ->
Lemma (log2c (n / 2) = log2c n - 1)
let log2c_div n = ()
val log2c_bound:
n:nat -> c:nat{n < pow2 c} ->
Lemma (log2c n <= c)
let rec log2c_bound n c =
if n = 0 then ()
else log2c_bound (n / 2) (c - 1)
val mt_hashes_lth_inv_log:
#hsz:pos ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
GTot Type0 (decreases j)
let rec mt_hashes_lth_inv_log #hsz j fhs =
if j = 0 then true
else (S.length (S.head fhs) == j /\
mt_hashes_lth_inv_log #hsz (j / 2) (S.tail fhs))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_lth_inv_log_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
Lemma (requires mt_hashes_lth_inv_log #hsz j fhs)
(ensures S.length (S.head fhs) == j /\
S.length (S.head (S.tail fhs)) == j / 2)
let mt_hashes_lth_inv_log_next #_ #_ _ _ = ()
val mt_hashes_inv_log:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j /\ mt_hashes_lth_inv_log #hsz j fhs} ->
GTot Type0 (decreases j)
let rec mt_hashes_inv_log #hsz #f j fhs =
if j <= 1 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs 0) (S.index fhs 1) /\
mt_hashes_inv_log #_ #f (j / 2) (S.tail fhs))
val mt_hashes_lth_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log #hsz j (S.slice fhs lv (lv + log2c j))))
(decreases j)
let rec mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs =
if j = 0 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log #hsz j (S.slice fhs 0 (log2c j))))
let mt_hashes_lth_inv_log_converted #_ #f j fhs =
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs
val mt_hashes_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j > 0 && j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz lv j fhs} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs lv (lv + log2c j))))
(decreases j)
#pop-options
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
let rec mt_hashes_inv_log_converted_ #_ #f lv j fhs =
if j = 1 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs;
mt_hashes_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
#pop-options
val mt_hashes_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 0 && j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz 0 j fhs} ->
Lemma (requires mt_hashes_inv #_ #f 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs 0 (log2c j))))
let mt_hashes_inv_log_converted #_ #f j fhs =
mt_hashes_inv_log_converted_ #_ #f 0 j fhs
val hash_seq_lift:
#hsz:pos ->
hs:hashes #hsz ->
GTot (shs:MTS.hashes #hsz {S.length shs = S.length hs})
(decreases (S.length hs))
let rec hash_seq_lift #hsz hs =
if S.length hs = 0 then S.empty
else S.cons (MTS.HRaw (S.head hs)) (hash_seq_lift #hsz (S.tail hs))
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
val hash_seq_lift_index:
#hsz:pos ->
hs:hashes #hsz ->
Lemma (requires True)
(ensures forall (i:nat{i < S.length hs}).
S.index (hash_seq_lift #hsz hs) i == MTS.HRaw (S.index hs i))
(decreases (S.length hs))
let rec hash_seq_lift_index #hsz hs =
if S.length hs = 0 then ()
else hash_seq_lift_index #hsz (S.tail hs)
#pop-options
val create_pads: #hsz:pos -> len:nat -> GTot (pads:MTS.hashes #hsz {S.length pads = len})
let create_pads #hsz len = S.create len (MTS.HPad #hsz)
val hash_seq_spec:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
GTot (MTS.merkle_tree #hsz (log2c (S.length hs)))
let hash_seq_spec #hsz hs =
S.append (hash_seq_lift #hsz hs)
(create_pads (pow2 (log2c (S.length hs)) - S.length hs))
val hash_seq_spec_index_raw:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
i:nat{i < S.length hs} ->
Lemma (S.index (hash_seq_spec #hsz hs) i == MTS.HRaw #hsz (S.index hs i)) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_seq_spec_index_raw:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
i:nat{i < S.length hs} ->
Lemma (S.index (hash_seq_spec #hsz hs) i == MTS.HRaw #hsz (S.index hs i)) | [] | MerkleTree.New.High.Correct.Base.hash_seq_spec_index_raw | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
hs: MerkleTree.New.High.hashes{FStar.Seq.Base.length hs > 0} ->
i: Prims.nat{i < FStar.Seq.Base.length hs}
-> FStar.Pervasives.Lemma
(ensures
FStar.Seq.Base.index (MerkleTree.New.High.Correct.Base.hash_seq_spec hs) i ==
MerkleTree.Spec.HRaw (FStar.Seq.Base.index hs i)) | {
"end_col": 29,
"end_line": 443,
"start_col": 2,
"start_line": 443
} |
FStar.Pervasives.Lemma | val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv)) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1)) | val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv = | false | null | true | if lv = 31
then ()
else
(mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1)) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"lemma",
""
] | [
"Prims.pos",
"MerkleTree.Spec.hash_fun_t",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_Equality",
"Prims.int",
"Prims.bool",
"MerkleTree.New.High.Correct.Base.mt_hashes_inv_empty",
"Prims.op_Addition",
"Prims.unit",
"MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv_empty"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv)) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv)) | [
"recursion"
] | MerkleTree.New.High.Correct.Base.mt_hashes_inv_empty | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | lv: Prims.nat{lv < 32}
-> FStar.Pervasives.Lemma
(ensures
([@@ FStar.Pervasives.inline_let ]let _ =
MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv_empty lv
in
MerkleTree.New.High.Correct.Base.mt_hashes_inv lv
0
(MerkleTree.New.High.Correct.Base.empty_hashes 32))) (decreases 32 - lv) | {
"end_col": 43,
"end_line": 112,
"start_col": 2,
"start_line": 110
} |
FStar.Pervasives.Lemma | val hash_seq_spec_full_index_raw:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs:hashes #hsz {S.length hs > 0} ->
acc:hash #hsz -> actd:bool -> i:nat{i < S.length hs} ->
Lemma (S.index (hash_seq_spec_full #_ #f hs acc actd) i ==
MTS.HRaw (S.index hs i)) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_seq_spec_full_index_raw #hsz #_ hs acc actd i =
hash_seq_spec_index_raw #hsz hs i | val hash_seq_spec_full_index_raw:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs:hashes #hsz {S.length hs > 0} ->
acc:hash #hsz -> actd:bool -> i:nat{i < S.length hs} ->
Lemma (S.index (hash_seq_spec_full #_ #f hs acc actd) i ==
MTS.HRaw (S.index hs i))
let hash_seq_spec_full_index_raw #hsz #_ hs acc actd i = | false | null | true | hash_seq_spec_index_raw #hsz hs i | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"lemma"
] | [
"Prims.pos",
"MerkleTree.Spec.hash_fun_t",
"MerkleTree.New.High.hashes",
"Prims.b2t",
"Prims.op_GreaterThan",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hash",
"Prims.bool",
"Prims.nat",
"Prims.op_LessThan",
"MerkleTree.New.High.Correct.Base.hash_seq_spec_index_raw",
"Prims.unit"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j)
val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i)
let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2
val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_olds_inv #hsz lv i olds =
if lv = 32 then true
else (let ofs = offset_of i in
S.length (S.index olds lv) == ofs /\
mt_olds_inv #hsz (lv + 1) (i / 2) olds)
val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv))
let rec mt_olds_inv_equiv #hsz #f lv i olds1 olds2 =
if lv = 32 then ()
else (assert (S.index olds1 lv == S.index olds2 lv);
mt_olds_inv_equiv #_ #f (lv + 1) (i / 2) olds1 olds2)
val mt_olds_hs_lth_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs))
(decreases (32 - lv))
let rec mt_olds_hs_lth_inv_ok #hsz #f lv i j olds hs =
if lv = 32 then ()
else (mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs)
val mt_olds_hs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
GTot Type0
let mt_olds_hs_inv #hsz #f lv i j olds hs =
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs)
// Relation between valid internal hashes (satisfying `mt_olds_hs_inv`) and
// the spec. While giving such relation, all rightmost hashes are recovered.
// Note that `MT?.rhs` after `construct_rhs` does NOT contain all rightmost
// hashes; it has partial rightmost hashes that are enough to calculate
// Merkle paths.
val log2: n:nat{n > 0} -> GTot (c:nat{pow2 c <= n && n < pow2 (c+1)})
let rec log2 n =
if n = 1 then 0
else 1 + log2 (n / 2)
val log2_bound:
n:nat{n > 0} -> c:nat{n < pow2 c} ->
Lemma (log2 n <= c-1)
let rec log2_bound n c =
if n = 1 then ()
else log2_bound (n / 2) (c - 1)
val log2_div:
n:nat{n > 1} ->
Lemma (log2 (n / 2) = log2 n - 1)
let log2_div n = ()
val log2c:
n:nat ->
GTot (c:nat{c = 0 || (pow2 (c-1) <= n && n < pow2 c)})
let log2c n =
if n = 0 then 0 else (log2 n + 1)
val log2c_div:
n:nat{n > 0} ->
Lemma (log2c (n / 2) = log2c n - 1)
let log2c_div n = ()
val log2c_bound:
n:nat -> c:nat{n < pow2 c} ->
Lemma (log2c n <= c)
let rec log2c_bound n c =
if n = 0 then ()
else log2c_bound (n / 2) (c - 1)
val mt_hashes_lth_inv_log:
#hsz:pos ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
GTot Type0 (decreases j)
let rec mt_hashes_lth_inv_log #hsz j fhs =
if j = 0 then true
else (S.length (S.head fhs) == j /\
mt_hashes_lth_inv_log #hsz (j / 2) (S.tail fhs))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_lth_inv_log_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
Lemma (requires mt_hashes_lth_inv_log #hsz j fhs)
(ensures S.length (S.head fhs) == j /\
S.length (S.head (S.tail fhs)) == j / 2)
let mt_hashes_lth_inv_log_next #_ #_ _ _ = ()
val mt_hashes_inv_log:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j /\ mt_hashes_lth_inv_log #hsz j fhs} ->
GTot Type0 (decreases j)
let rec mt_hashes_inv_log #hsz #f j fhs =
if j <= 1 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs 0) (S.index fhs 1) /\
mt_hashes_inv_log #_ #f (j / 2) (S.tail fhs))
val mt_hashes_lth_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log #hsz j (S.slice fhs lv (lv + log2c j))))
(decreases j)
let rec mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs =
if j = 0 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log #hsz j (S.slice fhs 0 (log2c j))))
let mt_hashes_lth_inv_log_converted #_ #f j fhs =
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs
val mt_hashes_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j > 0 && j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz lv j fhs} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs lv (lv + log2c j))))
(decreases j)
#pop-options
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
let rec mt_hashes_inv_log_converted_ #_ #f lv j fhs =
if j = 1 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs;
mt_hashes_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
#pop-options
val mt_hashes_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 0 && j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz 0 j fhs} ->
Lemma (requires mt_hashes_inv #_ #f 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs 0 (log2c j))))
let mt_hashes_inv_log_converted #_ #f j fhs =
mt_hashes_inv_log_converted_ #_ #f 0 j fhs
val hash_seq_lift:
#hsz:pos ->
hs:hashes #hsz ->
GTot (shs:MTS.hashes #hsz {S.length shs = S.length hs})
(decreases (S.length hs))
let rec hash_seq_lift #hsz hs =
if S.length hs = 0 then S.empty
else S.cons (MTS.HRaw (S.head hs)) (hash_seq_lift #hsz (S.tail hs))
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
val hash_seq_lift_index:
#hsz:pos ->
hs:hashes #hsz ->
Lemma (requires True)
(ensures forall (i:nat{i < S.length hs}).
S.index (hash_seq_lift #hsz hs) i == MTS.HRaw (S.index hs i))
(decreases (S.length hs))
let rec hash_seq_lift_index #hsz hs =
if S.length hs = 0 then ()
else hash_seq_lift_index #hsz (S.tail hs)
#pop-options
val create_pads: #hsz:pos -> len:nat -> GTot (pads:MTS.hashes #hsz {S.length pads = len})
let create_pads #hsz len = S.create len (MTS.HPad #hsz)
val hash_seq_spec:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
GTot (MTS.merkle_tree #hsz (log2c (S.length hs)))
let hash_seq_spec #hsz hs =
S.append (hash_seq_lift #hsz hs)
(create_pads (pow2 (log2c (S.length hs)) - S.length hs))
val hash_seq_spec_index_raw:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
i:nat{i < S.length hs} ->
Lemma (S.index (hash_seq_spec #hsz hs) i == MTS.HRaw #hsz (S.index hs i))
let hash_seq_spec_index_raw #hsz hs i =
hash_seq_lift_index #hsz hs
// Now about recovering rightmost hashes
#push-options "--z3rlimit 50 --initial_fuel 1 --max_fuel 1"
val mt_hashes_next_rel_lift_even:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures MTS.mt_next_rel #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs))
let mt_hashes_next_rel_lift_even #hsz #_ j hs nhs =
hash_seq_lift_index #hsz hs;
hash_seq_lift_index #hsz nhs
val mt_hashes_next_rel_lift_odd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 1 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures MTS.mt_next_rel #_ #f (log2c j)
(hash_seq_spec #hsz hs)
(S.upd (hash_seq_spec #hsz nhs)
(S.length nhs) (MTS.HRaw (S.last hs))))
let mt_hashes_next_rel_lift_odd #hsz #_ j hs nhs =
log2c_div j;
hash_seq_lift_index #hsz hs;
hash_seq_lift_index #hsz nhs
val mt_hashes_next_rel_next_even:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures S.equal (hash_seq_spec #hsz nhs)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec #hsz hs)))
let mt_hashes_next_rel_next_even #hsz #f j hs nhs =
log2c_div j;
mt_hashes_next_rel_lift_even #_ #f j hs nhs;
MTS.mt_next_rel_next_lv #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs)
val hash_seq_spec_full:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs:hashes #hsz {S.length hs > 0} ->
acc:hash #hsz -> actd:bool ->
GTot (MTS.merkle_tree #hsz (log2c (S.length hs)))
let hash_seq_spec_full #hsz #f hs acc actd =
if actd
then (S.upd (hash_seq_spec #hsz hs) (S.length hs) (MTS.HRaw acc))
else hash_seq_spec #hsz hs
val hash_seq_spec_full_index_raw:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs:hashes #hsz {S.length hs > 0} ->
acc:hash #hsz -> actd:bool -> i:nat{i < S.length hs} ->
Lemma (S.index (hash_seq_spec_full #_ #f hs acc actd) i ==
MTS.HRaw (S.index hs i)) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_seq_spec_full_index_raw:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs:hashes #hsz {S.length hs > 0} ->
acc:hash #hsz -> actd:bool -> i:nat{i < S.length hs} ->
Lemma (S.index (hash_seq_spec_full #_ #f hs acc actd) i ==
MTS.HRaw (S.index hs i)) | [] | MerkleTree.New.High.Correct.Base.hash_seq_spec_full_index_raw | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
hs: MerkleTree.New.High.hashes{FStar.Seq.Base.length hs > 0} ->
acc: MerkleTree.New.High.hash ->
actd: Prims.bool ->
i: Prims.nat{i < FStar.Seq.Base.length hs}
-> FStar.Pervasives.Lemma
(ensures
FStar.Seq.Base.index (MerkleTree.New.High.Correct.Base.hash_seq_spec_full hs acc actd) i ==
MerkleTree.Spec.HRaw (FStar.Seq.Base.index hs i)) | {
"end_col": 35,
"end_line": 506,
"start_col": 2,
"start_line": 506
} |
FStar.Pervasives.Lemma | val mt_hashes_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 0 && j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz 0 j fhs} ->
Lemma (requires mt_hashes_inv #_ #f 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs 0 (log2c j)))) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mt_hashes_inv_log_converted #_ #f j fhs =
mt_hashes_inv_log_converted_ #_ #f 0 j fhs | val mt_hashes_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 0 && j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz 0 j fhs} ->
Lemma (requires mt_hashes_inv #_ #f 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs 0 (log2c j))))
let mt_hashes_inv_log_converted #_ #f j fhs = | false | null | true | mt_hashes_inv_log_converted_ #_ #f 0 j fhs | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"lemma"
] | [
"Prims.pos",
"MerkleTree.Spec.hash_fun_t",
"Prims.nat",
"Prims.b2t",
"Prims.op_AmpAmp",
"Prims.op_GreaterThan",
"Prims.op_LessThan",
"Prims.pow2",
"MerkleTree.New.High.hashess",
"Prims.l_and",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hashes",
"MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv",
"MerkleTree.New.High.Correct.Base.mt_hashes_inv_log_converted_",
"Prims.unit"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j)
val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i)
let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2
val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_olds_inv #hsz lv i olds =
if lv = 32 then true
else (let ofs = offset_of i in
S.length (S.index olds lv) == ofs /\
mt_olds_inv #hsz (lv + 1) (i / 2) olds)
val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv))
let rec mt_olds_inv_equiv #hsz #f lv i olds1 olds2 =
if lv = 32 then ()
else (assert (S.index olds1 lv == S.index olds2 lv);
mt_olds_inv_equiv #_ #f (lv + 1) (i / 2) olds1 olds2)
val mt_olds_hs_lth_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs))
(decreases (32 - lv))
let rec mt_olds_hs_lth_inv_ok #hsz #f lv i j olds hs =
if lv = 32 then ()
else (mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs)
val mt_olds_hs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
GTot Type0
let mt_olds_hs_inv #hsz #f lv i j olds hs =
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs)
// Relation between valid internal hashes (satisfying `mt_olds_hs_inv`) and
// the spec. While giving such relation, all rightmost hashes are recovered.
// Note that `MT?.rhs` after `construct_rhs` does NOT contain all rightmost
// hashes; it has partial rightmost hashes that are enough to calculate
// Merkle paths.
val log2: n:nat{n > 0} -> GTot (c:nat{pow2 c <= n && n < pow2 (c+1)})
let rec log2 n =
if n = 1 then 0
else 1 + log2 (n / 2)
val log2_bound:
n:nat{n > 0} -> c:nat{n < pow2 c} ->
Lemma (log2 n <= c-1)
let rec log2_bound n c =
if n = 1 then ()
else log2_bound (n / 2) (c - 1)
val log2_div:
n:nat{n > 1} ->
Lemma (log2 (n / 2) = log2 n - 1)
let log2_div n = ()
val log2c:
n:nat ->
GTot (c:nat{c = 0 || (pow2 (c-1) <= n && n < pow2 c)})
let log2c n =
if n = 0 then 0 else (log2 n + 1)
val log2c_div:
n:nat{n > 0} ->
Lemma (log2c (n / 2) = log2c n - 1)
let log2c_div n = ()
val log2c_bound:
n:nat -> c:nat{n < pow2 c} ->
Lemma (log2c n <= c)
let rec log2c_bound n c =
if n = 0 then ()
else log2c_bound (n / 2) (c - 1)
val mt_hashes_lth_inv_log:
#hsz:pos ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
GTot Type0 (decreases j)
let rec mt_hashes_lth_inv_log #hsz j fhs =
if j = 0 then true
else (S.length (S.head fhs) == j /\
mt_hashes_lth_inv_log #hsz (j / 2) (S.tail fhs))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_lth_inv_log_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
Lemma (requires mt_hashes_lth_inv_log #hsz j fhs)
(ensures S.length (S.head fhs) == j /\
S.length (S.head (S.tail fhs)) == j / 2)
let mt_hashes_lth_inv_log_next #_ #_ _ _ = ()
val mt_hashes_inv_log:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j /\ mt_hashes_lth_inv_log #hsz j fhs} ->
GTot Type0 (decreases j)
let rec mt_hashes_inv_log #hsz #f j fhs =
if j <= 1 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs 0) (S.index fhs 1) /\
mt_hashes_inv_log #_ #f (j / 2) (S.tail fhs))
val mt_hashes_lth_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log #hsz j (S.slice fhs lv (lv + log2c j))))
(decreases j)
let rec mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs =
if j = 0 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log #hsz j (S.slice fhs 0 (log2c j))))
let mt_hashes_lth_inv_log_converted #_ #f j fhs =
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs
val mt_hashes_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j > 0 && j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz lv j fhs} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs lv (lv + log2c j))))
(decreases j)
#pop-options
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
let rec mt_hashes_inv_log_converted_ #_ #f lv j fhs =
if j = 1 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs;
mt_hashes_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
#pop-options
val mt_hashes_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 0 && j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz 0 j fhs} ->
Lemma (requires mt_hashes_inv #_ #f 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs 0 (log2c j)))) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mt_hashes_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 0 && j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz 0 j fhs} ->
Lemma (requires mt_hashes_inv #_ #f 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs 0 (log2c j)))) | [] | MerkleTree.New.High.Correct.Base.mt_hashes_inv_log_converted | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
j: Prims.nat{j > 0 && j < Prims.pow2 32} ->
fhs:
MerkleTree.New.High.hashess
{ FStar.Seq.Base.length fhs = 32 /\
MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv 0 j fhs }
-> FStar.Pervasives.Lemma (requires MerkleTree.New.High.Correct.Base.mt_hashes_inv 0 j fhs)
(ensures
([@@ FStar.Pervasives.inline_let ]let _ =
MerkleTree.New.High.Correct.Base.log2c_bound j 32
in
[@@ FStar.Pervasives.inline_let ]let _ =
MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv_log_converted_ 0 j fhs
in
MerkleTree.New.High.Correct.Base.mt_hashes_inv_log j
(FStar.Seq.Base.slice fhs 0 (MerkleTree.New.High.Correct.Base.log2c j)))) | {
"end_col": 44,
"end_line": 402,
"start_col": 2,
"start_line": 402
} |
Prims.GTot | val mt_olds_hs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
GTot Type0 | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mt_olds_hs_inv #hsz #f lv i j olds hs =
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs) | val mt_olds_hs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
GTot Type0
let mt_olds_hs_inv #hsz #f lv i j olds hs = | false | null | false | mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"sometrivial"
] | [
"Prims.pos",
"MerkleTree.Spec.hash_fun_t",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.l_and",
"Prims.op_LessThanOrEqual",
"Prims.pow2",
"Prims.op_Subtraction",
"MerkleTree.New.High.hashess",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hashes",
"MerkleTree.New.High.Correct.Base.mt_olds_inv",
"MerkleTree.New.High.hs_wf_elts",
"MerkleTree.New.High.Correct.Base.mt_hashes_inv",
"MerkleTree.New.High.Correct.Base.merge_hs",
"Prims.unit",
"MerkleTree.New.High.Correct.Base.mt_olds_hs_lth_inv_ok"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j)
val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i)
let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2
val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_olds_inv #hsz lv i olds =
if lv = 32 then true
else (let ofs = offset_of i in
S.length (S.index olds lv) == ofs /\
mt_olds_inv #hsz (lv + 1) (i / 2) olds)
val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv))
let rec mt_olds_inv_equiv #hsz #f lv i olds1 olds2 =
if lv = 32 then ()
else (assert (S.index olds1 lv == S.index olds2 lv);
mt_olds_inv_equiv #_ #f (lv + 1) (i / 2) olds1 olds2)
val mt_olds_hs_lth_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs))
(decreases (32 - lv))
let rec mt_olds_hs_lth_inv_ok #hsz #f lv i j olds hs =
if lv = 32 then ()
else (mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs)
val mt_olds_hs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
GTot Type0 | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mt_olds_hs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
GTot Type0 | [] | MerkleTree.New.High.Correct.Base.mt_olds_hs_inv | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
lv: Prims.nat{lv < 32} ->
i: Prims.nat ->
j: Prims.nat{i <= j /\ j < Prims.pow2 (32 - lv)} ->
olds:
MerkleTree.New.High.hashess
{FStar.Seq.Base.length olds = 32 /\ MerkleTree.New.High.Correct.Base.mt_olds_inv lv i olds} ->
hs:
MerkleTree.New.High.hashess
{FStar.Seq.Base.length hs = 32 /\ MerkleTree.New.High.hs_wf_elts lv hs i j}
-> Prims.GTot Type0 | {
"end_col": 51,
"end_line": 275,
"start_col": 2,
"start_line": 274
} |
FStar.Pervasives.Lemma | val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv)) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec mt_olds_inv_equiv #hsz #f lv i olds1 olds2 =
if lv = 32 then ()
else (assert (S.index olds1 lv == S.index olds2 lv);
mt_olds_inv_equiv #_ #f (lv + 1) (i / 2) olds1 olds2) | val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv))
let rec mt_olds_inv_equiv #hsz #f lv i olds1 olds2 = | false | null | true | if lv = 32
then ()
else
(assert (S.index olds1 lv == S.index olds2 lv);
mt_olds_inv_equiv #_ #f (lv + 1) (i / 2) olds1 olds2) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"lemma",
""
] | [
"Prims.pos",
"MerkleTree.Spec.hash_fun_t",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"MerkleTree.New.High.hashess",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hashes",
"Prims.bool",
"MerkleTree.New.High.Correct.Base.mt_olds_inv_equiv",
"Prims.op_Addition",
"Prims.op_Division",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"FStar.Seq.Base.index"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j)
val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i)
let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2
val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_olds_inv #hsz lv i olds =
if lv = 32 then true
else (let ofs = offset_of i in
S.length (S.index olds lv) == ofs /\
mt_olds_inv #hsz (lv + 1) (i / 2) olds)
val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv)) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv)) | [
"recursion"
] | MerkleTree.New.High.Correct.Base.mt_olds_inv_equiv | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
lv: Prims.nat{lv <= 32} ->
i: Prims.nat ->
olds1: MerkleTree.New.High.hashess{FStar.Seq.Base.length olds1 = 32} ->
olds2: MerkleTree.New.High.hashess{FStar.Seq.Base.length olds2 = 32}
-> FStar.Pervasives.Lemma
(requires
MerkleTree.New.High.Correct.Base.mt_olds_inv lv i olds1 /\
FStar.Seq.Base.equal (FStar.Seq.Base.slice olds1 lv 32) (FStar.Seq.Base.slice olds2 lv 32))
(ensures MerkleTree.New.High.Correct.Base.mt_olds_inv lv i olds2)
(decreases 32 - lv) | {
"end_col": 60,
"end_line": 249,
"start_col": 2,
"start_line": 247
} |
Prims.GTot | val mt_rhs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
smt:MTS.merkle_tree #hsz (log2c j) ->
rhs:hashes #hsz {S.length rhs = log2c j} ->
actd:bool ->
GTot Type0 (decreases j) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec mt_rhs_inv #_ #f j smt rhs actd =
if j = 0 then true
else begin
(if j % 2 = 1 && actd
then (S.index smt j == MTS.HRaw (S.head rhs))
else true) /\
mt_rhs_inv #_ #f (j / 2) (MTS.mt_next_lv #_ #f #(log2c j) smt) (S.tail rhs)
(actd || (j % 2 = 1))
end | val mt_rhs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
smt:MTS.merkle_tree #hsz (log2c j) ->
rhs:hashes #hsz {S.length rhs = log2c j} ->
actd:bool ->
GTot Type0 (decreases j)
let rec mt_rhs_inv #_ #f j smt rhs actd = | false | null | false | if j = 0
then true
else
(if j % 2 = 1 && actd then (S.index smt j == MTS.HRaw (S.head rhs)) else true) /\
mt_rhs_inv #_ #f (j / 2) (MTS.mt_next_lv #_ #f #(log2c j) smt) (S.tail rhs) (actd || (j % 2 = 1)) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"sometrivial",
""
] | [
"Prims.pos",
"MerkleTree.Spec.hash_fun_t",
"Prims.nat",
"MerkleTree.Spec.merkle_tree",
"MerkleTree.New.High.Correct.Base.log2c",
"MerkleTree.New.High.hashes",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hash",
"Prims.bool",
"Prims.int",
"Prims.l_and",
"Prims.op_AmpAmp",
"Prims.op_Modulus",
"Prims.eq2",
"MerkleTree.Spec.padded_hash",
"FStar.Seq.Base.index",
"MerkleTree.Spec.HRaw",
"FStar.Seq.Properties.head",
"Prims.logical",
"MerkleTree.New.High.Correct.Base.mt_rhs_inv",
"Prims.op_Division",
"MerkleTree.Spec.mt_next_lv",
"FStar.Seq.Properties.tail",
"Prims.op_BarBar"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j)
val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i)
let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2
val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_olds_inv #hsz lv i olds =
if lv = 32 then true
else (let ofs = offset_of i in
S.length (S.index olds lv) == ofs /\
mt_olds_inv #hsz (lv + 1) (i / 2) olds)
val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv))
let rec mt_olds_inv_equiv #hsz #f lv i olds1 olds2 =
if lv = 32 then ()
else (assert (S.index olds1 lv == S.index olds2 lv);
mt_olds_inv_equiv #_ #f (lv + 1) (i / 2) olds1 olds2)
val mt_olds_hs_lth_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs))
(decreases (32 - lv))
let rec mt_olds_hs_lth_inv_ok #hsz #f lv i j olds hs =
if lv = 32 then ()
else (mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs)
val mt_olds_hs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
GTot Type0
let mt_olds_hs_inv #hsz #f lv i j olds hs =
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs)
// Relation between valid internal hashes (satisfying `mt_olds_hs_inv`) and
// the spec. While giving such relation, all rightmost hashes are recovered.
// Note that `MT?.rhs` after `construct_rhs` does NOT contain all rightmost
// hashes; it has partial rightmost hashes that are enough to calculate
// Merkle paths.
val log2: n:nat{n > 0} -> GTot (c:nat{pow2 c <= n && n < pow2 (c+1)})
let rec log2 n =
if n = 1 then 0
else 1 + log2 (n / 2)
val log2_bound:
n:nat{n > 0} -> c:nat{n < pow2 c} ->
Lemma (log2 n <= c-1)
let rec log2_bound n c =
if n = 1 then ()
else log2_bound (n / 2) (c - 1)
val log2_div:
n:nat{n > 1} ->
Lemma (log2 (n / 2) = log2 n - 1)
let log2_div n = ()
val log2c:
n:nat ->
GTot (c:nat{c = 0 || (pow2 (c-1) <= n && n < pow2 c)})
let log2c n =
if n = 0 then 0 else (log2 n + 1)
val log2c_div:
n:nat{n > 0} ->
Lemma (log2c (n / 2) = log2c n - 1)
let log2c_div n = ()
val log2c_bound:
n:nat -> c:nat{n < pow2 c} ->
Lemma (log2c n <= c)
let rec log2c_bound n c =
if n = 0 then ()
else log2c_bound (n / 2) (c - 1)
val mt_hashes_lth_inv_log:
#hsz:pos ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
GTot Type0 (decreases j)
let rec mt_hashes_lth_inv_log #hsz j fhs =
if j = 0 then true
else (S.length (S.head fhs) == j /\
mt_hashes_lth_inv_log #hsz (j / 2) (S.tail fhs))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_lth_inv_log_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
Lemma (requires mt_hashes_lth_inv_log #hsz j fhs)
(ensures S.length (S.head fhs) == j /\
S.length (S.head (S.tail fhs)) == j / 2)
let mt_hashes_lth_inv_log_next #_ #_ _ _ = ()
val mt_hashes_inv_log:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j /\ mt_hashes_lth_inv_log #hsz j fhs} ->
GTot Type0 (decreases j)
let rec mt_hashes_inv_log #hsz #f j fhs =
if j <= 1 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs 0) (S.index fhs 1) /\
mt_hashes_inv_log #_ #f (j / 2) (S.tail fhs))
val mt_hashes_lth_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log #hsz j (S.slice fhs lv (lv + log2c j))))
(decreases j)
let rec mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs =
if j = 0 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log #hsz j (S.slice fhs 0 (log2c j))))
let mt_hashes_lth_inv_log_converted #_ #f j fhs =
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs
val mt_hashes_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j > 0 && j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz lv j fhs} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs lv (lv + log2c j))))
(decreases j)
#pop-options
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
let rec mt_hashes_inv_log_converted_ #_ #f lv j fhs =
if j = 1 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs;
mt_hashes_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
#pop-options
val mt_hashes_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 0 && j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz 0 j fhs} ->
Lemma (requires mt_hashes_inv #_ #f 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs 0 (log2c j))))
let mt_hashes_inv_log_converted #_ #f j fhs =
mt_hashes_inv_log_converted_ #_ #f 0 j fhs
val hash_seq_lift:
#hsz:pos ->
hs:hashes #hsz ->
GTot (shs:MTS.hashes #hsz {S.length shs = S.length hs})
(decreases (S.length hs))
let rec hash_seq_lift #hsz hs =
if S.length hs = 0 then S.empty
else S.cons (MTS.HRaw (S.head hs)) (hash_seq_lift #hsz (S.tail hs))
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
val hash_seq_lift_index:
#hsz:pos ->
hs:hashes #hsz ->
Lemma (requires True)
(ensures forall (i:nat{i < S.length hs}).
S.index (hash_seq_lift #hsz hs) i == MTS.HRaw (S.index hs i))
(decreases (S.length hs))
let rec hash_seq_lift_index #hsz hs =
if S.length hs = 0 then ()
else hash_seq_lift_index #hsz (S.tail hs)
#pop-options
val create_pads: #hsz:pos -> len:nat -> GTot (pads:MTS.hashes #hsz {S.length pads = len})
let create_pads #hsz len = S.create len (MTS.HPad #hsz)
val hash_seq_spec:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
GTot (MTS.merkle_tree #hsz (log2c (S.length hs)))
let hash_seq_spec #hsz hs =
S.append (hash_seq_lift #hsz hs)
(create_pads (pow2 (log2c (S.length hs)) - S.length hs))
val hash_seq_spec_index_raw:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
i:nat{i < S.length hs} ->
Lemma (S.index (hash_seq_spec #hsz hs) i == MTS.HRaw #hsz (S.index hs i))
let hash_seq_spec_index_raw #hsz hs i =
hash_seq_lift_index #hsz hs
// Now about recovering rightmost hashes
#push-options "--z3rlimit 50 --initial_fuel 1 --max_fuel 1"
val mt_hashes_next_rel_lift_even:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures MTS.mt_next_rel #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs))
let mt_hashes_next_rel_lift_even #hsz #_ j hs nhs =
hash_seq_lift_index #hsz hs;
hash_seq_lift_index #hsz nhs
val mt_hashes_next_rel_lift_odd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 1 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures MTS.mt_next_rel #_ #f (log2c j)
(hash_seq_spec #hsz hs)
(S.upd (hash_seq_spec #hsz nhs)
(S.length nhs) (MTS.HRaw (S.last hs))))
let mt_hashes_next_rel_lift_odd #hsz #_ j hs nhs =
log2c_div j;
hash_seq_lift_index #hsz hs;
hash_seq_lift_index #hsz nhs
val mt_hashes_next_rel_next_even:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures S.equal (hash_seq_spec #hsz nhs)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec #hsz hs)))
let mt_hashes_next_rel_next_even #hsz #f j hs nhs =
log2c_div j;
mt_hashes_next_rel_lift_even #_ #f j hs nhs;
MTS.mt_next_rel_next_lv #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs)
val hash_seq_spec_full:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs:hashes #hsz {S.length hs > 0} ->
acc:hash #hsz -> actd:bool ->
GTot (MTS.merkle_tree #hsz (log2c (S.length hs)))
let hash_seq_spec_full #hsz #f hs acc actd =
if actd
then (S.upd (hash_seq_spec #hsz hs) (S.length hs) (MTS.HRaw acc))
else hash_seq_spec #hsz hs
val hash_seq_spec_full_index_raw:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs:hashes #hsz {S.length hs > 0} ->
acc:hash #hsz -> actd:bool -> i:nat{i < S.length hs} ->
Lemma (S.index (hash_seq_spec_full #_ #f hs acc actd) i ==
MTS.HRaw (S.index hs i))
let hash_seq_spec_full_index_raw #hsz #_ hs acc actd i =
hash_seq_spec_index_raw #hsz hs i
val hash_seq_spec_full_case_true:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs:hashes #hsz {S.length hs > 0} -> acc:hash #hsz ->
Lemma (S.index (hash_seq_spec_full #_ #f hs acc true) (S.length hs) == MTS.HRaw acc)
let hash_seq_spec_full_case_true #_ #_ _ _ = ()
val hash_seq_spec_full_even_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 0} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
acc:hash #hsz -> actd:bool ->
Lemma
(requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures S.equal (hash_seq_spec_full #_ #f nhs acc actd)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f hs acc actd)))
#restart-solver
#push-options "--quake 1/3 --z3rlimit 100 --fuel 2 --ifuel 1"
let hash_seq_spec_full_even_next #hsz #f j hs nhs acc actd =
log2c_div j;
mt_hashes_next_rel_lift_even #_ #f j hs nhs;
if actd
then begin
MTS.mt_next_rel_upd_even_pad #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs) (S.length hs / 2) (MTS.HRaw acc);
let n = log2c j in
let mt = S.upd (hash_seq_spec #hsz hs) (S.length hs) (MTS.HRaw acc) in
let nmt = S.upd (hash_seq_spec #hsz nhs) (S.length nhs) (MTS.HRaw acc) in
// assume (MTS.mt_next_rel #_ #f n mt nmt);
MTS.mt_next_rel_next_lv #_ #f n mt nmt
end
else MTS.mt_next_rel_next_lv #_ #f (log2c j)
(hash_seq_spec_full #_ #f hs acc actd)
(hash_seq_spec_full #_ #f nhs acc actd)
#pop-options
#push-options "--z3rlimit 80"
val hash_seq_spec_full_odd_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
acc:hash #hsz -> actd:bool -> nacc:hash #hsz ->
Lemma
(requires j % 2 = 1 /\
mt_hashes_next_rel #_ #f j hs nhs /\
nacc == (if actd then f (S.last hs) acc else S.last hs))
(ensures S.equal (hash_seq_spec_full #_ #f nhs nacc true)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f hs acc actd)))
let hash_seq_spec_full_odd_next #hsz #f j hs nhs acc actd nacc =
log2c_div j;
mt_hashes_next_rel_lift_odd #_ #f j hs nhs;
if actd
then begin
MTS.mt_next_rel_upd_odd #_ #f (log2c j)
(hash_seq_spec #hsz hs)
(S.upd (hash_seq_spec #hsz nhs) (S.length nhs) (MTS.HRaw (S.last hs)))
(S.length nhs) (MTS.HRaw acc);
MTS.mt_next_rel_next_lv #_ #f (log2c j)
(S.upd (hash_seq_spec #hsz hs) (S.length hs) (MTS.HRaw acc))
(S.upd (hash_seq_spec #hsz nhs) (S.length nhs) (MTS.HRaw (f (S.last hs) acc)))
end
else MTS.mt_next_rel_next_lv #_ #f (log2c j)
(hash_seq_spec_full #_ #f hs acc actd)
(hash_seq_spec_full #_ #f nhs nacc true)
#pop-options
val hash_seq_spec_full_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
acc:hash #hsz -> actd:bool -> nacc:hash #hsz -> nactd:bool ->
Lemma
(requires mt_hashes_next_rel #_ #f j hs nhs /\
nacc == (if j % 2 = 0 then acc
else if actd
then f (S.last hs) acc
else S.last hs) /\
nactd == (actd || j % 2 = 1))
(ensures S.equal (hash_seq_spec_full #_ #f nhs nacc nactd)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f hs acc actd)))
let hash_seq_spec_full_next #_ #f j hs nhs acc actd nacc nactd =
if j % 2 = 0
then hash_seq_spec_full_even_next #_ #f j hs nhs acc actd
else hash_seq_spec_full_odd_next #_ #f j hs nhs acc actd nacc
val mt_rhs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
smt:MTS.merkle_tree #hsz (log2c j) ->
rhs:hashes #hsz {S.length rhs = log2c j} ->
actd:bool ->
GTot Type0 (decreases j) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mt_rhs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
smt:MTS.merkle_tree #hsz (log2c j) ->
rhs:hashes #hsz {S.length rhs = log2c j} ->
actd:bool ->
GTot Type0 (decreases j) | [
"recursion"
] | MerkleTree.New.High.Correct.Base.mt_rhs_inv | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
j: Prims.nat ->
smt: MerkleTree.Spec.merkle_tree (MerkleTree.New.High.Correct.Base.log2c j) ->
rhs:
MerkleTree.New.High.hashes
{FStar.Seq.Base.length rhs = MerkleTree.New.High.Correct.Base.log2c j} ->
actd: Prims.bool
-> Prims.GTot Type0 | {
"end_col": 5,
"end_line": 612,
"start_col": 2,
"start_line": 605
} |
FStar.Pervasives.Lemma | val mt_hashes_next_rel_next_even:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures S.equal (hash_seq_spec #hsz nhs)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec #hsz hs))) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mt_hashes_next_rel_next_even #hsz #f j hs nhs =
log2c_div j;
mt_hashes_next_rel_lift_even #_ #f j hs nhs;
MTS.mt_next_rel_next_lv #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs) | val mt_hashes_next_rel_next_even:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures S.equal (hash_seq_spec #hsz nhs)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec #hsz hs)))
let mt_hashes_next_rel_next_even #hsz #f j hs nhs = | false | null | true | log2c_div j;
mt_hashes_next_rel_lift_even #_ #f j hs nhs;
MTS.mt_next_rel_next_lv #_ #f (log2c j) (hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"lemma"
] | [
"Prims.pos",
"MerkleTree.Spec.hash_fun_t",
"Prims.nat",
"Prims.b2t",
"Prims.op_GreaterThan",
"MerkleTree.New.High.hashes",
"Prims.op_Equality",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hash",
"Prims.int",
"Prims.op_Division",
"MerkleTree.Spec.mt_next_rel_next_lv",
"MerkleTree.New.High.Correct.Base.log2c",
"MerkleTree.New.High.Correct.Base.hash_seq_spec",
"Prims.unit",
"MerkleTree.New.High.Correct.Base.mt_hashes_next_rel_lift_even",
"MerkleTree.New.High.Correct.Base.log2c_div"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j)
val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i)
let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2
val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_olds_inv #hsz lv i olds =
if lv = 32 then true
else (let ofs = offset_of i in
S.length (S.index olds lv) == ofs /\
mt_olds_inv #hsz (lv + 1) (i / 2) olds)
val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv))
let rec mt_olds_inv_equiv #hsz #f lv i olds1 olds2 =
if lv = 32 then ()
else (assert (S.index olds1 lv == S.index olds2 lv);
mt_olds_inv_equiv #_ #f (lv + 1) (i / 2) olds1 olds2)
val mt_olds_hs_lth_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs))
(decreases (32 - lv))
let rec mt_olds_hs_lth_inv_ok #hsz #f lv i j olds hs =
if lv = 32 then ()
else (mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs)
val mt_olds_hs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
GTot Type0
let mt_olds_hs_inv #hsz #f lv i j olds hs =
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs)
// Relation between valid internal hashes (satisfying `mt_olds_hs_inv`) and
// the spec. While giving such relation, all rightmost hashes are recovered.
// Note that `MT?.rhs` after `construct_rhs` does NOT contain all rightmost
// hashes; it has partial rightmost hashes that are enough to calculate
// Merkle paths.
val log2: n:nat{n > 0} -> GTot (c:nat{pow2 c <= n && n < pow2 (c+1)})
let rec log2 n =
if n = 1 then 0
else 1 + log2 (n / 2)
val log2_bound:
n:nat{n > 0} -> c:nat{n < pow2 c} ->
Lemma (log2 n <= c-1)
let rec log2_bound n c =
if n = 1 then ()
else log2_bound (n / 2) (c - 1)
val log2_div:
n:nat{n > 1} ->
Lemma (log2 (n / 2) = log2 n - 1)
let log2_div n = ()
val log2c:
n:nat ->
GTot (c:nat{c = 0 || (pow2 (c-1) <= n && n < pow2 c)})
let log2c n =
if n = 0 then 0 else (log2 n + 1)
val log2c_div:
n:nat{n > 0} ->
Lemma (log2c (n / 2) = log2c n - 1)
let log2c_div n = ()
val log2c_bound:
n:nat -> c:nat{n < pow2 c} ->
Lemma (log2c n <= c)
let rec log2c_bound n c =
if n = 0 then ()
else log2c_bound (n / 2) (c - 1)
val mt_hashes_lth_inv_log:
#hsz:pos ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
GTot Type0 (decreases j)
let rec mt_hashes_lth_inv_log #hsz j fhs =
if j = 0 then true
else (S.length (S.head fhs) == j /\
mt_hashes_lth_inv_log #hsz (j / 2) (S.tail fhs))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_lth_inv_log_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
Lemma (requires mt_hashes_lth_inv_log #hsz j fhs)
(ensures S.length (S.head fhs) == j /\
S.length (S.head (S.tail fhs)) == j / 2)
let mt_hashes_lth_inv_log_next #_ #_ _ _ = ()
val mt_hashes_inv_log:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j /\ mt_hashes_lth_inv_log #hsz j fhs} ->
GTot Type0 (decreases j)
let rec mt_hashes_inv_log #hsz #f j fhs =
if j <= 1 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs 0) (S.index fhs 1) /\
mt_hashes_inv_log #_ #f (j / 2) (S.tail fhs))
val mt_hashes_lth_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log #hsz j (S.slice fhs lv (lv + log2c j))))
(decreases j)
let rec mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs =
if j = 0 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log #hsz j (S.slice fhs 0 (log2c j))))
let mt_hashes_lth_inv_log_converted #_ #f j fhs =
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs
val mt_hashes_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j > 0 && j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz lv j fhs} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs lv (lv + log2c j))))
(decreases j)
#pop-options
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
let rec mt_hashes_inv_log_converted_ #_ #f lv j fhs =
if j = 1 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs;
mt_hashes_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
#pop-options
val mt_hashes_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 0 && j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz 0 j fhs} ->
Lemma (requires mt_hashes_inv #_ #f 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs 0 (log2c j))))
let mt_hashes_inv_log_converted #_ #f j fhs =
mt_hashes_inv_log_converted_ #_ #f 0 j fhs
val hash_seq_lift:
#hsz:pos ->
hs:hashes #hsz ->
GTot (shs:MTS.hashes #hsz {S.length shs = S.length hs})
(decreases (S.length hs))
let rec hash_seq_lift #hsz hs =
if S.length hs = 0 then S.empty
else S.cons (MTS.HRaw (S.head hs)) (hash_seq_lift #hsz (S.tail hs))
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
val hash_seq_lift_index:
#hsz:pos ->
hs:hashes #hsz ->
Lemma (requires True)
(ensures forall (i:nat{i < S.length hs}).
S.index (hash_seq_lift #hsz hs) i == MTS.HRaw (S.index hs i))
(decreases (S.length hs))
let rec hash_seq_lift_index #hsz hs =
if S.length hs = 0 then ()
else hash_seq_lift_index #hsz (S.tail hs)
#pop-options
val create_pads: #hsz:pos -> len:nat -> GTot (pads:MTS.hashes #hsz {S.length pads = len})
let create_pads #hsz len = S.create len (MTS.HPad #hsz)
val hash_seq_spec:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
GTot (MTS.merkle_tree #hsz (log2c (S.length hs)))
let hash_seq_spec #hsz hs =
S.append (hash_seq_lift #hsz hs)
(create_pads (pow2 (log2c (S.length hs)) - S.length hs))
val hash_seq_spec_index_raw:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
i:nat{i < S.length hs} ->
Lemma (S.index (hash_seq_spec #hsz hs) i == MTS.HRaw #hsz (S.index hs i))
let hash_seq_spec_index_raw #hsz hs i =
hash_seq_lift_index #hsz hs
// Now about recovering rightmost hashes
#push-options "--z3rlimit 50 --initial_fuel 1 --max_fuel 1"
val mt_hashes_next_rel_lift_even:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures MTS.mt_next_rel #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs))
let mt_hashes_next_rel_lift_even #hsz #_ j hs nhs =
hash_seq_lift_index #hsz hs;
hash_seq_lift_index #hsz nhs
val mt_hashes_next_rel_lift_odd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 1 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures MTS.mt_next_rel #_ #f (log2c j)
(hash_seq_spec #hsz hs)
(S.upd (hash_seq_spec #hsz nhs)
(S.length nhs) (MTS.HRaw (S.last hs))))
let mt_hashes_next_rel_lift_odd #hsz #_ j hs nhs =
log2c_div j;
hash_seq_lift_index #hsz hs;
hash_seq_lift_index #hsz nhs
val mt_hashes_next_rel_next_even:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures S.equal (hash_seq_spec #hsz nhs)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec #hsz hs))) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mt_hashes_next_rel_next_even:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures S.equal (hash_seq_spec #hsz nhs)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec #hsz hs))) | [] | MerkleTree.New.High.Correct.Base.mt_hashes_next_rel_next_even | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
j: Prims.nat{j > 1} ->
hs: MerkleTree.New.High.hashes{FStar.Seq.Base.length hs = j} ->
nhs: MerkleTree.New.High.hashes{FStar.Seq.Base.length nhs = j / 2}
-> FStar.Pervasives.Lemma
(requires j % 2 = 0 /\ MerkleTree.New.High.Correct.Base.mt_hashes_next_rel j hs nhs)
(ensures
FStar.Seq.Base.equal (MerkleTree.New.High.Correct.Base.hash_seq_spec nhs)
(MerkleTree.Spec.mt_next_lv (MerkleTree.New.High.Correct.Base.hash_seq_spec hs))) | {
"end_col": 52,
"end_line": 487,
"start_col": 2,
"start_line": 484
} |
Prims.GTot | val mt_hashes_lth_inv_log:
#hsz:pos ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
GTot Type0 (decreases j) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec mt_hashes_lth_inv_log #hsz j fhs =
if j = 0 then true
else (S.length (S.head fhs) == j /\
mt_hashes_lth_inv_log #hsz (j / 2) (S.tail fhs)) | val mt_hashes_lth_inv_log:
#hsz:pos ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
GTot Type0 (decreases j)
let rec mt_hashes_lth_inv_log #hsz j fhs = | false | null | false | if j = 0
then true
else (S.length (S.head fhs) == j /\ mt_hashes_lth_inv_log #hsz (j / 2) (S.tail fhs)) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"sometrivial",
""
] | [
"Prims.pos",
"Prims.nat",
"MerkleTree.New.High.hashess",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hashes",
"MerkleTree.New.High.Correct.Base.log2c",
"Prims.int",
"Prims.bool",
"Prims.l_and",
"Prims.eq2",
"MerkleTree.New.High.hash",
"FStar.Seq.Properties.head",
"MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv_log",
"Prims.op_Division",
"FStar.Seq.Properties.tail"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j)
val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i)
let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2
val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_olds_inv #hsz lv i olds =
if lv = 32 then true
else (let ofs = offset_of i in
S.length (S.index olds lv) == ofs /\
mt_olds_inv #hsz (lv + 1) (i / 2) olds)
val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv))
let rec mt_olds_inv_equiv #hsz #f lv i olds1 olds2 =
if lv = 32 then ()
else (assert (S.index olds1 lv == S.index olds2 lv);
mt_olds_inv_equiv #_ #f (lv + 1) (i / 2) olds1 olds2)
val mt_olds_hs_lth_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs))
(decreases (32 - lv))
let rec mt_olds_hs_lth_inv_ok #hsz #f lv i j olds hs =
if lv = 32 then ()
else (mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs)
val mt_olds_hs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
GTot Type0
let mt_olds_hs_inv #hsz #f lv i j olds hs =
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs)
// Relation between valid internal hashes (satisfying `mt_olds_hs_inv`) and
// the spec. While giving such relation, all rightmost hashes are recovered.
// Note that `MT?.rhs` after `construct_rhs` does NOT contain all rightmost
// hashes; it has partial rightmost hashes that are enough to calculate
// Merkle paths.
val log2: n:nat{n > 0} -> GTot (c:nat{pow2 c <= n && n < pow2 (c+1)})
let rec log2 n =
if n = 1 then 0
else 1 + log2 (n / 2)
val log2_bound:
n:nat{n > 0} -> c:nat{n < pow2 c} ->
Lemma (log2 n <= c-1)
let rec log2_bound n c =
if n = 1 then ()
else log2_bound (n / 2) (c - 1)
val log2_div:
n:nat{n > 1} ->
Lemma (log2 (n / 2) = log2 n - 1)
let log2_div n = ()
val log2c:
n:nat ->
GTot (c:nat{c = 0 || (pow2 (c-1) <= n && n < pow2 c)})
let log2c n =
if n = 0 then 0 else (log2 n + 1)
val log2c_div:
n:nat{n > 0} ->
Lemma (log2c (n / 2) = log2c n - 1)
let log2c_div n = ()
val log2c_bound:
n:nat -> c:nat{n < pow2 c} ->
Lemma (log2c n <= c)
let rec log2c_bound n c =
if n = 0 then ()
else log2c_bound (n / 2) (c - 1)
val mt_hashes_lth_inv_log:
#hsz:pos ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
GTot Type0 (decreases j) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mt_hashes_lth_inv_log:
#hsz:pos ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
GTot Type0 (decreases j) | [
"recursion"
] | MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv_log | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
j: Prims.nat ->
fhs:
MerkleTree.New.High.hashess
{FStar.Seq.Base.length fhs = MerkleTree.New.High.Correct.Base.log2c j}
-> Prims.GTot Type0 | {
"end_col": 55,
"end_line": 326,
"start_col": 2,
"start_line": 324
} |
Prims.GTot | val hash_seq_lift:
#hsz:pos ->
hs:hashes #hsz ->
GTot (shs:MTS.hashes #hsz {S.length shs = S.length hs})
(decreases (S.length hs)) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec hash_seq_lift #hsz hs =
if S.length hs = 0 then S.empty
else S.cons (MTS.HRaw (S.head hs)) (hash_seq_lift #hsz (S.tail hs)) | val hash_seq_lift:
#hsz:pos ->
hs:hashes #hsz ->
GTot (shs:MTS.hashes #hsz {S.length shs = S.length hs})
(decreases (S.length hs))
let rec hash_seq_lift #hsz hs = | false | null | false | if S.length hs = 0 then S.empty else S.cons (MTS.HRaw (S.head hs)) (hash_seq_lift #hsz (S.tail hs)) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"sometrivial",
""
] | [
"Prims.pos",
"MerkleTree.New.High.hashes",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hash",
"FStar.Seq.Base.empty",
"MerkleTree.Spec.padded_hash",
"Prims.bool",
"FStar.Seq.Properties.cons",
"MerkleTree.Spec.HRaw",
"FStar.Seq.Properties.head",
"MerkleTree.New.High.Correct.Base.hash_seq_lift",
"FStar.Seq.Properties.tail",
"MerkleTree.Spec.hashes",
"Prims.b2t",
"Prims.nat"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j)
val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i)
let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2
val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_olds_inv #hsz lv i olds =
if lv = 32 then true
else (let ofs = offset_of i in
S.length (S.index olds lv) == ofs /\
mt_olds_inv #hsz (lv + 1) (i / 2) olds)
val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv))
let rec mt_olds_inv_equiv #hsz #f lv i olds1 olds2 =
if lv = 32 then ()
else (assert (S.index olds1 lv == S.index olds2 lv);
mt_olds_inv_equiv #_ #f (lv + 1) (i / 2) olds1 olds2)
val mt_olds_hs_lth_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs))
(decreases (32 - lv))
let rec mt_olds_hs_lth_inv_ok #hsz #f lv i j olds hs =
if lv = 32 then ()
else (mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs)
val mt_olds_hs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
GTot Type0
let mt_olds_hs_inv #hsz #f lv i j olds hs =
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs)
// Relation between valid internal hashes (satisfying `mt_olds_hs_inv`) and
// the spec. While giving such relation, all rightmost hashes are recovered.
// Note that `MT?.rhs` after `construct_rhs` does NOT contain all rightmost
// hashes; it has partial rightmost hashes that are enough to calculate
// Merkle paths.
val log2: n:nat{n > 0} -> GTot (c:nat{pow2 c <= n && n < pow2 (c+1)})
let rec log2 n =
if n = 1 then 0
else 1 + log2 (n / 2)
val log2_bound:
n:nat{n > 0} -> c:nat{n < pow2 c} ->
Lemma (log2 n <= c-1)
let rec log2_bound n c =
if n = 1 then ()
else log2_bound (n / 2) (c - 1)
val log2_div:
n:nat{n > 1} ->
Lemma (log2 (n / 2) = log2 n - 1)
let log2_div n = ()
val log2c:
n:nat ->
GTot (c:nat{c = 0 || (pow2 (c-1) <= n && n < pow2 c)})
let log2c n =
if n = 0 then 0 else (log2 n + 1)
val log2c_div:
n:nat{n > 0} ->
Lemma (log2c (n / 2) = log2c n - 1)
let log2c_div n = ()
val log2c_bound:
n:nat -> c:nat{n < pow2 c} ->
Lemma (log2c n <= c)
let rec log2c_bound n c =
if n = 0 then ()
else log2c_bound (n / 2) (c - 1)
val mt_hashes_lth_inv_log:
#hsz:pos ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
GTot Type0 (decreases j)
let rec mt_hashes_lth_inv_log #hsz j fhs =
if j = 0 then true
else (S.length (S.head fhs) == j /\
mt_hashes_lth_inv_log #hsz (j / 2) (S.tail fhs))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_lth_inv_log_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
Lemma (requires mt_hashes_lth_inv_log #hsz j fhs)
(ensures S.length (S.head fhs) == j /\
S.length (S.head (S.tail fhs)) == j / 2)
let mt_hashes_lth_inv_log_next #_ #_ _ _ = ()
val mt_hashes_inv_log:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j /\ mt_hashes_lth_inv_log #hsz j fhs} ->
GTot Type0 (decreases j)
let rec mt_hashes_inv_log #hsz #f j fhs =
if j <= 1 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs 0) (S.index fhs 1) /\
mt_hashes_inv_log #_ #f (j / 2) (S.tail fhs))
val mt_hashes_lth_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log #hsz j (S.slice fhs lv (lv + log2c j))))
(decreases j)
let rec mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs =
if j = 0 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log #hsz j (S.slice fhs 0 (log2c j))))
let mt_hashes_lth_inv_log_converted #_ #f j fhs =
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs
val mt_hashes_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j > 0 && j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz lv j fhs} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs lv (lv + log2c j))))
(decreases j)
#pop-options
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
let rec mt_hashes_inv_log_converted_ #_ #f lv j fhs =
if j = 1 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs;
mt_hashes_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
#pop-options
val mt_hashes_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 0 && j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz 0 j fhs} ->
Lemma (requires mt_hashes_inv #_ #f 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs 0 (log2c j))))
let mt_hashes_inv_log_converted #_ #f j fhs =
mt_hashes_inv_log_converted_ #_ #f 0 j fhs
val hash_seq_lift:
#hsz:pos ->
hs:hashes #hsz ->
GTot (shs:MTS.hashes #hsz {S.length shs = S.length hs})
(decreases (S.length hs)) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_seq_lift:
#hsz:pos ->
hs:hashes #hsz ->
GTot (shs:MTS.hashes #hsz {S.length shs = S.length hs})
(decreases (S.length hs)) | [
"recursion"
] | MerkleTree.New.High.Correct.Base.hash_seq_lift | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | hs: MerkleTree.New.High.hashes
-> Prims.GTot (shs: MerkleTree.Spec.hashes{FStar.Seq.Base.length shs = FStar.Seq.Base.length hs}) | {
"end_col": 69,
"end_line": 411,
"start_col": 2,
"start_line": 410
} |
Prims.GTot | val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1)) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2))) | val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 = | false | null | false | if S.length hs1 = 0
then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2)) (merge_hs #_ #f (S.tail hs1) (S.tail hs2))) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"sometrivial",
""
] | [
"Prims.pos",
"MerkleTree.Spec.hash_fun_t",
"MerkleTree.New.High.hashess",
"Prims.b2t",
"Prims.op_Equality",
"Prims.nat",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hashes",
"Prims.int",
"FStar.Seq.Base.empty",
"Prims.bool",
"FStar.Seq.Properties.cons",
"FStar.Seq.Base.append",
"MerkleTree.New.High.hash",
"FStar.Seq.Properties.head",
"MerkleTree.New.High.Correct.Base.merge_hs",
"FStar.Seq.Properties.tail"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1)) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1)) | [
"recursion"
] | MerkleTree.New.High.Correct.Base.merge_hs | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
hs1: MerkleTree.New.High.hashess ->
hs2: MerkleTree.New.High.hashess{FStar.Seq.Base.length hs1 = FStar.Seq.Base.length hs2}
-> Prims.GTot
(mhs: MerkleTree.New.High.hashess{FStar.Seq.Base.length mhs = FStar.Seq.Base.length hs1}) | {
"end_col": 58,
"end_line": 156,
"start_col": 2,
"start_line": 154
} |
FStar.Pervasives.Lemma | val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv)) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2) | val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 = | false | null | true | if lv = 31
then ()
else
(assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"lemma",
""
] | [
"Prims.pos",
"MerkleTree.Spec.hash_fun_t",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.pow2",
"Prims.op_Subtraction",
"MerkleTree.New.High.hashess",
"Prims.l_and",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hashes",
"MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv",
"Prims.bool",
"MerkleTree.New.High.Correct.Base.mt_hashes_inv_equiv",
"Prims.op_Addition",
"Prims.op_Division",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"FStar.Seq.Base.index"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv)) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv)) | [
"recursion"
] | MerkleTree.New.High.Correct.Base.mt_hashes_inv_equiv | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
lv: Prims.nat{lv < 32} ->
j: Prims.nat{j < Prims.pow2 (32 - lv)} ->
fhs1:
MerkleTree.New.High.hashess
{ FStar.Seq.Base.length fhs1 = 32 /\
MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv lv j fhs1 } ->
fhs2:
MerkleTree.New.High.hashess
{ FStar.Seq.Base.length fhs2 = 32 /\
MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv lv j fhs2 }
-> FStar.Pervasives.Lemma
(requires
MerkleTree.New.High.Correct.Base.mt_hashes_inv lv j fhs1 /\
FStar.Seq.Base.equal (FStar.Seq.Base.slice fhs1 lv 32) (FStar.Seq.Base.slice fhs2 lv 32))
(ensures MerkleTree.New.High.Correct.Base.mt_hashes_inv lv j fhs2)
(decreases 32 - lv) | {
"end_col": 60,
"end_line": 145,
"start_col": 2,
"start_line": 142
} |
Prims.GTot | val mt_base:
#hsz:pos ->
mt:merkle_tree #hsz {mt_wf_elts mt} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz 0 (MT?.i mt) olds} ->
GTot (bhs:hashes #hsz {S.length bhs = MT?.j mt}) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mt_base #hsz mt olds =
S.head (merge_hs #hsz #(MT?.hash_fun mt) olds (MT?.hs mt)) | val mt_base:
#hsz:pos ->
mt:merkle_tree #hsz {mt_wf_elts mt} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz 0 (MT?.i mt) olds} ->
GTot (bhs:hashes #hsz {S.length bhs = MT?.j mt})
let mt_base #hsz mt olds = | false | null | false | S.head (merge_hs #hsz #(MT?.hash_fun mt) olds (MT?.hs mt)) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"sometrivial"
] | [
"Prims.pos",
"MerkleTree.New.High.merkle_tree",
"MerkleTree.New.High.mt_wf_elts",
"MerkleTree.New.High.hashess",
"Prims.l_and",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hashes",
"MerkleTree.New.High.Correct.Base.mt_olds_inv",
"MerkleTree.New.High.__proj__MT__item__i",
"FStar.Seq.Properties.head",
"MerkleTree.New.High.Correct.Base.merge_hs",
"MerkleTree.New.High.__proj__MT__item__hash_fun",
"MerkleTree.New.High.__proj__MT__item__hs",
"Prims.nat",
"MerkleTree.New.High.hash",
"MerkleTree.New.High.__proj__MT__item__j"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j)
val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i)
let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2
val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_olds_inv #hsz lv i olds =
if lv = 32 then true
else (let ofs = offset_of i in
S.length (S.index olds lv) == ofs /\
mt_olds_inv #hsz (lv + 1) (i / 2) olds)
val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv))
let rec mt_olds_inv_equiv #hsz #f lv i olds1 olds2 =
if lv = 32 then ()
else (assert (S.index olds1 lv == S.index olds2 lv);
mt_olds_inv_equiv #_ #f (lv + 1) (i / 2) olds1 olds2)
val mt_olds_hs_lth_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs))
(decreases (32 - lv))
let rec mt_olds_hs_lth_inv_ok #hsz #f lv i j olds hs =
if lv = 32 then ()
else (mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs)
val mt_olds_hs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
GTot Type0
let mt_olds_hs_inv #hsz #f lv i j olds hs =
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs)
// Relation between valid internal hashes (satisfying `mt_olds_hs_inv`) and
// the spec. While giving such relation, all rightmost hashes are recovered.
// Note that `MT?.rhs` after `construct_rhs` does NOT contain all rightmost
// hashes; it has partial rightmost hashes that are enough to calculate
// Merkle paths.
val log2: n:nat{n > 0} -> GTot (c:nat{pow2 c <= n && n < pow2 (c+1)})
let rec log2 n =
if n = 1 then 0
else 1 + log2 (n / 2)
val log2_bound:
n:nat{n > 0} -> c:nat{n < pow2 c} ->
Lemma (log2 n <= c-1)
let rec log2_bound n c =
if n = 1 then ()
else log2_bound (n / 2) (c - 1)
val log2_div:
n:nat{n > 1} ->
Lemma (log2 (n / 2) = log2 n - 1)
let log2_div n = ()
val log2c:
n:nat ->
GTot (c:nat{c = 0 || (pow2 (c-1) <= n && n < pow2 c)})
let log2c n =
if n = 0 then 0 else (log2 n + 1)
val log2c_div:
n:nat{n > 0} ->
Lemma (log2c (n / 2) = log2c n - 1)
let log2c_div n = ()
val log2c_bound:
n:nat -> c:nat{n < pow2 c} ->
Lemma (log2c n <= c)
let rec log2c_bound n c =
if n = 0 then ()
else log2c_bound (n / 2) (c - 1)
val mt_hashes_lth_inv_log:
#hsz:pos ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
GTot Type0 (decreases j)
let rec mt_hashes_lth_inv_log #hsz j fhs =
if j = 0 then true
else (S.length (S.head fhs) == j /\
mt_hashes_lth_inv_log #hsz (j / 2) (S.tail fhs))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_lth_inv_log_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
Lemma (requires mt_hashes_lth_inv_log #hsz j fhs)
(ensures S.length (S.head fhs) == j /\
S.length (S.head (S.tail fhs)) == j / 2)
let mt_hashes_lth_inv_log_next #_ #_ _ _ = ()
val mt_hashes_inv_log:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j /\ mt_hashes_lth_inv_log #hsz j fhs} ->
GTot Type0 (decreases j)
let rec mt_hashes_inv_log #hsz #f j fhs =
if j <= 1 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs 0) (S.index fhs 1) /\
mt_hashes_inv_log #_ #f (j / 2) (S.tail fhs))
val mt_hashes_lth_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log #hsz j (S.slice fhs lv (lv + log2c j))))
(decreases j)
let rec mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs =
if j = 0 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log #hsz j (S.slice fhs 0 (log2c j))))
let mt_hashes_lth_inv_log_converted #_ #f j fhs =
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs
val mt_hashes_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j > 0 && j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz lv j fhs} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs lv (lv + log2c j))))
(decreases j)
#pop-options
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
let rec mt_hashes_inv_log_converted_ #_ #f lv j fhs =
if j = 1 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs;
mt_hashes_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
#pop-options
val mt_hashes_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 0 && j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz 0 j fhs} ->
Lemma (requires mt_hashes_inv #_ #f 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs 0 (log2c j))))
let mt_hashes_inv_log_converted #_ #f j fhs =
mt_hashes_inv_log_converted_ #_ #f 0 j fhs
val hash_seq_lift:
#hsz:pos ->
hs:hashes #hsz ->
GTot (shs:MTS.hashes #hsz {S.length shs = S.length hs})
(decreases (S.length hs))
let rec hash_seq_lift #hsz hs =
if S.length hs = 0 then S.empty
else S.cons (MTS.HRaw (S.head hs)) (hash_seq_lift #hsz (S.tail hs))
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
val hash_seq_lift_index:
#hsz:pos ->
hs:hashes #hsz ->
Lemma (requires True)
(ensures forall (i:nat{i < S.length hs}).
S.index (hash_seq_lift #hsz hs) i == MTS.HRaw (S.index hs i))
(decreases (S.length hs))
let rec hash_seq_lift_index #hsz hs =
if S.length hs = 0 then ()
else hash_seq_lift_index #hsz (S.tail hs)
#pop-options
val create_pads: #hsz:pos -> len:nat -> GTot (pads:MTS.hashes #hsz {S.length pads = len})
let create_pads #hsz len = S.create len (MTS.HPad #hsz)
val hash_seq_spec:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
GTot (MTS.merkle_tree #hsz (log2c (S.length hs)))
let hash_seq_spec #hsz hs =
S.append (hash_seq_lift #hsz hs)
(create_pads (pow2 (log2c (S.length hs)) - S.length hs))
val hash_seq_spec_index_raw:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
i:nat{i < S.length hs} ->
Lemma (S.index (hash_seq_spec #hsz hs) i == MTS.HRaw #hsz (S.index hs i))
let hash_seq_spec_index_raw #hsz hs i =
hash_seq_lift_index #hsz hs
// Now about recovering rightmost hashes
#push-options "--z3rlimit 50 --initial_fuel 1 --max_fuel 1"
val mt_hashes_next_rel_lift_even:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures MTS.mt_next_rel #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs))
let mt_hashes_next_rel_lift_even #hsz #_ j hs nhs =
hash_seq_lift_index #hsz hs;
hash_seq_lift_index #hsz nhs
val mt_hashes_next_rel_lift_odd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 1 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures MTS.mt_next_rel #_ #f (log2c j)
(hash_seq_spec #hsz hs)
(S.upd (hash_seq_spec #hsz nhs)
(S.length nhs) (MTS.HRaw (S.last hs))))
let mt_hashes_next_rel_lift_odd #hsz #_ j hs nhs =
log2c_div j;
hash_seq_lift_index #hsz hs;
hash_seq_lift_index #hsz nhs
val mt_hashes_next_rel_next_even:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures S.equal (hash_seq_spec #hsz nhs)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec #hsz hs)))
let mt_hashes_next_rel_next_even #hsz #f j hs nhs =
log2c_div j;
mt_hashes_next_rel_lift_even #_ #f j hs nhs;
MTS.mt_next_rel_next_lv #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs)
val hash_seq_spec_full:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs:hashes #hsz {S.length hs > 0} ->
acc:hash #hsz -> actd:bool ->
GTot (MTS.merkle_tree #hsz (log2c (S.length hs)))
let hash_seq_spec_full #hsz #f hs acc actd =
if actd
then (S.upd (hash_seq_spec #hsz hs) (S.length hs) (MTS.HRaw acc))
else hash_seq_spec #hsz hs
val hash_seq_spec_full_index_raw:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs:hashes #hsz {S.length hs > 0} ->
acc:hash #hsz -> actd:bool -> i:nat{i < S.length hs} ->
Lemma (S.index (hash_seq_spec_full #_ #f hs acc actd) i ==
MTS.HRaw (S.index hs i))
let hash_seq_spec_full_index_raw #hsz #_ hs acc actd i =
hash_seq_spec_index_raw #hsz hs i
val hash_seq_spec_full_case_true:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs:hashes #hsz {S.length hs > 0} -> acc:hash #hsz ->
Lemma (S.index (hash_seq_spec_full #_ #f hs acc true) (S.length hs) == MTS.HRaw acc)
let hash_seq_spec_full_case_true #_ #_ _ _ = ()
val hash_seq_spec_full_even_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 0} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
acc:hash #hsz -> actd:bool ->
Lemma
(requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures S.equal (hash_seq_spec_full #_ #f nhs acc actd)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f hs acc actd)))
#restart-solver
#push-options "--quake 1/3 --z3rlimit 100 --fuel 2 --ifuel 1"
let hash_seq_spec_full_even_next #hsz #f j hs nhs acc actd =
log2c_div j;
mt_hashes_next_rel_lift_even #_ #f j hs nhs;
if actd
then begin
MTS.mt_next_rel_upd_even_pad #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs) (S.length hs / 2) (MTS.HRaw acc);
let n = log2c j in
let mt = S.upd (hash_seq_spec #hsz hs) (S.length hs) (MTS.HRaw acc) in
let nmt = S.upd (hash_seq_spec #hsz nhs) (S.length nhs) (MTS.HRaw acc) in
// assume (MTS.mt_next_rel #_ #f n mt nmt);
MTS.mt_next_rel_next_lv #_ #f n mt nmt
end
else MTS.mt_next_rel_next_lv #_ #f (log2c j)
(hash_seq_spec_full #_ #f hs acc actd)
(hash_seq_spec_full #_ #f nhs acc actd)
#pop-options
#push-options "--z3rlimit 80"
val hash_seq_spec_full_odd_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
acc:hash #hsz -> actd:bool -> nacc:hash #hsz ->
Lemma
(requires j % 2 = 1 /\
mt_hashes_next_rel #_ #f j hs nhs /\
nacc == (if actd then f (S.last hs) acc else S.last hs))
(ensures S.equal (hash_seq_spec_full #_ #f nhs nacc true)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f hs acc actd)))
let hash_seq_spec_full_odd_next #hsz #f j hs nhs acc actd nacc =
log2c_div j;
mt_hashes_next_rel_lift_odd #_ #f j hs nhs;
if actd
then begin
MTS.mt_next_rel_upd_odd #_ #f (log2c j)
(hash_seq_spec #hsz hs)
(S.upd (hash_seq_spec #hsz nhs) (S.length nhs) (MTS.HRaw (S.last hs)))
(S.length nhs) (MTS.HRaw acc);
MTS.mt_next_rel_next_lv #_ #f (log2c j)
(S.upd (hash_seq_spec #hsz hs) (S.length hs) (MTS.HRaw acc))
(S.upd (hash_seq_spec #hsz nhs) (S.length nhs) (MTS.HRaw (f (S.last hs) acc)))
end
else MTS.mt_next_rel_next_lv #_ #f (log2c j)
(hash_seq_spec_full #_ #f hs acc actd)
(hash_seq_spec_full #_ #f nhs nacc true)
#pop-options
val hash_seq_spec_full_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
acc:hash #hsz -> actd:bool -> nacc:hash #hsz -> nactd:bool ->
Lemma
(requires mt_hashes_next_rel #_ #f j hs nhs /\
nacc == (if j % 2 = 0 then acc
else if actd
then f (S.last hs) acc
else S.last hs) /\
nactd == (actd || j % 2 = 1))
(ensures S.equal (hash_seq_spec_full #_ #f nhs nacc nactd)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f hs acc actd)))
let hash_seq_spec_full_next #_ #f j hs nhs acc actd nacc nactd =
if j % 2 = 0
then hash_seq_spec_full_even_next #_ #f j hs nhs acc actd
else hash_seq_spec_full_odd_next #_ #f j hs nhs acc actd nacc
val mt_rhs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
smt:MTS.merkle_tree #hsz (log2c j) ->
rhs:hashes #hsz {S.length rhs = log2c j} ->
actd:bool ->
GTot Type0 (decreases j)
let rec mt_rhs_inv #_ #f j smt rhs actd =
if j = 0 then true
else begin
(if j % 2 = 1 && actd
then (S.index smt j == MTS.HRaw (S.head rhs))
else true) /\
mt_rhs_inv #_ #f (j / 2) (MTS.mt_next_lv #_ #f #(log2c j) smt) (S.tail rhs)
(actd || (j % 2 = 1))
end
val mt_root_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs0:hashes #hsz {S.length hs0 > 0} ->
acc:hash #hsz -> actd:bool ->
rt:hash #hsz ->
GTot Type0
let mt_root_inv #_ #f hs0 acc actd rt =
MTS.mt_get_root #_ #f #(log2c (S.length hs0))
(hash_seq_spec_full #_ #f hs0 acc actd) == MTS.HRaw rt
val mt_base:
#hsz:pos ->
mt:merkle_tree #hsz {mt_wf_elts mt} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz 0 (MT?.i mt) olds} ->
GTot (bhs:hashes #hsz {S.length bhs = MT?.j mt}) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mt_base:
#hsz:pos ->
mt:merkle_tree #hsz {mt_wf_elts mt} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz 0 (MT?.i mt) olds} ->
GTot (bhs:hashes #hsz {S.length bhs = MT?.j mt}) | [] | MerkleTree.New.High.Correct.Base.mt_base | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
mt: MerkleTree.New.High.merkle_tree{MerkleTree.New.High.mt_wf_elts mt} ->
olds:
MerkleTree.New.High.hashess
{ FStar.Seq.Base.length olds = 32 /\
MerkleTree.New.High.Correct.Base.mt_olds_inv 0 (MT?.i mt) olds }
-> Prims.GTot (bhs: MerkleTree.New.High.hashes{FStar.Seq.Base.length bhs = MT?.j mt}) | {
"end_col": 60,
"end_line": 630,
"start_col": 2,
"start_line": 630
} |
Prims.GTot | val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv)) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs) | val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs = | false | null | false | if lv = 31
then true
else
(mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"sometrivial",
""
] | [
"Prims.pos",
"MerkleTree.Spec.hash_fun_t",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.pow2",
"Prims.op_Subtraction",
"MerkleTree.New.High.hashess",
"Prims.l_and",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hashes",
"MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv",
"Prims.bool",
"MerkleTree.New.High.Correct.Base.mt_hashes_next_rel",
"FStar.Seq.Base.index",
"Prims.op_Addition",
"MerkleTree.New.High.Correct.Base.mt_hashes_inv",
"Prims.op_Division"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv)) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv)) | [
"recursion"
] | MerkleTree.New.High.Correct.Base.mt_hashes_inv | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
lv: Prims.nat{lv < 32} ->
j: Prims.nat{j < Prims.pow2 (32 - lv)} ->
fhs:
MerkleTree.New.High.hashess
{ FStar.Seq.Base.length fhs = 32 /\
MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv lv j fhs }
-> Prims.GTot Type0 | {
"end_col": 48,
"end_line": 100,
"start_col": 2,
"start_line": 98
} |
FStar.Pervasives.Lemma | val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)] | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1) | val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i = | false | null | true | if S.length hs1 = 0
then ()
else if i = 0 then () else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"lemma",
""
] | [
"Prims.pos",
"MerkleTree.Spec.hash_fun_t",
"MerkleTree.New.High.hashess",
"Prims.b2t",
"Prims.op_Equality",
"Prims.nat",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hashes",
"Prims.op_LessThan",
"Prims.int",
"Prims.bool",
"MerkleTree.New.High.Correct.Base.merge_hs_index",
"FStar.Seq.Properties.tail",
"Prims.op_Subtraction",
"Prims.unit"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)] | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)] | [
"recursion"
] | MerkleTree.New.High.Correct.Base.merge_hs_index | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
hs1: MerkleTree.New.High.hashess ->
hs2: MerkleTree.New.High.hashess{FStar.Seq.Base.length hs1 = FStar.Seq.Base.length hs2} ->
i: Prims.nat{i < FStar.Seq.Base.length hs1}
-> FStar.Pervasives.Lemma
(ensures
FStar.Seq.Base.equal (FStar.Seq.Base.index (MerkleTree.New.High.Correct.Base.merge_hs hs1
hs2)
i)
(FStar.Seq.Base.append (FStar.Seq.Base.index hs1 i) (FStar.Seq.Base.index hs2 i)))
(decreases FStar.Seq.Base.length hs1)
[SMTPat (FStar.Seq.Base.index (MerkleTree.New.High.Correct.Base.merge_hs hs1 hs2) i)] | {
"end_col": 61,
"end_line": 188,
"start_col": 2,
"start_line": 186
} |
Prims.GTot | val mt_hashes_inv_log:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j /\ mt_hashes_lth_inv_log #hsz j fhs} ->
GTot Type0 (decreases j) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec mt_hashes_inv_log #hsz #f j fhs =
if j <= 1 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs 0) (S.index fhs 1) /\
mt_hashes_inv_log #_ #f (j / 2) (S.tail fhs)) | val mt_hashes_inv_log:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j /\ mt_hashes_lth_inv_log #hsz j fhs} ->
GTot Type0 (decreases j)
let rec mt_hashes_inv_log #hsz #f j fhs = | false | null | false | if j <= 1
then true
else
(mt_hashes_next_rel #_ #f j (S.index fhs 0) (S.index fhs 1) /\
mt_hashes_inv_log #_ #f (j / 2) (S.tail fhs)) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"sometrivial",
""
] | [
"Prims.pos",
"MerkleTree.Spec.hash_fun_t",
"Prims.nat",
"MerkleTree.New.High.hashess",
"Prims.l_and",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hashes",
"MerkleTree.New.High.Correct.Base.log2c",
"MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv_log",
"Prims.op_LessThanOrEqual",
"Prims.bool",
"MerkleTree.New.High.Correct.Base.mt_hashes_next_rel",
"FStar.Seq.Base.index",
"MerkleTree.New.High.Correct.Base.mt_hashes_inv_log",
"Prims.op_Division",
"FStar.Seq.Properties.tail"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j)
val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i)
let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2
val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_olds_inv #hsz lv i olds =
if lv = 32 then true
else (let ofs = offset_of i in
S.length (S.index olds lv) == ofs /\
mt_olds_inv #hsz (lv + 1) (i / 2) olds)
val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv))
let rec mt_olds_inv_equiv #hsz #f lv i olds1 olds2 =
if lv = 32 then ()
else (assert (S.index olds1 lv == S.index olds2 lv);
mt_olds_inv_equiv #_ #f (lv + 1) (i / 2) olds1 olds2)
val mt_olds_hs_lth_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs))
(decreases (32 - lv))
let rec mt_olds_hs_lth_inv_ok #hsz #f lv i j olds hs =
if lv = 32 then ()
else (mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs)
val mt_olds_hs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
GTot Type0
let mt_olds_hs_inv #hsz #f lv i j olds hs =
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs)
// Relation between valid internal hashes (satisfying `mt_olds_hs_inv`) and
// the spec. While giving such relation, all rightmost hashes are recovered.
// Note that `MT?.rhs` after `construct_rhs` does NOT contain all rightmost
// hashes; it has partial rightmost hashes that are enough to calculate
// Merkle paths.
val log2: n:nat{n > 0} -> GTot (c:nat{pow2 c <= n && n < pow2 (c+1)})
let rec log2 n =
if n = 1 then 0
else 1 + log2 (n / 2)
val log2_bound:
n:nat{n > 0} -> c:nat{n < pow2 c} ->
Lemma (log2 n <= c-1)
let rec log2_bound n c =
if n = 1 then ()
else log2_bound (n / 2) (c - 1)
val log2_div:
n:nat{n > 1} ->
Lemma (log2 (n / 2) = log2 n - 1)
let log2_div n = ()
val log2c:
n:nat ->
GTot (c:nat{c = 0 || (pow2 (c-1) <= n && n < pow2 c)})
let log2c n =
if n = 0 then 0 else (log2 n + 1)
val log2c_div:
n:nat{n > 0} ->
Lemma (log2c (n / 2) = log2c n - 1)
let log2c_div n = ()
val log2c_bound:
n:nat -> c:nat{n < pow2 c} ->
Lemma (log2c n <= c)
let rec log2c_bound n c =
if n = 0 then ()
else log2c_bound (n / 2) (c - 1)
val mt_hashes_lth_inv_log:
#hsz:pos ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
GTot Type0 (decreases j)
let rec mt_hashes_lth_inv_log #hsz j fhs =
if j = 0 then true
else (S.length (S.head fhs) == j /\
mt_hashes_lth_inv_log #hsz (j / 2) (S.tail fhs))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_lth_inv_log_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
Lemma (requires mt_hashes_lth_inv_log #hsz j fhs)
(ensures S.length (S.head fhs) == j /\
S.length (S.head (S.tail fhs)) == j / 2)
let mt_hashes_lth_inv_log_next #_ #_ _ _ = ()
val mt_hashes_inv_log:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j /\ mt_hashes_lth_inv_log #hsz j fhs} ->
GTot Type0 (decreases j) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mt_hashes_inv_log:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j /\ mt_hashes_lth_inv_log #hsz j fhs} ->
GTot Type0 (decreases j) | [
"recursion"
] | MerkleTree.New.High.Correct.Base.mt_hashes_inv_log | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
j: Prims.nat ->
fhs:
MerkleTree.New.High.hashess
{ FStar.Seq.Base.length fhs = MerkleTree.New.High.Correct.Base.log2c j /\
MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv_log j fhs }
-> Prims.GTot Type0 | {
"end_col": 52,
"end_line": 347,
"start_col": 2,
"start_line": 345
} |
FStar.Pervasives.Lemma | val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv)) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2) | val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 = | false | null | true | if lv = 31
then ()
else
(assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"lemma",
""
] | [
"Prims.pos",
"MerkleTree.Spec.hash_fun_t",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.pow2",
"Prims.op_Subtraction",
"MerkleTree.New.High.hashess",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hashes",
"Prims.bool",
"MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv_equiv",
"Prims.op_Addition",
"Prims.op_Division",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"FStar.Seq.Base.index"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv)) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv)) | [
"recursion"
] | MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv_equiv | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
lv: Prims.nat{lv < 32} ->
j: Prims.nat{j < Prims.pow2 (32 - lv)} ->
fhs1: MerkleTree.New.High.hashess{FStar.Seq.Base.length fhs1 = 32} ->
fhs2: MerkleTree.New.High.hashess{FStar.Seq.Base.length fhs2 = 32}
-> FStar.Pervasives.Lemma
(requires
MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv lv j fhs1 /\
FStar.Seq.Base.equal (FStar.Seq.Base.slice fhs1 lv 32) (FStar.Seq.Base.slice fhs2 lv 32))
(ensures MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv lv j fhs2)
(decreases 32 - lv) | {
"end_col": 64,
"end_line": 127,
"start_col": 2,
"start_line": 125
} |
FStar.Pervasives.Lemma | val mt_olds_hs_lth_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs))
(decreases (32 - lv)) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec mt_olds_hs_lth_inv_ok #hsz #f lv i j olds hs =
if lv = 32 then ()
else (mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs) | val mt_olds_hs_lth_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs))
(decreases (32 - lv))
let rec mt_olds_hs_lth_inv_ok #hsz #f lv i j olds hs = | false | null | true | if lv = 32 then () else (mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"lemma",
""
] | [
"Prims.pos",
"MerkleTree.Spec.hash_fun_t",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.l_and",
"Prims.op_LessThan",
"Prims.pow2",
"Prims.op_Subtraction",
"MerkleTree.New.High.hashess",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hashes",
"MerkleTree.New.High.Correct.Base.mt_olds_inv",
"MerkleTree.New.High.hs_wf_elts",
"Prims.bool",
"MerkleTree.New.High.Correct.Base.mt_olds_hs_lth_inv_ok",
"Prims.op_Addition",
"Prims.op_Division",
"Prims.unit"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j)
val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i)
let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2
val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_olds_inv #hsz lv i olds =
if lv = 32 then true
else (let ofs = offset_of i in
S.length (S.index olds lv) == ofs /\
mt_olds_inv #hsz (lv + 1) (i / 2) olds)
val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv))
let rec mt_olds_inv_equiv #hsz #f lv i olds1 olds2 =
if lv = 32 then ()
else (assert (S.index olds1 lv == S.index olds2 lv);
mt_olds_inv_equiv #_ #f (lv + 1) (i / 2) olds1 olds2)
val mt_olds_hs_lth_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs))
(decreases (32 - lv)) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mt_olds_hs_lth_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs))
(decreases (32 - lv)) | [
"recursion"
] | MerkleTree.New.High.Correct.Base.mt_olds_hs_lth_inv_ok | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
lv: Prims.nat{lv <= 32} ->
i: Prims.nat ->
j: Prims.nat{i <= j /\ j < Prims.pow2 (32 - lv)} ->
olds:
MerkleTree.New.High.hashess
{FStar.Seq.Base.length olds = 32 /\ MerkleTree.New.High.Correct.Base.mt_olds_inv lv i olds} ->
hs:
MerkleTree.New.High.hashess
{FStar.Seq.Base.length hs = 32 /\ MerkleTree.New.High.hs_wf_elts lv hs i j}
-> FStar.Pervasives.Lemma
(ensures
MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv lv
j
(MerkleTree.New.High.Correct.Base.merge_hs olds hs)) (decreases 32 - lv) | {
"end_col": 69,
"end_line": 263,
"start_col": 2,
"start_line": 262
} |
FStar.Pervasives.Lemma | val hash_seq_spec_full_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
acc:hash #hsz -> actd:bool -> nacc:hash #hsz -> nactd:bool ->
Lemma
(requires mt_hashes_next_rel #_ #f j hs nhs /\
nacc == (if j % 2 = 0 then acc
else if actd
then f (S.last hs) acc
else S.last hs) /\
nactd == (actd || j % 2 = 1))
(ensures S.equal (hash_seq_spec_full #_ #f nhs nacc nactd)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f hs acc actd))) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_seq_spec_full_next #_ #f j hs nhs acc actd nacc nactd =
if j % 2 = 0
then hash_seq_spec_full_even_next #_ #f j hs nhs acc actd
else hash_seq_spec_full_odd_next #_ #f j hs nhs acc actd nacc | val hash_seq_spec_full_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
acc:hash #hsz -> actd:bool -> nacc:hash #hsz -> nactd:bool ->
Lemma
(requires mt_hashes_next_rel #_ #f j hs nhs /\
nacc == (if j % 2 = 0 then acc
else if actd
then f (S.last hs) acc
else S.last hs) /\
nactd == (actd || j % 2 = 1))
(ensures S.equal (hash_seq_spec_full #_ #f nhs nacc nactd)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f hs acc actd)))
let hash_seq_spec_full_next #_ #f j hs nhs acc actd nacc nactd = | false | null | true | if j % 2 = 0
then hash_seq_spec_full_even_next #_ #f j hs nhs acc actd
else hash_seq_spec_full_odd_next #_ #f j hs nhs acc actd nacc | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"lemma"
] | [
"Prims.pos",
"MerkleTree.Spec.hash_fun_t",
"Prims.nat",
"Prims.b2t",
"Prims.op_GreaterThan",
"MerkleTree.New.High.hashes",
"Prims.op_Equality",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hash",
"Prims.int",
"Prims.op_Division",
"Prims.bool",
"Prims.op_Modulus",
"MerkleTree.New.High.Correct.Base.hash_seq_spec_full_even_next",
"MerkleTree.New.High.Correct.Base.hash_seq_spec_full_odd_next",
"Prims.unit"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j)
val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i)
let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2
val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_olds_inv #hsz lv i olds =
if lv = 32 then true
else (let ofs = offset_of i in
S.length (S.index olds lv) == ofs /\
mt_olds_inv #hsz (lv + 1) (i / 2) olds)
val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv))
let rec mt_olds_inv_equiv #hsz #f lv i olds1 olds2 =
if lv = 32 then ()
else (assert (S.index olds1 lv == S.index olds2 lv);
mt_olds_inv_equiv #_ #f (lv + 1) (i / 2) olds1 olds2)
val mt_olds_hs_lth_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs))
(decreases (32 - lv))
let rec mt_olds_hs_lth_inv_ok #hsz #f lv i j olds hs =
if lv = 32 then ()
else (mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs)
val mt_olds_hs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
GTot Type0
let mt_olds_hs_inv #hsz #f lv i j olds hs =
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs)
// Relation between valid internal hashes (satisfying `mt_olds_hs_inv`) and
// the spec. While giving such relation, all rightmost hashes are recovered.
// Note that `MT?.rhs` after `construct_rhs` does NOT contain all rightmost
// hashes; it has partial rightmost hashes that are enough to calculate
// Merkle paths.
val log2: n:nat{n > 0} -> GTot (c:nat{pow2 c <= n && n < pow2 (c+1)})
let rec log2 n =
if n = 1 then 0
else 1 + log2 (n / 2)
val log2_bound:
n:nat{n > 0} -> c:nat{n < pow2 c} ->
Lemma (log2 n <= c-1)
let rec log2_bound n c =
if n = 1 then ()
else log2_bound (n / 2) (c - 1)
val log2_div:
n:nat{n > 1} ->
Lemma (log2 (n / 2) = log2 n - 1)
let log2_div n = ()
val log2c:
n:nat ->
GTot (c:nat{c = 0 || (pow2 (c-1) <= n && n < pow2 c)})
let log2c n =
if n = 0 then 0 else (log2 n + 1)
val log2c_div:
n:nat{n > 0} ->
Lemma (log2c (n / 2) = log2c n - 1)
let log2c_div n = ()
val log2c_bound:
n:nat -> c:nat{n < pow2 c} ->
Lemma (log2c n <= c)
let rec log2c_bound n c =
if n = 0 then ()
else log2c_bound (n / 2) (c - 1)
val mt_hashes_lth_inv_log:
#hsz:pos ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
GTot Type0 (decreases j)
let rec mt_hashes_lth_inv_log #hsz j fhs =
if j = 0 then true
else (S.length (S.head fhs) == j /\
mt_hashes_lth_inv_log #hsz (j / 2) (S.tail fhs))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_lth_inv_log_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
Lemma (requires mt_hashes_lth_inv_log #hsz j fhs)
(ensures S.length (S.head fhs) == j /\
S.length (S.head (S.tail fhs)) == j / 2)
let mt_hashes_lth_inv_log_next #_ #_ _ _ = ()
val mt_hashes_inv_log:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j /\ mt_hashes_lth_inv_log #hsz j fhs} ->
GTot Type0 (decreases j)
let rec mt_hashes_inv_log #hsz #f j fhs =
if j <= 1 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs 0) (S.index fhs 1) /\
mt_hashes_inv_log #_ #f (j / 2) (S.tail fhs))
val mt_hashes_lth_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log #hsz j (S.slice fhs lv (lv + log2c j))))
(decreases j)
let rec mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs =
if j = 0 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log #hsz j (S.slice fhs 0 (log2c j))))
let mt_hashes_lth_inv_log_converted #_ #f j fhs =
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs
val mt_hashes_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j > 0 && j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz lv j fhs} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs lv (lv + log2c j))))
(decreases j)
#pop-options
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
let rec mt_hashes_inv_log_converted_ #_ #f lv j fhs =
if j = 1 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs;
mt_hashes_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
#pop-options
val mt_hashes_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 0 && j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz 0 j fhs} ->
Lemma (requires mt_hashes_inv #_ #f 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs 0 (log2c j))))
let mt_hashes_inv_log_converted #_ #f j fhs =
mt_hashes_inv_log_converted_ #_ #f 0 j fhs
val hash_seq_lift:
#hsz:pos ->
hs:hashes #hsz ->
GTot (shs:MTS.hashes #hsz {S.length shs = S.length hs})
(decreases (S.length hs))
let rec hash_seq_lift #hsz hs =
if S.length hs = 0 then S.empty
else S.cons (MTS.HRaw (S.head hs)) (hash_seq_lift #hsz (S.tail hs))
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
val hash_seq_lift_index:
#hsz:pos ->
hs:hashes #hsz ->
Lemma (requires True)
(ensures forall (i:nat{i < S.length hs}).
S.index (hash_seq_lift #hsz hs) i == MTS.HRaw (S.index hs i))
(decreases (S.length hs))
let rec hash_seq_lift_index #hsz hs =
if S.length hs = 0 then ()
else hash_seq_lift_index #hsz (S.tail hs)
#pop-options
val create_pads: #hsz:pos -> len:nat -> GTot (pads:MTS.hashes #hsz {S.length pads = len})
let create_pads #hsz len = S.create len (MTS.HPad #hsz)
val hash_seq_spec:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
GTot (MTS.merkle_tree #hsz (log2c (S.length hs)))
let hash_seq_spec #hsz hs =
S.append (hash_seq_lift #hsz hs)
(create_pads (pow2 (log2c (S.length hs)) - S.length hs))
val hash_seq_spec_index_raw:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
i:nat{i < S.length hs} ->
Lemma (S.index (hash_seq_spec #hsz hs) i == MTS.HRaw #hsz (S.index hs i))
let hash_seq_spec_index_raw #hsz hs i =
hash_seq_lift_index #hsz hs
// Now about recovering rightmost hashes
#push-options "--z3rlimit 50 --initial_fuel 1 --max_fuel 1"
val mt_hashes_next_rel_lift_even:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures MTS.mt_next_rel #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs))
let mt_hashes_next_rel_lift_even #hsz #_ j hs nhs =
hash_seq_lift_index #hsz hs;
hash_seq_lift_index #hsz nhs
val mt_hashes_next_rel_lift_odd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 1 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures MTS.mt_next_rel #_ #f (log2c j)
(hash_seq_spec #hsz hs)
(S.upd (hash_seq_spec #hsz nhs)
(S.length nhs) (MTS.HRaw (S.last hs))))
let mt_hashes_next_rel_lift_odd #hsz #_ j hs nhs =
log2c_div j;
hash_seq_lift_index #hsz hs;
hash_seq_lift_index #hsz nhs
val mt_hashes_next_rel_next_even:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures S.equal (hash_seq_spec #hsz nhs)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec #hsz hs)))
let mt_hashes_next_rel_next_even #hsz #f j hs nhs =
log2c_div j;
mt_hashes_next_rel_lift_even #_ #f j hs nhs;
MTS.mt_next_rel_next_lv #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs)
val hash_seq_spec_full:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs:hashes #hsz {S.length hs > 0} ->
acc:hash #hsz -> actd:bool ->
GTot (MTS.merkle_tree #hsz (log2c (S.length hs)))
let hash_seq_spec_full #hsz #f hs acc actd =
if actd
then (S.upd (hash_seq_spec #hsz hs) (S.length hs) (MTS.HRaw acc))
else hash_seq_spec #hsz hs
val hash_seq_spec_full_index_raw:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs:hashes #hsz {S.length hs > 0} ->
acc:hash #hsz -> actd:bool -> i:nat{i < S.length hs} ->
Lemma (S.index (hash_seq_spec_full #_ #f hs acc actd) i ==
MTS.HRaw (S.index hs i))
let hash_seq_spec_full_index_raw #hsz #_ hs acc actd i =
hash_seq_spec_index_raw #hsz hs i
val hash_seq_spec_full_case_true:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs:hashes #hsz {S.length hs > 0} -> acc:hash #hsz ->
Lemma (S.index (hash_seq_spec_full #_ #f hs acc true) (S.length hs) == MTS.HRaw acc)
let hash_seq_spec_full_case_true #_ #_ _ _ = ()
val hash_seq_spec_full_even_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 0} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
acc:hash #hsz -> actd:bool ->
Lemma
(requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures S.equal (hash_seq_spec_full #_ #f nhs acc actd)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f hs acc actd)))
#restart-solver
#push-options "--quake 1/3 --z3rlimit 100 --fuel 2 --ifuel 1"
let hash_seq_spec_full_even_next #hsz #f j hs nhs acc actd =
log2c_div j;
mt_hashes_next_rel_lift_even #_ #f j hs nhs;
if actd
then begin
MTS.mt_next_rel_upd_even_pad #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs) (S.length hs / 2) (MTS.HRaw acc);
let n = log2c j in
let mt = S.upd (hash_seq_spec #hsz hs) (S.length hs) (MTS.HRaw acc) in
let nmt = S.upd (hash_seq_spec #hsz nhs) (S.length nhs) (MTS.HRaw acc) in
// assume (MTS.mt_next_rel #_ #f n mt nmt);
MTS.mt_next_rel_next_lv #_ #f n mt nmt
end
else MTS.mt_next_rel_next_lv #_ #f (log2c j)
(hash_seq_spec_full #_ #f hs acc actd)
(hash_seq_spec_full #_ #f nhs acc actd)
#pop-options
#push-options "--z3rlimit 80"
val hash_seq_spec_full_odd_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
acc:hash #hsz -> actd:bool -> nacc:hash #hsz ->
Lemma
(requires j % 2 = 1 /\
mt_hashes_next_rel #_ #f j hs nhs /\
nacc == (if actd then f (S.last hs) acc else S.last hs))
(ensures S.equal (hash_seq_spec_full #_ #f nhs nacc true)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f hs acc actd)))
let hash_seq_spec_full_odd_next #hsz #f j hs nhs acc actd nacc =
log2c_div j;
mt_hashes_next_rel_lift_odd #_ #f j hs nhs;
if actd
then begin
MTS.mt_next_rel_upd_odd #_ #f (log2c j)
(hash_seq_spec #hsz hs)
(S.upd (hash_seq_spec #hsz nhs) (S.length nhs) (MTS.HRaw (S.last hs)))
(S.length nhs) (MTS.HRaw acc);
MTS.mt_next_rel_next_lv #_ #f (log2c j)
(S.upd (hash_seq_spec #hsz hs) (S.length hs) (MTS.HRaw acc))
(S.upd (hash_seq_spec #hsz nhs) (S.length nhs) (MTS.HRaw (f (S.last hs) acc)))
end
else MTS.mt_next_rel_next_lv #_ #f (log2c j)
(hash_seq_spec_full #_ #f hs acc actd)
(hash_seq_spec_full #_ #f nhs nacc true)
#pop-options
val hash_seq_spec_full_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
acc:hash #hsz -> actd:bool -> nacc:hash #hsz -> nactd:bool ->
Lemma
(requires mt_hashes_next_rel #_ #f j hs nhs /\
nacc == (if j % 2 = 0 then acc
else if actd
then f (S.last hs) acc
else S.last hs) /\
nactd == (actd || j % 2 = 1))
(ensures S.equal (hash_seq_spec_full #_ #f nhs nacc nactd)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f hs acc actd))) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_seq_spec_full_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
acc:hash #hsz -> actd:bool -> nacc:hash #hsz -> nactd:bool ->
Lemma
(requires mt_hashes_next_rel #_ #f j hs nhs /\
nacc == (if j % 2 = 0 then acc
else if actd
then f (S.last hs) acc
else S.last hs) /\
nactd == (actd || j % 2 = 1))
(ensures S.equal (hash_seq_spec_full #_ #f nhs nacc nactd)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f hs acc actd))) | [] | MerkleTree.New.High.Correct.Base.hash_seq_spec_full_next | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
j: Prims.nat{j > 1} ->
hs: MerkleTree.New.High.hashes{FStar.Seq.Base.length hs = j} ->
nhs: MerkleTree.New.High.hashes{FStar.Seq.Base.length nhs = j / 2} ->
acc: MerkleTree.New.High.hash ->
actd: Prims.bool ->
nacc: MerkleTree.New.High.hash ->
nactd: Prims.bool
-> FStar.Pervasives.Lemma
(requires
MerkleTree.New.High.Correct.Base.mt_hashes_next_rel j hs nhs /\
nacc ==
(match j % 2 = 0 with
| true -> acc
| _ ->
(match actd with
| true -> f (FStar.Seq.Properties.last hs) acc
| _ -> FStar.Seq.Properties.last hs)
<:
b:
Spec.Hash.Definitions.bytes
{ FStar.Seq.Base.length b = hsz \/ FStar.Seq.Base.length b = hsz \/
FStar.Seq.Base.length b = hsz }) /\ nactd == (actd || j % 2 = 1))
(ensures
FStar.Seq.Base.equal (MerkleTree.New.High.Correct.Base.hash_seq_spec_full nhs nacc nactd)
(MerkleTree.Spec.mt_next_lv (MerkleTree.New.High.Correct.Base.hash_seq_spec_full hs
acc
actd))) | {
"end_col": 63,
"end_line": 595,
"start_col": 2,
"start_line": 593
} |
FStar.Pervasives.Lemma | val hash_seq_lift_index:
#hsz:pos ->
hs:hashes #hsz ->
Lemma (requires True)
(ensures forall (i:nat{i < S.length hs}).
S.index (hash_seq_lift #hsz hs) i == MTS.HRaw (S.index hs i))
(decreases (S.length hs)) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec hash_seq_lift_index #hsz hs =
if S.length hs = 0 then ()
else hash_seq_lift_index #hsz (S.tail hs) | val hash_seq_lift_index:
#hsz:pos ->
hs:hashes #hsz ->
Lemma (requires True)
(ensures forall (i:nat{i < S.length hs}).
S.index (hash_seq_lift #hsz hs) i == MTS.HRaw (S.index hs i))
(decreases (S.length hs))
let rec hash_seq_lift_index #hsz hs = | false | null | true | if S.length hs = 0 then () else hash_seq_lift_index #hsz (S.tail hs) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"lemma",
""
] | [
"Prims.pos",
"MerkleTree.New.High.hashes",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hash",
"Prims.bool",
"MerkleTree.New.High.Correct.Base.hash_seq_lift_index",
"FStar.Seq.Properties.tail",
"Prims.unit"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j)
val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i)
let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2
val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_olds_inv #hsz lv i olds =
if lv = 32 then true
else (let ofs = offset_of i in
S.length (S.index olds lv) == ofs /\
mt_olds_inv #hsz (lv + 1) (i / 2) olds)
val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv))
let rec mt_olds_inv_equiv #hsz #f lv i olds1 olds2 =
if lv = 32 then ()
else (assert (S.index olds1 lv == S.index olds2 lv);
mt_olds_inv_equiv #_ #f (lv + 1) (i / 2) olds1 olds2)
val mt_olds_hs_lth_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs))
(decreases (32 - lv))
let rec mt_olds_hs_lth_inv_ok #hsz #f lv i j olds hs =
if lv = 32 then ()
else (mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs)
val mt_olds_hs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
GTot Type0
let mt_olds_hs_inv #hsz #f lv i j olds hs =
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs)
// Relation between valid internal hashes (satisfying `mt_olds_hs_inv`) and
// the spec. While giving such relation, all rightmost hashes are recovered.
// Note that `MT?.rhs` after `construct_rhs` does NOT contain all rightmost
// hashes; it has partial rightmost hashes that are enough to calculate
// Merkle paths.
val log2: n:nat{n > 0} -> GTot (c:nat{pow2 c <= n && n < pow2 (c+1)})
let rec log2 n =
if n = 1 then 0
else 1 + log2 (n / 2)
val log2_bound:
n:nat{n > 0} -> c:nat{n < pow2 c} ->
Lemma (log2 n <= c-1)
let rec log2_bound n c =
if n = 1 then ()
else log2_bound (n / 2) (c - 1)
val log2_div:
n:nat{n > 1} ->
Lemma (log2 (n / 2) = log2 n - 1)
let log2_div n = ()
val log2c:
n:nat ->
GTot (c:nat{c = 0 || (pow2 (c-1) <= n && n < pow2 c)})
let log2c n =
if n = 0 then 0 else (log2 n + 1)
val log2c_div:
n:nat{n > 0} ->
Lemma (log2c (n / 2) = log2c n - 1)
let log2c_div n = ()
val log2c_bound:
n:nat -> c:nat{n < pow2 c} ->
Lemma (log2c n <= c)
let rec log2c_bound n c =
if n = 0 then ()
else log2c_bound (n / 2) (c - 1)
val mt_hashes_lth_inv_log:
#hsz:pos ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
GTot Type0 (decreases j)
let rec mt_hashes_lth_inv_log #hsz j fhs =
if j = 0 then true
else (S.length (S.head fhs) == j /\
mt_hashes_lth_inv_log #hsz (j / 2) (S.tail fhs))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_lth_inv_log_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
Lemma (requires mt_hashes_lth_inv_log #hsz j fhs)
(ensures S.length (S.head fhs) == j /\
S.length (S.head (S.tail fhs)) == j / 2)
let mt_hashes_lth_inv_log_next #_ #_ _ _ = ()
val mt_hashes_inv_log:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j /\ mt_hashes_lth_inv_log #hsz j fhs} ->
GTot Type0 (decreases j)
let rec mt_hashes_inv_log #hsz #f j fhs =
if j <= 1 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs 0) (S.index fhs 1) /\
mt_hashes_inv_log #_ #f (j / 2) (S.tail fhs))
val mt_hashes_lth_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log #hsz j (S.slice fhs lv (lv + log2c j))))
(decreases j)
let rec mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs =
if j = 0 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log #hsz j (S.slice fhs 0 (log2c j))))
let mt_hashes_lth_inv_log_converted #_ #f j fhs =
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs
val mt_hashes_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j > 0 && j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz lv j fhs} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs lv (lv + log2c j))))
(decreases j)
#pop-options
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
let rec mt_hashes_inv_log_converted_ #_ #f lv j fhs =
if j = 1 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs;
mt_hashes_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
#pop-options
val mt_hashes_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 0 && j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz 0 j fhs} ->
Lemma (requires mt_hashes_inv #_ #f 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs 0 (log2c j))))
let mt_hashes_inv_log_converted #_ #f j fhs =
mt_hashes_inv_log_converted_ #_ #f 0 j fhs
val hash_seq_lift:
#hsz:pos ->
hs:hashes #hsz ->
GTot (shs:MTS.hashes #hsz {S.length shs = S.length hs})
(decreases (S.length hs))
let rec hash_seq_lift #hsz hs =
if S.length hs = 0 then S.empty
else S.cons (MTS.HRaw (S.head hs)) (hash_seq_lift #hsz (S.tail hs))
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
val hash_seq_lift_index:
#hsz:pos ->
hs:hashes #hsz ->
Lemma (requires True)
(ensures forall (i:nat{i < S.length hs}).
S.index (hash_seq_lift #hsz hs) i == MTS.HRaw (S.index hs i))
(decreases (S.length hs)) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_seq_lift_index:
#hsz:pos ->
hs:hashes #hsz ->
Lemma (requires True)
(ensures forall (i:nat{i < S.length hs}).
S.index (hash_seq_lift #hsz hs) i == MTS.HRaw (S.index hs i))
(decreases (S.length hs)) | [
"recursion"
] | MerkleTree.New.High.Correct.Base.hash_seq_lift_index | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | hs: MerkleTree.New.High.hashes
-> FStar.Pervasives.Lemma
(ensures
forall (i: Prims.nat{i < FStar.Seq.Base.length hs}).
FStar.Seq.Base.index (MerkleTree.New.High.Correct.Base.hash_seq_lift hs) i ==
MerkleTree.Spec.HRaw (FStar.Seq.Base.index hs i)) (decreases FStar.Seq.Base.length hs) | {
"end_col": 43,
"end_line": 423,
"start_col": 2,
"start_line": 422
} |
FStar.Pervasives.Lemma | val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i)) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j) | val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j = | false | null | true | if i = j
then ()
else
(assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"lemma",
""
] | [
"Prims.pos",
"MerkleTree.Spec.hash_fun_t",
"MerkleTree.New.High.hashess",
"Prims.b2t",
"Prims.op_Equality",
"Prims.nat",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hashes",
"Prims.op_AmpAmp",
"Prims.op_LessThanOrEqual",
"Prims.bool",
"MerkleTree.New.High.Correct.Base.merge_hs_slice_equal",
"Prims.op_Addition",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"FStar.Seq.Base.index"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i)) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i)) | [
"recursion"
] | MerkleTree.New.High.Correct.Base.merge_hs_slice_equal | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
ahs1: MerkleTree.New.High.hashess ->
ahs2: MerkleTree.New.High.hashess{FStar.Seq.Base.length ahs1 = FStar.Seq.Base.length ahs2} ->
bhs1: MerkleTree.New.High.hashess ->
bhs2: MerkleTree.New.High.hashess{FStar.Seq.Base.length bhs1 = FStar.Seq.Base.length bhs2} ->
i: Prims.nat ->
j: Prims.nat{i <= j && j <= FStar.Seq.Base.length ahs1 && j <= FStar.Seq.Base.length bhs1}
-> FStar.Pervasives.Lemma
(requires
FStar.Seq.Base.equal (FStar.Seq.Base.slice ahs1 i j) (FStar.Seq.Base.slice bhs1 i j) /\
FStar.Seq.Base.equal (FStar.Seq.Base.slice ahs2 i j) (FStar.Seq.Base.slice bhs2 i j))
(ensures
FStar.Seq.Base.equal (FStar.Seq.Base.slice (MerkleTree.New.High.Correct.Base.merge_hs ahs1
ahs2)
i
j)
(FStar.Seq.Base.slice (MerkleTree.New.High.Correct.Base.merge_hs bhs1 bhs2) i j))
(decreases j - i) | {
"end_col": 64,
"end_line": 206,
"start_col": 2,
"start_line": 203
} |
FStar.Pervasives.Lemma | val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2 | val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i)
let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 = | false | null | true | if S.length hs1 = 0
then ()
else if i = 0 then () else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2 | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"lemma",
""
] | [
"Prims.pos",
"MerkleTree.Spec.hash_fun_t",
"MerkleTree.New.High.hashess",
"Prims.b2t",
"Prims.op_Equality",
"Prims.nat",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hashes",
"Prims.op_LessThan",
"Prims.int",
"Prims.bool",
"MerkleTree.New.High.Correct.Base.merge_hs_upd",
"FStar.Seq.Properties.tail",
"Prims.op_Subtraction",
"Prims.unit"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j)
val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i) | [
"recursion"
] | MerkleTree.New.High.Correct.Base.merge_hs_upd | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
hs1: MerkleTree.New.High.hashess ->
hs2: MerkleTree.New.High.hashess{FStar.Seq.Base.length hs1 = FStar.Seq.Base.length hs2} ->
i: Prims.nat{i < FStar.Seq.Base.length hs1} ->
v1: MerkleTree.New.High.hashes ->
v2: MerkleTree.New.High.hashes
-> FStar.Pervasives.Lemma
(requires
FStar.Seq.Base.equal (FStar.Seq.Base.append (FStar.Seq.Base.index hs1 i)
(FStar.Seq.Base.index hs2 i))
(FStar.Seq.Base.append v1 v2))
(ensures
FStar.Seq.Base.equal (MerkleTree.New.High.Correct.Base.merge_hs hs1 hs2)
(MerkleTree.New.High.Correct.Base.merge_hs (FStar.Seq.Base.upd hs1 i v1)
(FStar.Seq.Base.upd hs2 i v2)))
(decreases i) | {
"end_col": 65,
"end_line": 222,
"start_col": 2,
"start_line": 220
} |
Prims.GTot | val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv)) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs) | val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs = | false | null | false | if lv = 32 then true else (S.length (S.index fhs lv) == j /\ mt_hashes_lth_inv (lv + 1) (j / 2) fhs) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"sometrivial",
""
] | [
"Prims.pos",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.pow2",
"Prims.op_Subtraction",
"MerkleTree.New.High.hashess",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hashes",
"Prims.bool",
"Prims.l_and",
"Prims.eq2",
"MerkleTree.New.High.hash",
"FStar.Seq.Base.index",
"MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv",
"Prims.op_Addition",
"Prims.op_Division"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv)) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv)) | [
"recursion"
] | MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
lv: Prims.nat{lv <= 32} ->
j: Prims.nat{j < Prims.pow2 (32 - lv)} ->
fhs: MerkleTree.New.High.hashess{FStar.Seq.Base.length fhs = 32}
-> Prims.GTot Type0 | {
"end_col": 46,
"end_line": 65,
"start_col": 2,
"start_line": 63
} |
FStar.Pervasives.Lemma | val mt_hashes_lth_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log #hsz j (S.slice fhs lv (lv + log2c j))))
(decreases j) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs =
if j = 0 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs) | val mt_hashes_lth_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log #hsz j (S.slice fhs lv (lv + log2c j))))
(decreases j)
let rec mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs = | false | null | true | if j = 0
then ()
else
(log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"lemma",
""
] | [
"Prims.pos",
"MerkleTree.Spec.hash_fun_t",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.pow2",
"Prims.op_Subtraction",
"MerkleTree.New.High.hashess",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hashes",
"Prims.bool",
"MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv_log_converted_",
"Prims.op_Addition",
"Prims.op_Division",
"Prims.unit",
"MerkleTree.New.High.Correct.Base.log2c_bound"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j)
val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i)
let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2
val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_olds_inv #hsz lv i olds =
if lv = 32 then true
else (let ofs = offset_of i in
S.length (S.index olds lv) == ofs /\
mt_olds_inv #hsz (lv + 1) (i / 2) olds)
val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv))
let rec mt_olds_inv_equiv #hsz #f lv i olds1 olds2 =
if lv = 32 then ()
else (assert (S.index olds1 lv == S.index olds2 lv);
mt_olds_inv_equiv #_ #f (lv + 1) (i / 2) olds1 olds2)
val mt_olds_hs_lth_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs))
(decreases (32 - lv))
let rec mt_olds_hs_lth_inv_ok #hsz #f lv i j olds hs =
if lv = 32 then ()
else (mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs)
val mt_olds_hs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
GTot Type0
let mt_olds_hs_inv #hsz #f lv i j olds hs =
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs)
// Relation between valid internal hashes (satisfying `mt_olds_hs_inv`) and
// the spec. While giving such relation, all rightmost hashes are recovered.
// Note that `MT?.rhs` after `construct_rhs` does NOT contain all rightmost
// hashes; it has partial rightmost hashes that are enough to calculate
// Merkle paths.
val log2: n:nat{n > 0} -> GTot (c:nat{pow2 c <= n && n < pow2 (c+1)})
let rec log2 n =
if n = 1 then 0
else 1 + log2 (n / 2)
val log2_bound:
n:nat{n > 0} -> c:nat{n < pow2 c} ->
Lemma (log2 n <= c-1)
let rec log2_bound n c =
if n = 1 then ()
else log2_bound (n / 2) (c - 1)
val log2_div:
n:nat{n > 1} ->
Lemma (log2 (n / 2) = log2 n - 1)
let log2_div n = ()
val log2c:
n:nat ->
GTot (c:nat{c = 0 || (pow2 (c-1) <= n && n < pow2 c)})
let log2c n =
if n = 0 then 0 else (log2 n + 1)
val log2c_div:
n:nat{n > 0} ->
Lemma (log2c (n / 2) = log2c n - 1)
let log2c_div n = ()
val log2c_bound:
n:nat -> c:nat{n < pow2 c} ->
Lemma (log2c n <= c)
let rec log2c_bound n c =
if n = 0 then ()
else log2c_bound (n / 2) (c - 1)
val mt_hashes_lth_inv_log:
#hsz:pos ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
GTot Type0 (decreases j)
let rec mt_hashes_lth_inv_log #hsz j fhs =
if j = 0 then true
else (S.length (S.head fhs) == j /\
mt_hashes_lth_inv_log #hsz (j / 2) (S.tail fhs))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_lth_inv_log_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
Lemma (requires mt_hashes_lth_inv_log #hsz j fhs)
(ensures S.length (S.head fhs) == j /\
S.length (S.head (S.tail fhs)) == j / 2)
let mt_hashes_lth_inv_log_next #_ #_ _ _ = ()
val mt_hashes_inv_log:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j /\ mt_hashes_lth_inv_log #hsz j fhs} ->
GTot Type0 (decreases j)
let rec mt_hashes_inv_log #hsz #f j fhs =
if j <= 1 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs 0) (S.index fhs 1) /\
mt_hashes_inv_log #_ #f (j / 2) (S.tail fhs))
val mt_hashes_lth_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log #hsz j (S.slice fhs lv (lv + log2c j))))
(decreases j) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mt_hashes_lth_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log #hsz j (S.slice fhs lv (lv + log2c j))))
(decreases j) | [
"recursion"
] | MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv_log_converted_ | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
lv: Prims.nat{lv <= 32} ->
j: Prims.nat{j < Prims.pow2 (32 - lv)} ->
fhs: MerkleTree.New.High.hashess{FStar.Seq.Base.length fhs = 32}
-> FStar.Pervasives.Lemma (requires MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv lv j fhs)
(ensures
([@@ FStar.Pervasives.inline_let ]let _ =
MerkleTree.New.High.Correct.Base.log2c_bound j (32 - lv)
in
MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv_log j
(FStar.Seq.Base.slice fhs lv (lv + MerkleTree.New.High.Correct.Base.log2c j))))
(decreases j) | {
"end_col": 67,
"end_line": 361,
"start_col": 2,
"start_line": 359
} |
FStar.Pervasives.Lemma | val hash_seq_spec_full_odd_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
acc:hash #hsz -> actd:bool -> nacc:hash #hsz ->
Lemma
(requires j % 2 = 1 /\
mt_hashes_next_rel #_ #f j hs nhs /\
nacc == (if actd then f (S.last hs) acc else S.last hs))
(ensures S.equal (hash_seq_spec_full #_ #f nhs nacc true)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f hs acc actd))) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_seq_spec_full_odd_next #hsz #f j hs nhs acc actd nacc =
log2c_div j;
mt_hashes_next_rel_lift_odd #_ #f j hs nhs;
if actd
then begin
MTS.mt_next_rel_upd_odd #_ #f (log2c j)
(hash_seq_spec #hsz hs)
(S.upd (hash_seq_spec #hsz nhs) (S.length nhs) (MTS.HRaw (S.last hs)))
(S.length nhs) (MTS.HRaw acc);
MTS.mt_next_rel_next_lv #_ #f (log2c j)
(S.upd (hash_seq_spec #hsz hs) (S.length hs) (MTS.HRaw acc))
(S.upd (hash_seq_spec #hsz nhs) (S.length nhs) (MTS.HRaw (f (S.last hs) acc)))
end
else MTS.mt_next_rel_next_lv #_ #f (log2c j)
(hash_seq_spec_full #_ #f hs acc actd)
(hash_seq_spec_full #_ #f nhs nacc true) | val hash_seq_spec_full_odd_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
acc:hash #hsz -> actd:bool -> nacc:hash #hsz ->
Lemma
(requires j % 2 = 1 /\
mt_hashes_next_rel #_ #f j hs nhs /\
nacc == (if actd then f (S.last hs) acc else S.last hs))
(ensures S.equal (hash_seq_spec_full #_ #f nhs nacc true)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f hs acc actd)))
let hash_seq_spec_full_odd_next #hsz #f j hs nhs acc actd nacc = | false | null | true | log2c_div j;
mt_hashes_next_rel_lift_odd #_ #f j hs nhs;
if actd
then
(MTS.mt_next_rel_upd_odd #_
#f
(log2c j)
(hash_seq_spec #hsz hs)
(S.upd (hash_seq_spec #hsz nhs) (S.length nhs) (MTS.HRaw (S.last hs)))
(S.length nhs)
(MTS.HRaw acc);
MTS.mt_next_rel_next_lv #_
#f
(log2c j)
(S.upd (hash_seq_spec #hsz hs) (S.length hs) (MTS.HRaw acc))
(S.upd (hash_seq_spec #hsz nhs) (S.length nhs) (MTS.HRaw (f (S.last hs) acc))))
else
MTS.mt_next_rel_next_lv #_
#f
(log2c j)
(hash_seq_spec_full #_ #f hs acc actd)
(hash_seq_spec_full #_ #f nhs nacc true) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"lemma"
] | [
"Prims.pos",
"MerkleTree.Spec.hash_fun_t",
"Prims.nat",
"Prims.b2t",
"Prims.op_GreaterThan",
"MerkleTree.New.High.hashes",
"Prims.op_Equality",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hash",
"Prims.int",
"Prims.op_Division",
"Prims.bool",
"MerkleTree.Spec.mt_next_rel_next_lv",
"MerkleTree.New.High.Correct.Base.log2c",
"FStar.Seq.Base.upd",
"MerkleTree.Spec.padded_hash",
"MerkleTree.New.High.Correct.Base.hash_seq_spec",
"MerkleTree.Spec.HRaw",
"FStar.Seq.Properties.last",
"Prims.unit",
"MerkleTree.Spec.mt_next_rel_upd_odd",
"MerkleTree.New.High.Correct.Base.hash_seq_spec_full",
"MerkleTree.New.High.Correct.Base.mt_hashes_next_rel_lift_odd",
"MerkleTree.New.High.Correct.Base.log2c_div"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j)
val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i)
let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2
val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_olds_inv #hsz lv i olds =
if lv = 32 then true
else (let ofs = offset_of i in
S.length (S.index olds lv) == ofs /\
mt_olds_inv #hsz (lv + 1) (i / 2) olds)
val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv))
let rec mt_olds_inv_equiv #hsz #f lv i olds1 olds2 =
if lv = 32 then ()
else (assert (S.index olds1 lv == S.index olds2 lv);
mt_olds_inv_equiv #_ #f (lv + 1) (i / 2) olds1 olds2)
val mt_olds_hs_lth_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs))
(decreases (32 - lv))
let rec mt_olds_hs_lth_inv_ok #hsz #f lv i j olds hs =
if lv = 32 then ()
else (mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs)
val mt_olds_hs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
GTot Type0
let mt_olds_hs_inv #hsz #f lv i j olds hs =
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs)
// Relation between valid internal hashes (satisfying `mt_olds_hs_inv`) and
// the spec. While giving such relation, all rightmost hashes are recovered.
// Note that `MT?.rhs` after `construct_rhs` does NOT contain all rightmost
// hashes; it has partial rightmost hashes that are enough to calculate
// Merkle paths.
val log2: n:nat{n > 0} -> GTot (c:nat{pow2 c <= n && n < pow2 (c+1)})
let rec log2 n =
if n = 1 then 0
else 1 + log2 (n / 2)
val log2_bound:
n:nat{n > 0} -> c:nat{n < pow2 c} ->
Lemma (log2 n <= c-1)
let rec log2_bound n c =
if n = 1 then ()
else log2_bound (n / 2) (c - 1)
val log2_div:
n:nat{n > 1} ->
Lemma (log2 (n / 2) = log2 n - 1)
let log2_div n = ()
val log2c:
n:nat ->
GTot (c:nat{c = 0 || (pow2 (c-1) <= n && n < pow2 c)})
let log2c n =
if n = 0 then 0 else (log2 n + 1)
val log2c_div:
n:nat{n > 0} ->
Lemma (log2c (n / 2) = log2c n - 1)
let log2c_div n = ()
val log2c_bound:
n:nat -> c:nat{n < pow2 c} ->
Lemma (log2c n <= c)
let rec log2c_bound n c =
if n = 0 then ()
else log2c_bound (n / 2) (c - 1)
val mt_hashes_lth_inv_log:
#hsz:pos ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
GTot Type0 (decreases j)
let rec mt_hashes_lth_inv_log #hsz j fhs =
if j = 0 then true
else (S.length (S.head fhs) == j /\
mt_hashes_lth_inv_log #hsz (j / 2) (S.tail fhs))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_lth_inv_log_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
Lemma (requires mt_hashes_lth_inv_log #hsz j fhs)
(ensures S.length (S.head fhs) == j /\
S.length (S.head (S.tail fhs)) == j / 2)
let mt_hashes_lth_inv_log_next #_ #_ _ _ = ()
val mt_hashes_inv_log:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j /\ mt_hashes_lth_inv_log #hsz j fhs} ->
GTot Type0 (decreases j)
let rec mt_hashes_inv_log #hsz #f j fhs =
if j <= 1 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs 0) (S.index fhs 1) /\
mt_hashes_inv_log #_ #f (j / 2) (S.tail fhs))
val mt_hashes_lth_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log #hsz j (S.slice fhs lv (lv + log2c j))))
(decreases j)
let rec mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs =
if j = 0 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log #hsz j (S.slice fhs 0 (log2c j))))
let mt_hashes_lth_inv_log_converted #_ #f j fhs =
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs
val mt_hashes_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j > 0 && j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz lv j fhs} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs lv (lv + log2c j))))
(decreases j)
#pop-options
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
let rec mt_hashes_inv_log_converted_ #_ #f lv j fhs =
if j = 1 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs;
mt_hashes_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
#pop-options
val mt_hashes_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 0 && j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz 0 j fhs} ->
Lemma (requires mt_hashes_inv #_ #f 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs 0 (log2c j))))
let mt_hashes_inv_log_converted #_ #f j fhs =
mt_hashes_inv_log_converted_ #_ #f 0 j fhs
val hash_seq_lift:
#hsz:pos ->
hs:hashes #hsz ->
GTot (shs:MTS.hashes #hsz {S.length shs = S.length hs})
(decreases (S.length hs))
let rec hash_seq_lift #hsz hs =
if S.length hs = 0 then S.empty
else S.cons (MTS.HRaw (S.head hs)) (hash_seq_lift #hsz (S.tail hs))
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
val hash_seq_lift_index:
#hsz:pos ->
hs:hashes #hsz ->
Lemma (requires True)
(ensures forall (i:nat{i < S.length hs}).
S.index (hash_seq_lift #hsz hs) i == MTS.HRaw (S.index hs i))
(decreases (S.length hs))
let rec hash_seq_lift_index #hsz hs =
if S.length hs = 0 then ()
else hash_seq_lift_index #hsz (S.tail hs)
#pop-options
val create_pads: #hsz:pos -> len:nat -> GTot (pads:MTS.hashes #hsz {S.length pads = len})
let create_pads #hsz len = S.create len (MTS.HPad #hsz)
val hash_seq_spec:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
GTot (MTS.merkle_tree #hsz (log2c (S.length hs)))
let hash_seq_spec #hsz hs =
S.append (hash_seq_lift #hsz hs)
(create_pads (pow2 (log2c (S.length hs)) - S.length hs))
val hash_seq_spec_index_raw:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
i:nat{i < S.length hs} ->
Lemma (S.index (hash_seq_spec #hsz hs) i == MTS.HRaw #hsz (S.index hs i))
let hash_seq_spec_index_raw #hsz hs i =
hash_seq_lift_index #hsz hs
// Now about recovering rightmost hashes
#push-options "--z3rlimit 50 --initial_fuel 1 --max_fuel 1"
val mt_hashes_next_rel_lift_even:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures MTS.mt_next_rel #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs))
let mt_hashes_next_rel_lift_even #hsz #_ j hs nhs =
hash_seq_lift_index #hsz hs;
hash_seq_lift_index #hsz nhs
val mt_hashes_next_rel_lift_odd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 1 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures MTS.mt_next_rel #_ #f (log2c j)
(hash_seq_spec #hsz hs)
(S.upd (hash_seq_spec #hsz nhs)
(S.length nhs) (MTS.HRaw (S.last hs))))
let mt_hashes_next_rel_lift_odd #hsz #_ j hs nhs =
log2c_div j;
hash_seq_lift_index #hsz hs;
hash_seq_lift_index #hsz nhs
val mt_hashes_next_rel_next_even:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures S.equal (hash_seq_spec #hsz nhs)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec #hsz hs)))
let mt_hashes_next_rel_next_even #hsz #f j hs nhs =
log2c_div j;
mt_hashes_next_rel_lift_even #_ #f j hs nhs;
MTS.mt_next_rel_next_lv #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs)
val hash_seq_spec_full:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs:hashes #hsz {S.length hs > 0} ->
acc:hash #hsz -> actd:bool ->
GTot (MTS.merkle_tree #hsz (log2c (S.length hs)))
let hash_seq_spec_full #hsz #f hs acc actd =
if actd
then (S.upd (hash_seq_spec #hsz hs) (S.length hs) (MTS.HRaw acc))
else hash_seq_spec #hsz hs
val hash_seq_spec_full_index_raw:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs:hashes #hsz {S.length hs > 0} ->
acc:hash #hsz -> actd:bool -> i:nat{i < S.length hs} ->
Lemma (S.index (hash_seq_spec_full #_ #f hs acc actd) i ==
MTS.HRaw (S.index hs i))
let hash_seq_spec_full_index_raw #hsz #_ hs acc actd i =
hash_seq_spec_index_raw #hsz hs i
val hash_seq_spec_full_case_true:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs:hashes #hsz {S.length hs > 0} -> acc:hash #hsz ->
Lemma (S.index (hash_seq_spec_full #_ #f hs acc true) (S.length hs) == MTS.HRaw acc)
let hash_seq_spec_full_case_true #_ #_ _ _ = ()
val hash_seq_spec_full_even_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 0} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
acc:hash #hsz -> actd:bool ->
Lemma
(requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures S.equal (hash_seq_spec_full #_ #f nhs acc actd)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f hs acc actd)))
#restart-solver
#push-options "--quake 1/3 --z3rlimit 100 --fuel 2 --ifuel 1"
let hash_seq_spec_full_even_next #hsz #f j hs nhs acc actd =
log2c_div j;
mt_hashes_next_rel_lift_even #_ #f j hs nhs;
if actd
then begin
MTS.mt_next_rel_upd_even_pad #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs) (S.length hs / 2) (MTS.HRaw acc);
let n = log2c j in
let mt = S.upd (hash_seq_spec #hsz hs) (S.length hs) (MTS.HRaw acc) in
let nmt = S.upd (hash_seq_spec #hsz nhs) (S.length nhs) (MTS.HRaw acc) in
// assume (MTS.mt_next_rel #_ #f n mt nmt);
MTS.mt_next_rel_next_lv #_ #f n mt nmt
end
else MTS.mt_next_rel_next_lv #_ #f (log2c j)
(hash_seq_spec_full #_ #f hs acc actd)
(hash_seq_spec_full #_ #f nhs acc actd)
#pop-options
#push-options "--z3rlimit 80"
val hash_seq_spec_full_odd_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
acc:hash #hsz -> actd:bool -> nacc:hash #hsz ->
Lemma
(requires j % 2 = 1 /\
mt_hashes_next_rel #_ #f j hs nhs /\
nacc == (if actd then f (S.last hs) acc else S.last hs))
(ensures S.equal (hash_seq_spec_full #_ #f nhs nacc true)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f hs acc actd))) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 80,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_seq_spec_full_odd_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
acc:hash #hsz -> actd:bool -> nacc:hash #hsz ->
Lemma
(requires j % 2 = 1 /\
mt_hashes_next_rel #_ #f j hs nhs /\
nacc == (if actd then f (S.last hs) acc else S.last hs))
(ensures S.equal (hash_seq_spec_full #_ #f nhs nacc true)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f hs acc actd))) | [] | MerkleTree.New.High.Correct.Base.hash_seq_spec_full_odd_next | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
j: Prims.nat{j > 1} ->
hs: MerkleTree.New.High.hashes{FStar.Seq.Base.length hs = j} ->
nhs: MerkleTree.New.High.hashes{FStar.Seq.Base.length nhs = j / 2} ->
acc: MerkleTree.New.High.hash ->
actd: Prims.bool ->
nacc: MerkleTree.New.High.hash
-> FStar.Pervasives.Lemma
(requires
j % 2 = 1 /\ MerkleTree.New.High.Correct.Base.mt_hashes_next_rel j hs nhs /\
nacc ==
(match actd with
| true -> f (FStar.Seq.Properties.last hs) acc
| _ -> FStar.Seq.Properties.last hs))
(ensures
FStar.Seq.Base.equal (MerkleTree.New.High.Correct.Base.hash_seq_spec_full nhs nacc true)
(MerkleTree.Spec.mt_next_lv (MerkleTree.New.High.Correct.Base.hash_seq_spec_full hs
acc
actd))) | {
"end_col": 49,
"end_line": 573,
"start_col": 2,
"start_line": 559
} |
FStar.Pervasives.Lemma | val mt_hashes_next_rel_lift_even:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures MTS.mt_next_rel #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs)) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mt_hashes_next_rel_lift_even #hsz #_ j hs nhs =
hash_seq_lift_index #hsz hs;
hash_seq_lift_index #hsz nhs | val mt_hashes_next_rel_lift_even:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures MTS.mt_next_rel #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs))
let mt_hashes_next_rel_lift_even #hsz #_ j hs nhs = | false | null | true | hash_seq_lift_index #hsz hs;
hash_seq_lift_index #hsz nhs | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"lemma"
] | [
"Prims.pos",
"MerkleTree.Spec.hash_fun_t",
"Prims.nat",
"Prims.b2t",
"Prims.op_GreaterThan",
"MerkleTree.New.High.hashes",
"Prims.op_Equality",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hash",
"Prims.int",
"Prims.op_Division",
"MerkleTree.New.High.Correct.Base.hash_seq_lift_index",
"Prims.unit"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j)
val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i)
let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2
val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_olds_inv #hsz lv i olds =
if lv = 32 then true
else (let ofs = offset_of i in
S.length (S.index olds lv) == ofs /\
mt_olds_inv #hsz (lv + 1) (i / 2) olds)
val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv))
let rec mt_olds_inv_equiv #hsz #f lv i olds1 olds2 =
if lv = 32 then ()
else (assert (S.index olds1 lv == S.index olds2 lv);
mt_olds_inv_equiv #_ #f (lv + 1) (i / 2) olds1 olds2)
val mt_olds_hs_lth_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs))
(decreases (32 - lv))
let rec mt_olds_hs_lth_inv_ok #hsz #f lv i j olds hs =
if lv = 32 then ()
else (mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs)
val mt_olds_hs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
GTot Type0
let mt_olds_hs_inv #hsz #f lv i j olds hs =
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs)
// Relation between valid internal hashes (satisfying `mt_olds_hs_inv`) and
// the spec. While giving such relation, all rightmost hashes are recovered.
// Note that `MT?.rhs` after `construct_rhs` does NOT contain all rightmost
// hashes; it has partial rightmost hashes that are enough to calculate
// Merkle paths.
val log2: n:nat{n > 0} -> GTot (c:nat{pow2 c <= n && n < pow2 (c+1)})
let rec log2 n =
if n = 1 then 0
else 1 + log2 (n / 2)
val log2_bound:
n:nat{n > 0} -> c:nat{n < pow2 c} ->
Lemma (log2 n <= c-1)
let rec log2_bound n c =
if n = 1 then ()
else log2_bound (n / 2) (c - 1)
val log2_div:
n:nat{n > 1} ->
Lemma (log2 (n / 2) = log2 n - 1)
let log2_div n = ()
val log2c:
n:nat ->
GTot (c:nat{c = 0 || (pow2 (c-1) <= n && n < pow2 c)})
let log2c n =
if n = 0 then 0 else (log2 n + 1)
val log2c_div:
n:nat{n > 0} ->
Lemma (log2c (n / 2) = log2c n - 1)
let log2c_div n = ()
val log2c_bound:
n:nat -> c:nat{n < pow2 c} ->
Lemma (log2c n <= c)
let rec log2c_bound n c =
if n = 0 then ()
else log2c_bound (n / 2) (c - 1)
val mt_hashes_lth_inv_log:
#hsz:pos ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
GTot Type0 (decreases j)
let rec mt_hashes_lth_inv_log #hsz j fhs =
if j = 0 then true
else (S.length (S.head fhs) == j /\
mt_hashes_lth_inv_log #hsz (j / 2) (S.tail fhs))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_lth_inv_log_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
Lemma (requires mt_hashes_lth_inv_log #hsz j fhs)
(ensures S.length (S.head fhs) == j /\
S.length (S.head (S.tail fhs)) == j / 2)
let mt_hashes_lth_inv_log_next #_ #_ _ _ = ()
val mt_hashes_inv_log:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j /\ mt_hashes_lth_inv_log #hsz j fhs} ->
GTot Type0 (decreases j)
let rec mt_hashes_inv_log #hsz #f j fhs =
if j <= 1 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs 0) (S.index fhs 1) /\
mt_hashes_inv_log #_ #f (j / 2) (S.tail fhs))
val mt_hashes_lth_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log #hsz j (S.slice fhs lv (lv + log2c j))))
(decreases j)
let rec mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs =
if j = 0 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log #hsz j (S.slice fhs 0 (log2c j))))
let mt_hashes_lth_inv_log_converted #_ #f j fhs =
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs
val mt_hashes_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j > 0 && j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz lv j fhs} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs lv (lv + log2c j))))
(decreases j)
#pop-options
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
let rec mt_hashes_inv_log_converted_ #_ #f lv j fhs =
if j = 1 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs;
mt_hashes_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
#pop-options
val mt_hashes_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 0 && j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz 0 j fhs} ->
Lemma (requires mt_hashes_inv #_ #f 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs 0 (log2c j))))
let mt_hashes_inv_log_converted #_ #f j fhs =
mt_hashes_inv_log_converted_ #_ #f 0 j fhs
val hash_seq_lift:
#hsz:pos ->
hs:hashes #hsz ->
GTot (shs:MTS.hashes #hsz {S.length shs = S.length hs})
(decreases (S.length hs))
let rec hash_seq_lift #hsz hs =
if S.length hs = 0 then S.empty
else S.cons (MTS.HRaw (S.head hs)) (hash_seq_lift #hsz (S.tail hs))
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
val hash_seq_lift_index:
#hsz:pos ->
hs:hashes #hsz ->
Lemma (requires True)
(ensures forall (i:nat{i < S.length hs}).
S.index (hash_seq_lift #hsz hs) i == MTS.HRaw (S.index hs i))
(decreases (S.length hs))
let rec hash_seq_lift_index #hsz hs =
if S.length hs = 0 then ()
else hash_seq_lift_index #hsz (S.tail hs)
#pop-options
val create_pads: #hsz:pos -> len:nat -> GTot (pads:MTS.hashes #hsz {S.length pads = len})
let create_pads #hsz len = S.create len (MTS.HPad #hsz)
val hash_seq_spec:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
GTot (MTS.merkle_tree #hsz (log2c (S.length hs)))
let hash_seq_spec #hsz hs =
S.append (hash_seq_lift #hsz hs)
(create_pads (pow2 (log2c (S.length hs)) - S.length hs))
val hash_seq_spec_index_raw:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
i:nat{i < S.length hs} ->
Lemma (S.index (hash_seq_spec #hsz hs) i == MTS.HRaw #hsz (S.index hs i))
let hash_seq_spec_index_raw #hsz hs i =
hash_seq_lift_index #hsz hs
// Now about recovering rightmost hashes
#push-options "--z3rlimit 50 --initial_fuel 1 --max_fuel 1"
val mt_hashes_next_rel_lift_even:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures MTS.mt_next_rel #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs)) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mt_hashes_next_rel_lift_even:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures MTS.mt_next_rel #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs)) | [] | MerkleTree.New.High.Correct.Base.mt_hashes_next_rel_lift_even | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
j: Prims.nat{j > 1} ->
hs: MerkleTree.New.High.hashes{FStar.Seq.Base.length hs = j} ->
nhs: MerkleTree.New.High.hashes{FStar.Seq.Base.length nhs = j / 2}
-> FStar.Pervasives.Lemma
(requires j % 2 = 0 /\ MerkleTree.New.High.Correct.Base.mt_hashes_next_rel j hs nhs)
(ensures
MerkleTree.Spec.mt_next_rel (MerkleTree.New.High.Correct.Base.log2c j)
(MerkleTree.New.High.Correct.Base.hash_seq_spec hs)
(MerkleTree.New.High.Correct.Base.hash_seq_spec nhs)) | {
"end_col": 30,
"end_line": 458,
"start_col": 2,
"start_line": 457
} |
FStar.Pervasives.Lemma | val mt_hashes_next_rel_lift_odd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 1 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures MTS.mt_next_rel #_ #f (log2c j)
(hash_seq_spec #hsz hs)
(S.upd (hash_seq_spec #hsz nhs)
(S.length nhs) (MTS.HRaw (S.last hs)))) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mt_hashes_next_rel_lift_odd #hsz #_ j hs nhs =
log2c_div j;
hash_seq_lift_index #hsz hs;
hash_seq_lift_index #hsz nhs | val mt_hashes_next_rel_lift_odd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 1 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures MTS.mt_next_rel #_ #f (log2c j)
(hash_seq_spec #hsz hs)
(S.upd (hash_seq_spec #hsz nhs)
(S.length nhs) (MTS.HRaw (S.last hs))))
let mt_hashes_next_rel_lift_odd #hsz #_ j hs nhs = | false | null | true | log2c_div j;
hash_seq_lift_index #hsz hs;
hash_seq_lift_index #hsz nhs | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"lemma"
] | [
"Prims.pos",
"MerkleTree.Spec.hash_fun_t",
"Prims.nat",
"Prims.b2t",
"Prims.op_GreaterThan",
"MerkleTree.New.High.hashes",
"Prims.op_Equality",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hash",
"Prims.int",
"Prims.op_Division",
"MerkleTree.New.High.Correct.Base.hash_seq_lift_index",
"Prims.unit",
"MerkleTree.New.High.Correct.Base.log2c_div"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j)
val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i)
let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2
val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_olds_inv #hsz lv i olds =
if lv = 32 then true
else (let ofs = offset_of i in
S.length (S.index olds lv) == ofs /\
mt_olds_inv #hsz (lv + 1) (i / 2) olds)
val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv))
let rec mt_olds_inv_equiv #hsz #f lv i olds1 olds2 =
if lv = 32 then ()
else (assert (S.index olds1 lv == S.index olds2 lv);
mt_olds_inv_equiv #_ #f (lv + 1) (i / 2) olds1 olds2)
val mt_olds_hs_lth_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs))
(decreases (32 - lv))
let rec mt_olds_hs_lth_inv_ok #hsz #f lv i j olds hs =
if lv = 32 then ()
else (mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs)
val mt_olds_hs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
GTot Type0
let mt_olds_hs_inv #hsz #f lv i j olds hs =
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs)
// Relation between valid internal hashes (satisfying `mt_olds_hs_inv`) and
// the spec. While giving such relation, all rightmost hashes are recovered.
// Note that `MT?.rhs` after `construct_rhs` does NOT contain all rightmost
// hashes; it has partial rightmost hashes that are enough to calculate
// Merkle paths.
val log2: n:nat{n > 0} -> GTot (c:nat{pow2 c <= n && n < pow2 (c+1)})
let rec log2 n =
if n = 1 then 0
else 1 + log2 (n / 2)
val log2_bound:
n:nat{n > 0} -> c:nat{n < pow2 c} ->
Lemma (log2 n <= c-1)
let rec log2_bound n c =
if n = 1 then ()
else log2_bound (n / 2) (c - 1)
val log2_div:
n:nat{n > 1} ->
Lemma (log2 (n / 2) = log2 n - 1)
let log2_div n = ()
val log2c:
n:nat ->
GTot (c:nat{c = 0 || (pow2 (c-1) <= n && n < pow2 c)})
let log2c n =
if n = 0 then 0 else (log2 n + 1)
val log2c_div:
n:nat{n > 0} ->
Lemma (log2c (n / 2) = log2c n - 1)
let log2c_div n = ()
val log2c_bound:
n:nat -> c:nat{n < pow2 c} ->
Lemma (log2c n <= c)
let rec log2c_bound n c =
if n = 0 then ()
else log2c_bound (n / 2) (c - 1)
val mt_hashes_lth_inv_log:
#hsz:pos ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
GTot Type0 (decreases j)
let rec mt_hashes_lth_inv_log #hsz j fhs =
if j = 0 then true
else (S.length (S.head fhs) == j /\
mt_hashes_lth_inv_log #hsz (j / 2) (S.tail fhs))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_lth_inv_log_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
Lemma (requires mt_hashes_lth_inv_log #hsz j fhs)
(ensures S.length (S.head fhs) == j /\
S.length (S.head (S.tail fhs)) == j / 2)
let mt_hashes_lth_inv_log_next #_ #_ _ _ = ()
val mt_hashes_inv_log:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j /\ mt_hashes_lth_inv_log #hsz j fhs} ->
GTot Type0 (decreases j)
let rec mt_hashes_inv_log #hsz #f j fhs =
if j <= 1 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs 0) (S.index fhs 1) /\
mt_hashes_inv_log #_ #f (j / 2) (S.tail fhs))
val mt_hashes_lth_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log #hsz j (S.slice fhs lv (lv + log2c j))))
(decreases j)
let rec mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs =
if j = 0 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log #hsz j (S.slice fhs 0 (log2c j))))
let mt_hashes_lth_inv_log_converted #_ #f j fhs =
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs
val mt_hashes_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j > 0 && j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz lv j fhs} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs lv (lv + log2c j))))
(decreases j)
#pop-options
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
let rec mt_hashes_inv_log_converted_ #_ #f lv j fhs =
if j = 1 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs;
mt_hashes_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
#pop-options
val mt_hashes_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 0 && j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz 0 j fhs} ->
Lemma (requires mt_hashes_inv #_ #f 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs 0 (log2c j))))
let mt_hashes_inv_log_converted #_ #f j fhs =
mt_hashes_inv_log_converted_ #_ #f 0 j fhs
val hash_seq_lift:
#hsz:pos ->
hs:hashes #hsz ->
GTot (shs:MTS.hashes #hsz {S.length shs = S.length hs})
(decreases (S.length hs))
let rec hash_seq_lift #hsz hs =
if S.length hs = 0 then S.empty
else S.cons (MTS.HRaw (S.head hs)) (hash_seq_lift #hsz (S.tail hs))
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
val hash_seq_lift_index:
#hsz:pos ->
hs:hashes #hsz ->
Lemma (requires True)
(ensures forall (i:nat{i < S.length hs}).
S.index (hash_seq_lift #hsz hs) i == MTS.HRaw (S.index hs i))
(decreases (S.length hs))
let rec hash_seq_lift_index #hsz hs =
if S.length hs = 0 then ()
else hash_seq_lift_index #hsz (S.tail hs)
#pop-options
val create_pads: #hsz:pos -> len:nat -> GTot (pads:MTS.hashes #hsz {S.length pads = len})
let create_pads #hsz len = S.create len (MTS.HPad #hsz)
val hash_seq_spec:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
GTot (MTS.merkle_tree #hsz (log2c (S.length hs)))
let hash_seq_spec #hsz hs =
S.append (hash_seq_lift #hsz hs)
(create_pads (pow2 (log2c (S.length hs)) - S.length hs))
val hash_seq_spec_index_raw:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
i:nat{i < S.length hs} ->
Lemma (S.index (hash_seq_spec #hsz hs) i == MTS.HRaw #hsz (S.index hs i))
let hash_seq_spec_index_raw #hsz hs i =
hash_seq_lift_index #hsz hs
// Now about recovering rightmost hashes
#push-options "--z3rlimit 50 --initial_fuel 1 --max_fuel 1"
val mt_hashes_next_rel_lift_even:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures MTS.mt_next_rel #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs))
let mt_hashes_next_rel_lift_even #hsz #_ j hs nhs =
hash_seq_lift_index #hsz hs;
hash_seq_lift_index #hsz nhs
val mt_hashes_next_rel_lift_odd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 1 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures MTS.mt_next_rel #_ #f (log2c j)
(hash_seq_spec #hsz hs)
(S.upd (hash_seq_spec #hsz nhs)
(S.length nhs) (MTS.HRaw (S.last hs)))) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mt_hashes_next_rel_lift_odd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 1 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures MTS.mt_next_rel #_ #f (log2c j)
(hash_seq_spec #hsz hs)
(S.upd (hash_seq_spec #hsz nhs)
(S.length nhs) (MTS.HRaw (S.last hs)))) | [] | MerkleTree.New.High.Correct.Base.mt_hashes_next_rel_lift_odd | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
j: Prims.nat{j > 1} ->
hs: MerkleTree.New.High.hashes{FStar.Seq.Base.length hs = j} ->
nhs: MerkleTree.New.High.hashes{FStar.Seq.Base.length nhs = j / 2}
-> FStar.Pervasives.Lemma
(requires j % 2 = 1 /\ MerkleTree.New.High.Correct.Base.mt_hashes_next_rel j hs nhs)
(ensures
MerkleTree.Spec.mt_next_rel (MerkleTree.New.High.Correct.Base.log2c j)
(MerkleTree.New.High.Correct.Base.hash_seq_spec hs)
(FStar.Seq.Base.upd (MerkleTree.New.High.Correct.Base.hash_seq_spec nhs)
(FStar.Seq.Base.length nhs)
(MerkleTree.Spec.HRaw (FStar.Seq.Properties.last hs)))) | {
"end_col": 30,
"end_line": 473,
"start_col": 2,
"start_line": 471
} |
FStar.Pervasives.Lemma | val log2c_bound:
n:nat -> c:nat{n < pow2 c} ->
Lemma (log2c n <= c) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec log2c_bound n c =
if n = 0 then ()
else log2c_bound (n / 2) (c - 1) | val log2c_bound:
n:nat -> c:nat{n < pow2 c} ->
Lemma (log2c n <= c)
let rec log2c_bound n c = | false | null | true | if n = 0 then () else log2c_bound (n / 2) (c - 1) | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"lemma"
] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.pow2",
"Prims.op_Equality",
"Prims.int",
"Prims.bool",
"MerkleTree.New.High.Correct.Base.log2c_bound",
"Prims.op_Division",
"Prims.op_Subtraction",
"Prims.unit"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j)
val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i)
let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2
val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_olds_inv #hsz lv i olds =
if lv = 32 then true
else (let ofs = offset_of i in
S.length (S.index olds lv) == ofs /\
mt_olds_inv #hsz (lv + 1) (i / 2) olds)
val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv))
let rec mt_olds_inv_equiv #hsz #f lv i olds1 olds2 =
if lv = 32 then ()
else (assert (S.index olds1 lv == S.index olds2 lv);
mt_olds_inv_equiv #_ #f (lv + 1) (i / 2) olds1 olds2)
val mt_olds_hs_lth_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs))
(decreases (32 - lv))
let rec mt_olds_hs_lth_inv_ok #hsz #f lv i j olds hs =
if lv = 32 then ()
else (mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs)
val mt_olds_hs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
GTot Type0
let mt_olds_hs_inv #hsz #f lv i j olds hs =
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs)
// Relation between valid internal hashes (satisfying `mt_olds_hs_inv`) and
// the spec. While giving such relation, all rightmost hashes are recovered.
// Note that `MT?.rhs` after `construct_rhs` does NOT contain all rightmost
// hashes; it has partial rightmost hashes that are enough to calculate
// Merkle paths.
val log2: n:nat{n > 0} -> GTot (c:nat{pow2 c <= n && n < pow2 (c+1)})
let rec log2 n =
if n = 1 then 0
else 1 + log2 (n / 2)
val log2_bound:
n:nat{n > 0} -> c:nat{n < pow2 c} ->
Lemma (log2 n <= c-1)
let rec log2_bound n c =
if n = 1 then ()
else log2_bound (n / 2) (c - 1)
val log2_div:
n:nat{n > 1} ->
Lemma (log2 (n / 2) = log2 n - 1)
let log2_div n = ()
val log2c:
n:nat ->
GTot (c:nat{c = 0 || (pow2 (c-1) <= n && n < pow2 c)})
let log2c n =
if n = 0 then 0 else (log2 n + 1)
val log2c_div:
n:nat{n > 0} ->
Lemma (log2c (n / 2) = log2c n - 1)
let log2c_div n = ()
val log2c_bound:
n:nat -> c:nat{n < pow2 c} ->
Lemma (log2c n <= c) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val log2c_bound:
n:nat -> c:nat{n < pow2 c} ->
Lemma (log2c n <= c) | [
"recursion"
] | MerkleTree.New.High.Correct.Base.log2c_bound | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | n: Prims.nat -> c: Prims.nat{n < Prims.pow2 c}
-> FStar.Pervasives.Lemma (ensures MerkleTree.New.High.Correct.Base.log2c n <= c) | {
"end_col": 34,
"end_line": 316,
"start_col": 2,
"start_line": 315
} |
Prims.GTot | val hash_seq_spec_full:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs:hashes #hsz {S.length hs > 0} ->
acc:hash #hsz -> actd:bool ->
GTot (MTS.merkle_tree #hsz (log2c (S.length hs))) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_seq_spec_full #hsz #f hs acc actd =
if actd
then (S.upd (hash_seq_spec #hsz hs) (S.length hs) (MTS.HRaw acc))
else hash_seq_spec #hsz hs | val hash_seq_spec_full:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs:hashes #hsz {S.length hs > 0} ->
acc:hash #hsz -> actd:bool ->
GTot (MTS.merkle_tree #hsz (log2c (S.length hs)))
let hash_seq_spec_full #hsz #f hs acc actd = | false | null | false | if actd then (S.upd (hash_seq_spec #hsz hs) (S.length hs) (MTS.HRaw acc)) else hash_seq_spec #hsz hs | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"sometrivial"
] | [
"Prims.pos",
"MerkleTree.Spec.hash_fun_t",
"MerkleTree.New.High.hashes",
"Prims.b2t",
"Prims.op_GreaterThan",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hash",
"Prims.bool",
"FStar.Seq.Base.upd",
"MerkleTree.Spec.padded_hash",
"MerkleTree.New.High.Correct.Base.hash_seq_spec",
"MerkleTree.Spec.HRaw",
"MerkleTree.Spec.merkle_tree",
"MerkleTree.New.High.Correct.Base.log2c"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j)
val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i)
let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2
val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_olds_inv #hsz lv i olds =
if lv = 32 then true
else (let ofs = offset_of i in
S.length (S.index olds lv) == ofs /\
mt_olds_inv #hsz (lv + 1) (i / 2) olds)
val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv))
let rec mt_olds_inv_equiv #hsz #f lv i olds1 olds2 =
if lv = 32 then ()
else (assert (S.index olds1 lv == S.index olds2 lv);
mt_olds_inv_equiv #_ #f (lv + 1) (i / 2) olds1 olds2)
val mt_olds_hs_lth_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs))
(decreases (32 - lv))
let rec mt_olds_hs_lth_inv_ok #hsz #f lv i j olds hs =
if lv = 32 then ()
else (mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs)
val mt_olds_hs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
GTot Type0
let mt_olds_hs_inv #hsz #f lv i j olds hs =
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs)
// Relation between valid internal hashes (satisfying `mt_olds_hs_inv`) and
// the spec. While giving such relation, all rightmost hashes are recovered.
// Note that `MT?.rhs` after `construct_rhs` does NOT contain all rightmost
// hashes; it has partial rightmost hashes that are enough to calculate
// Merkle paths.
val log2: n:nat{n > 0} -> GTot (c:nat{pow2 c <= n && n < pow2 (c+1)})
let rec log2 n =
if n = 1 then 0
else 1 + log2 (n / 2)
val log2_bound:
n:nat{n > 0} -> c:nat{n < pow2 c} ->
Lemma (log2 n <= c-1)
let rec log2_bound n c =
if n = 1 then ()
else log2_bound (n / 2) (c - 1)
val log2_div:
n:nat{n > 1} ->
Lemma (log2 (n / 2) = log2 n - 1)
let log2_div n = ()
val log2c:
n:nat ->
GTot (c:nat{c = 0 || (pow2 (c-1) <= n && n < pow2 c)})
let log2c n =
if n = 0 then 0 else (log2 n + 1)
val log2c_div:
n:nat{n > 0} ->
Lemma (log2c (n / 2) = log2c n - 1)
let log2c_div n = ()
val log2c_bound:
n:nat -> c:nat{n < pow2 c} ->
Lemma (log2c n <= c)
let rec log2c_bound n c =
if n = 0 then ()
else log2c_bound (n / 2) (c - 1)
val mt_hashes_lth_inv_log:
#hsz:pos ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
GTot Type0 (decreases j)
let rec mt_hashes_lth_inv_log #hsz j fhs =
if j = 0 then true
else (S.length (S.head fhs) == j /\
mt_hashes_lth_inv_log #hsz (j / 2) (S.tail fhs))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_lth_inv_log_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
Lemma (requires mt_hashes_lth_inv_log #hsz j fhs)
(ensures S.length (S.head fhs) == j /\
S.length (S.head (S.tail fhs)) == j / 2)
let mt_hashes_lth_inv_log_next #_ #_ _ _ = ()
val mt_hashes_inv_log:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j /\ mt_hashes_lth_inv_log #hsz j fhs} ->
GTot Type0 (decreases j)
let rec mt_hashes_inv_log #hsz #f j fhs =
if j <= 1 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs 0) (S.index fhs 1) /\
mt_hashes_inv_log #_ #f (j / 2) (S.tail fhs))
val mt_hashes_lth_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log #hsz j (S.slice fhs lv (lv + log2c j))))
(decreases j)
let rec mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs =
if j = 0 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log #hsz j (S.slice fhs 0 (log2c j))))
let mt_hashes_lth_inv_log_converted #_ #f j fhs =
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs
val mt_hashes_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j > 0 && j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz lv j fhs} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs lv (lv + log2c j))))
(decreases j)
#pop-options
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
let rec mt_hashes_inv_log_converted_ #_ #f lv j fhs =
if j = 1 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs;
mt_hashes_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
#pop-options
val mt_hashes_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 0 && j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv #hsz 0 j fhs} ->
Lemma (requires mt_hashes_inv #_ #f 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs;
mt_hashes_inv_log #_ #f j (S.slice fhs 0 (log2c j))))
let mt_hashes_inv_log_converted #_ #f j fhs =
mt_hashes_inv_log_converted_ #_ #f 0 j fhs
val hash_seq_lift:
#hsz:pos ->
hs:hashes #hsz ->
GTot (shs:MTS.hashes #hsz {S.length shs = S.length hs})
(decreases (S.length hs))
let rec hash_seq_lift #hsz hs =
if S.length hs = 0 then S.empty
else S.cons (MTS.HRaw (S.head hs)) (hash_seq_lift #hsz (S.tail hs))
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2"
val hash_seq_lift_index:
#hsz:pos ->
hs:hashes #hsz ->
Lemma (requires True)
(ensures forall (i:nat{i < S.length hs}).
S.index (hash_seq_lift #hsz hs) i == MTS.HRaw (S.index hs i))
(decreases (S.length hs))
let rec hash_seq_lift_index #hsz hs =
if S.length hs = 0 then ()
else hash_seq_lift_index #hsz (S.tail hs)
#pop-options
val create_pads: #hsz:pos -> len:nat -> GTot (pads:MTS.hashes #hsz {S.length pads = len})
let create_pads #hsz len = S.create len (MTS.HPad #hsz)
val hash_seq_spec:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
GTot (MTS.merkle_tree #hsz (log2c (S.length hs)))
let hash_seq_spec #hsz hs =
S.append (hash_seq_lift #hsz hs)
(create_pads (pow2 (log2c (S.length hs)) - S.length hs))
val hash_seq_spec_index_raw:
#hsz:pos ->
hs:hashes #hsz {S.length hs > 0} ->
i:nat{i < S.length hs} ->
Lemma (S.index (hash_seq_spec #hsz hs) i == MTS.HRaw #hsz (S.index hs i))
let hash_seq_spec_index_raw #hsz hs i =
hash_seq_lift_index #hsz hs
// Now about recovering rightmost hashes
#push-options "--z3rlimit 50 --initial_fuel 1 --max_fuel 1"
val mt_hashes_next_rel_lift_even:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures MTS.mt_next_rel #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs))
let mt_hashes_next_rel_lift_even #hsz #_ j hs nhs =
hash_seq_lift_index #hsz hs;
hash_seq_lift_index #hsz nhs
val mt_hashes_next_rel_lift_odd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 1 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures MTS.mt_next_rel #_ #f (log2c j)
(hash_seq_spec #hsz hs)
(S.upd (hash_seq_spec #hsz nhs)
(S.length nhs) (MTS.HRaw (S.last hs))))
let mt_hashes_next_rel_lift_odd #hsz #_ j hs nhs =
log2c_div j;
hash_seq_lift_index #hsz hs;
hash_seq_lift_index #hsz nhs
val mt_hashes_next_rel_next_even:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
Lemma (requires j % 2 = 0 /\ mt_hashes_next_rel #_ #f j hs nhs)
(ensures S.equal (hash_seq_spec #hsz nhs)
(MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec #hsz hs)))
let mt_hashes_next_rel_next_even #hsz #f j hs nhs =
log2c_div j;
mt_hashes_next_rel_lift_even #_ #f j hs nhs;
MTS.mt_next_rel_next_lv #_ #f (log2c j)
(hash_seq_spec #hsz hs) (hash_seq_spec #hsz nhs)
val hash_seq_spec_full:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs:hashes #hsz {S.length hs > 0} ->
acc:hash #hsz -> actd:bool ->
GTot (MTS.merkle_tree #hsz (log2c (S.length hs))) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_seq_spec_full:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs:hashes #hsz {S.length hs > 0} ->
acc:hash #hsz -> actd:bool ->
GTot (MTS.merkle_tree #hsz (log2c (S.length hs))) | [] | MerkleTree.New.High.Correct.Base.hash_seq_spec_full | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} |
hs: MerkleTree.New.High.hashes{FStar.Seq.Base.length hs > 0} ->
acc: MerkleTree.New.High.hash ->
actd: Prims.bool
-> Prims.GTot
(MerkleTree.Spec.merkle_tree (MerkleTree.New.High.Correct.Base.log2c (FStar.Seq.Base.length hs))
) | {
"end_col": 28,
"end_line": 497,
"start_col": 2,
"start_line": 495
} |
FStar.Pervasives.Lemma | val mt_hashes_lth_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log #hsz j (S.slice fhs 0 (log2c j)))) | [
{
"abbrev": false,
"full_module": "MerkleTree.New.High",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Classical",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.New.High.Correct",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mt_hashes_lth_inv_log_converted #_ #f j fhs =
mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs | val mt_hashes_lth_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log #hsz j (S.slice fhs 0 (log2c j))))
let mt_hashes_lth_inv_log_converted #_ #f j fhs = | false | null | true | mt_hashes_lth_inv_log_converted_ #_ #f 0 j fhs | {
"checked_file": "MerkleTree.New.High.Correct.Base.fst.checked",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.New.High.Correct.Base.fst"
} | [
"lemma"
] | [
"Prims.pos",
"MerkleTree.Spec.hash_fun_t",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.pow2",
"MerkleTree.New.High.hashess",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"MerkleTree.New.High.hashes",
"MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv_log_converted_",
"Prims.unit"
] | [] | module MerkleTree.New.High.Correct.Base
open FStar.Classical
open FStar.Ghost
open FStar.Seq
module S = FStar.Seq
module MTS = MerkleTree.Spec
open MerkleTree.New.High
#set-options "--z3rlimit 40 --max_fuel 0 --max_ifuel 0"
/// Sequence helpers
val seq_prefix:
#a:Type -> s1:S.seq a ->
s2:S.seq a{S.length s1 <= S.length s2} ->
GTot Type0
let seq_prefix #a s1 s2 =
S.equal s1 (S.slice s2 0 (S.length s1))
val seq_head_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.head (S.cons x s) == x)
[SMTPat (S.cons x s)]
let seq_head_cons #a x s = ()
val seq_tail_cons:
#a:Type -> x:a -> s:S.seq a ->
Lemma (S.equal (S.tail (S.cons x s)) s)
[SMTPat (S.cons x s)]
let seq_tail_cons #a x s = ()
/// Invariants and simulation relation of high-level Merkle tree design
// Invariants of internal hashes
val empty_hashes: (#hsz:pos) -> (len:nat) -> GTot (hs:hashess #hsz {S.length hs = len})
let empty_hashes #hsz len = S.create len S.empty
val empty_hashes_head:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.head (empty_hashes #hsz len) == S.empty)
let empty_hashes_head #_ _ = ()
val empty_hashes_tail:
#hsz:pos ->
len:nat{len > 0} ->
Lemma (S.equal (S.tail (empty_hashes len))
(empty_hashes #hsz (len - 1)))
let empty_hashes_tail #_ _ = ()
#push-options "--max_fuel 1"
val mt_hashes_lth_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_lth_inv #hsz lv j fhs =
if lv = 32 then true
else (S.length (S.index fhs lv) == j /\
mt_hashes_lth_inv (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_empty:
#hsz:pos ->
lv:nat{lv <= 32} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv lv 0 (empty_hashes #hsz 32))
(decreases (32 - lv))
let rec mt_hashes_lth_inv_empty #hsz lv =
if lv = 32 then ()
else mt_hashes_lth_inv_empty #hsz (lv + 1)
val mt_hashes_next_rel:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
hs:hashes #hsz {S.length hs = j} ->
nhs:hashes #hsz {S.length nhs = j / 2} ->
GTot Type0
let mt_hashes_next_rel #hsz #f j hs nhs =
forall (i:nat{i < j / 2}).
S.index nhs i ==
f (S.index hs (op_Multiply 2 i))
(S.index hs (op_Multiply 2 i + 1))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32 /\ mt_hashes_lth_inv lv j fhs} ->
GTot Type0 (decreases (32 - lv))
let rec mt_hashes_inv #hsz #f lv j fhs =
if lv = 31 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs lv) (S.index fhs (lv + 1)) /\
mt_hashes_inv #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_inv_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
Lemma (requires True)
(ensures (mt_hashes_lth_inv_empty #hsz lv;
mt_hashes_inv #hsz #f lv 0 (empty_hashes #hsz 32)))
(decreases (32 - lv))
let rec mt_hashes_inv_empty #hsz #f lv =
if lv = 31 then ()
else (mt_hashes_lth_inv_empty #hsz (lv + 1);
mt_hashes_inv_empty #_ #f (lv + 1))
val mt_hashes_lth_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess{S.length fhs1 = 32} ->
fhs2:hashess{S.length fhs2 = 32} ->
Lemma (requires mt_hashes_lth_inv lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_lth_inv #hsz lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_lth_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
mt_hashes_lth_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
#pop-options
#push-options "--max_fuel 1"
val mt_hashes_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs1:hashess #hsz {S.length fhs1 = 32 /\ mt_hashes_lth_inv lv j fhs1} ->
fhs2:hashess #hsz {S.length fhs2 = 32 /\ mt_hashes_lth_inv lv j fhs2} ->
Lemma (requires mt_hashes_inv #_ #f lv j fhs1 /\
S.equal (S.slice fhs1 lv 32) (S.slice fhs2 lv 32))
(ensures mt_hashes_inv #_ #f lv j fhs2)
(decreases (32 - lv))
let rec mt_hashes_inv_equiv #hsz #f lv j fhs1 fhs2 =
if lv = 31 then ()
else (assert (S.index fhs1 lv == S.index fhs2 lv);
assert (S.index fhs1 (lv + 1) == S.index fhs2 (lv + 1));
mt_hashes_inv_equiv #_ #f (lv + 1) (j / 2) fhs1 fhs2)
val merge_hs:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
GTot (mhs:hashess #hsz {S.length mhs = S.length hs1})
(decreases (S.length hs1))
let rec merge_hs #hsz #f hs1 hs2 =
if S.length hs1 = 0 then S.empty
else (S.cons (S.append (S.head hs1) (S.head hs2))
(merge_hs #_ #f (S.tail hs1) (S.tail hs2)))
val merge_hs_empty:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
len:nat ->
Lemma (S.equal (merge_hs #_ #f (empty_hashes #hsz len) (empty_hashes #hsz len))
(empty_hashes #hsz len))
let rec merge_hs_empty #hsz #f len =
if len = 0 then ()
else (empty_hashes_head #hsz len;
empty_hashes_tail #hsz len;
assert (S.equal (S.append #(hash #hsz) S.empty S.empty)
(S.empty #(hash #hsz)));
assert (S.equal (merge_hs #_ #f (empty_hashes len) (empty_hashes len))
(S.cons S.empty
(merge_hs #_ #f (empty_hashes (len - 1))
(empty_hashes (len - 1)))));
merge_hs_empty #_ #f (len - 1))
val merge_hs_index:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess ->
hs2:hashess{S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
Lemma (requires True)
(ensures S.equal (S.index (merge_hs #_ #f hs1 hs2) i)
(S.append (S.index hs1 i) (S.index hs2 i)))
(decreases (S.length hs1))
[SMTPat (S.index (merge_hs #_ #f hs1 hs2) i)]
let rec merge_hs_index #hsz #f hs1 hs2 i =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_index #_ #f (S.tail hs1) (S.tail hs2) (i - 1)
val merge_hs_slice_equal:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
ahs1:hashess #hsz ->
ahs2:hashess #hsz {S.length ahs1 = S.length ahs2} ->
bhs1:hashess #hsz ->
bhs2:hashess #hsz {S.length bhs1 = S.length bhs2} ->
i:nat -> j:nat{i <= j && j <= S.length ahs1 && j <= S.length bhs1} ->
Lemma (requires S.equal (S.slice ahs1 i j) (S.slice bhs1 i j) /\
S.equal (S.slice ahs2 i j) (S.slice bhs2 i j))
(ensures S.equal (S.slice (merge_hs #_ #f ahs1 ahs2) i j)
(S.slice (merge_hs #_ #f bhs1 bhs2) i j))
(decreases (j - i))
let rec merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 i j =
if i = j then ()
else (assert (S.index ahs1 i == S.index bhs1 i);
assert (S.index ahs2 i == S.index bhs2 i);
merge_hs_slice_equal #_ #f ahs1 ahs2 bhs1 bhs2 (i + 1) j)
val merge_hs_upd:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
hs1:hashess #hsz ->
hs2:hashess #hsz {S.length hs1 = S.length hs2} ->
i:nat{i < S.length hs1} ->
v1:hashes #hsz -> v2:hashes #hsz ->
Lemma (requires S.equal (S.append (S.index hs1 i) (S.index hs2 i))
(S.append v1 v2))
(ensures S.equal (merge_hs #_ #f hs1 hs2)
(merge_hs #_ #f (S.upd hs1 i v1) (S.upd hs2 i v2)))
(decreases i)
let rec merge_hs_upd #_ #f hs1 hs2 i v1 v2 =
if S.length hs1 = 0 then ()
else if i = 0 then ()
else merge_hs_upd #_ #f (S.tail hs1) (S.tail hs2) (i - 1) v1 v2
val mt_olds_inv:
#hsz:pos ->
lv:nat{lv <= 32} ->
i:nat ->
olds:hashess #hsz {S.length olds = 32} ->
GTot Type0 (decreases (32 - lv))
let rec mt_olds_inv #hsz lv i olds =
if lv = 32 then true
else (let ofs = offset_of i in
S.length (S.index olds lv) == ofs /\
mt_olds_inv #hsz (lv + 1) (i / 2) olds)
val mt_olds_inv_equiv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
olds1:hashess #hsz {S.length olds1 = 32} ->
olds2:hashess #hsz {S.length olds2 = 32} ->
Lemma (requires mt_olds_inv #hsz lv i olds1 /\
S.equal (S.slice olds1 lv 32) (S.slice olds2 lv 32))
(ensures mt_olds_inv #hsz lv i olds2)
(decreases (32 - lv))
let rec mt_olds_inv_equiv #hsz #f lv i olds1 olds2 =
if lv = 32 then ()
else (assert (S.index olds1 lv == S.index olds2 lv);
mt_olds_inv_equiv #_ #f (lv + 1) (i / 2) olds1 olds2)
val mt_olds_hs_lth_inv_ok:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
Lemma (requires True)
(ensures mt_hashes_lth_inv #hsz lv j (merge_hs #_ #f olds hs))
(decreases (32 - lv))
let rec mt_olds_hs_lth_inv_ok #hsz #f lv i j olds hs =
if lv = 32 then ()
else (mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs)
val mt_olds_hs_inv:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv < 32} ->
i:nat ->
j:nat{i <= j /\ j < pow2 (32 - lv)} ->
olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz lv i olds} ->
hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts #hsz lv hs i j} ->
GTot Type0
let mt_olds_hs_inv #hsz #f lv i j olds hs =
mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs;
mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs)
// Relation between valid internal hashes (satisfying `mt_olds_hs_inv`) and
// the spec. While giving such relation, all rightmost hashes are recovered.
// Note that `MT?.rhs` after `construct_rhs` does NOT contain all rightmost
// hashes; it has partial rightmost hashes that are enough to calculate
// Merkle paths.
val log2: n:nat{n > 0} -> GTot (c:nat{pow2 c <= n && n < pow2 (c+1)})
let rec log2 n =
if n = 1 then 0
else 1 + log2 (n / 2)
val log2_bound:
n:nat{n > 0} -> c:nat{n < pow2 c} ->
Lemma (log2 n <= c-1)
let rec log2_bound n c =
if n = 1 then ()
else log2_bound (n / 2) (c - 1)
val log2_div:
n:nat{n > 1} ->
Lemma (log2 (n / 2) = log2 n - 1)
let log2_div n = ()
val log2c:
n:nat ->
GTot (c:nat{c = 0 || (pow2 (c-1) <= n && n < pow2 c)})
let log2c n =
if n = 0 then 0 else (log2 n + 1)
val log2c_div:
n:nat{n > 0} ->
Lemma (log2c (n / 2) = log2c n - 1)
let log2c_div n = ()
val log2c_bound:
n:nat -> c:nat{n < pow2 c} ->
Lemma (log2c n <= c)
let rec log2c_bound n c =
if n = 0 then ()
else log2c_bound (n / 2) (c - 1)
val mt_hashes_lth_inv_log:
#hsz:pos ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
GTot Type0 (decreases j)
let rec mt_hashes_lth_inv_log #hsz j fhs =
if j = 0 then true
else (S.length (S.head fhs) == j /\
mt_hashes_lth_inv_log #hsz (j / 2) (S.tail fhs))
#pop-options
#push-options "--max_fuel 2"
val mt_hashes_lth_inv_log_next:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j > 1} ->
fhs:hashess #hsz {S.length fhs = log2c j} ->
Lemma (requires mt_hashes_lth_inv_log #hsz j fhs)
(ensures S.length (S.head fhs) == j /\
S.length (S.head (S.tail fhs)) == j / 2)
let mt_hashes_lth_inv_log_next #_ #_ _ _ = ()
val mt_hashes_inv_log:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat ->
fhs:hashess #hsz {S.length fhs = log2c j /\ mt_hashes_lth_inv_log #hsz j fhs} ->
GTot Type0 (decreases j)
let rec mt_hashes_inv_log #hsz #f j fhs =
if j <= 1 then true
else (mt_hashes_next_rel #_ #f j (S.index fhs 0) (S.index fhs 1) /\
mt_hashes_inv_log #_ #f (j / 2) (S.tail fhs))
val mt_hashes_lth_inv_log_converted_:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
lv:nat{lv <= 32} ->
j:nat{j < pow2 (32 - lv)} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz lv j fhs)
(ensures (log2c_bound j (32 - lv);
mt_hashes_lth_inv_log #hsz j (S.slice fhs lv (lv + log2c j))))
(decreases j)
let rec mt_hashes_lth_inv_log_converted_ #_ #f lv j fhs =
if j = 0 then ()
else (log2c_bound (j / 2) (32 - (lv + 1));
mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) fhs)
val mt_hashes_lth_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log #hsz j (S.slice fhs 0 (log2c j)))) | false | false | MerkleTree.New.High.Correct.Base.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mt_hashes_lth_inv_log_converted:
#hsz:pos -> #f:MTS.hash_fun_t #hsz ->
j:nat{j < pow2 32} ->
fhs:hashess #hsz {S.length fhs = 32} ->
Lemma (requires mt_hashes_lth_inv #hsz 0 j fhs)
(ensures (log2c_bound j 32;
mt_hashes_lth_inv_log #hsz j (S.slice fhs 0 (log2c j)))) | [] | MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv_log_converted | {
"file_name": "src/MerkleTree.New.High.Correct.Base.fst",
"git_rev": "3b0f086655c145aa23f58a97259ebf4cf112a4a3",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
} | j: Prims.nat{j < Prims.pow2 32} -> fhs: MerkleTree.New.High.hashess{FStar.Seq.Base.length fhs = 32}
-> FStar.Pervasives.Lemma (requires MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv 0 j fhs)
(ensures
([@@ FStar.Pervasives.inline_let ]let _ =
MerkleTree.New.High.Correct.Base.log2c_bound j 32
in
MerkleTree.New.High.Correct.Base.mt_hashes_lth_inv_log j
(FStar.Seq.Base.slice fhs 0 (MerkleTree.New.High.Correct.Base.log2c j)))) | {
"end_col": 48,
"end_line": 371,
"start_col": 2,
"start_line": 371
} |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.