file_name
stringlengths
5
52
name
stringlengths
4
95
original_source_type
stringlengths
0
23k
source_type
stringlengths
9
23k
source_definition
stringlengths
9
57.9k
source
dict
source_range
dict
file_context
stringlengths
0
721k
dependencies
dict
opens_and_abbrevs
listlengths
2
94
vconfig
dict
interleaved
bool
1 class
verbose_type
stringlengths
1
7.42k
effect
stringclasses
118 values
effect_flags
sequencelengths
0
2
mutual_with
sequencelengths
0
11
ideal_premises
sequencelengths
0
236
proof_features
sequencelengths
0
1
is_simple_lemma
bool
2 classes
is_div
bool
2 classes
is_proof
bool
2 classes
is_simply_typed
bool
2 classes
is_type
bool
2 classes
partial_definition
stringlengths
5
3.99k
completed_definiton
stringlengths
1
1.63M
isa_cross_project_example
bool
1 class
Vale.X64.Machine_s.fst
Vale.X64.Machine_s.reg_R13
val reg_R13:reg
val reg_R13:reg
let reg_R13 : reg = Reg 0 13
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 47, "end_line": 101, "start_col": 19, "start_line": 101 }
module Vale.X64.Machine_s open FStar.Mul include Vale.Arch.HeapTypes_s irreducible let va_qattr = () unfold let pow2_32 = Vale.Def.Words_s.pow2_32 unfold let pow2_64 = Vale.Def.Words_s.pow2_64 unfold let pow2_128 = Vale.Def.Words_s.pow2_128 unfold let nat64 = Vale.Def.Types_s.nat64 let int_to_nat64 (i:int) : n:nat64{0 <= i && i < pow2_64 ==> i == n} = Vale.Def.Words_s.int_to_natN pow2_64 i unfold let nat128 = Vale.Def.Words_s.nat128 unfold let quad32 = Vale.Def.Types_s.quad32 type flag:eqtype = i:int{0 <= i /\ i < 16} [@va_qattr] unfold let fCarry : flag = 0 [@va_qattr] unfold let fOverflow : flag = 11 let n_reg_files = 2 let reg_file_id = rf:nat{rf < n_reg_files} let n_regs (rf:reg_file_id) : nat = match rf with | 0 -> 16 | 1 -> 16 let t_reg_file (rf:reg_file_id) : Type0 = match rf with | 0 -> nat64 | 1 -> quad32 let reg_id (rf:reg_file_id) : Type0 = r:nat{r < n_regs rf} [@va_qattr] type reg = | Reg: rf:reg_file_id -> r:reg_id rf -> reg let t_reg (r:reg) : Type0 = t_reg_file r.rf // Some register files can be used as integers (for addresses); others arbitrarily return 0 let t_reg_to_int (rf:reg_file_id) (v:t_reg_file rf) : int = match rf with | 0 -> v | 1 -> 0 type maddr:eqtype = | MConst: n:int -> maddr | MReg: r:reg -> offset:int -> maddr | MIndex: base:reg -> scale:int -> index:reg -> offset:int -> maddr type tmaddr:eqtype = maddr & taint [@va_qattr] type operand (tc tr:eqtype) : eqtype = | OConst: n:tc -> operand tc tr | OReg: r:tr -> operand tc tr | OMem: m:tmaddr -> operand tc tr | OStack: m:tmaddr -> operand tc tr [@va_qattr] let operand_rf (rf:reg_file_id) : eqtype = operand (t_reg_file rf) (reg_id rf) [@va_qattr] unfold let oreg (r:reg) : operand_rf r.rf = OReg r.r let reg_64 : Type0 = r:nat{r < 16} let reg_xmm : Type0 = r:nat{r < 16} [@va_qattr] unfold let rRax : reg_64 = 0 [@va_qattr] unfold let rRbx : reg_64 = 1 [@va_qattr] unfold let rRcx : reg_64 = 2 [@va_qattr] unfold let rRdx : reg_64 = 3 [@va_qattr] unfold let rRsi : reg_64 = 4 [@va_qattr] unfold let rRdi : reg_64 = 5 [@va_qattr] unfold let rRbp : reg_64 = 6 [@va_qattr] unfold let rRsp : reg_64 = 7 [@va_qattr] unfold let rR8 : reg_64 = 8 [@va_qattr] unfold let rR9 : reg_64 = 9 [@va_qattr] unfold let rR10 : reg_64 = 10 [@va_qattr] unfold let rR11 : reg_64 = 11 [@va_qattr] unfold let rR12 : reg_64 = 12 [@va_qattr] unfold let rR13 : reg_64 = 13 [@va_qattr] unfold let rR14 : reg_64 = 14 [@va_qattr] unfold let rR15 : reg_64 = 15 [@va_qattr] unfold let reg_Rax : reg = Reg 0 0 [@va_qattr] unfold let reg_Rbx : reg = Reg 0 1 [@va_qattr] unfold let reg_Rcx : reg = Reg 0 2 [@va_qattr] unfold let reg_Rdx : reg = Reg 0 3 [@va_qattr] unfold let reg_Rsi : reg = Reg 0 4 [@va_qattr] unfold let reg_Rdi : reg = Reg 0 5 [@va_qattr] unfold let reg_Rbp : reg = Reg 0 6 [@va_qattr] unfold let reg_Rsp : reg = Reg 0 7 [@va_qattr] unfold let reg_R8 : reg = Reg 0 8 [@va_qattr] unfold let reg_R9 : reg = Reg 0 9 [@va_qattr] unfold let reg_R10 : reg = Reg 0 10 [@va_qattr] unfold let reg_R11 : reg = Reg 0 11
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_s.fst" }
[ { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.X64.Machine_s.reg
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Machine_s.Reg" ]
[]
false
false
false
true
false
let reg_R13:reg =
Reg 0 13
false
Hacl.Impl.Salsa20.Core32.fst
Hacl.Impl.Salsa20.Core32.set_counter
val set_counter: st:state -> c:size_t -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Seq.upd (as_seq h0 st) 8 (size_to_uint32 c))
val set_counter: st:state -> c:size_t -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Seq.upd (as_seq h0 st) 8 (size_to_uint32 c))
let set_counter st c = st.(size 8) <- size_to_uint32 c
{ "file_name": "code/salsa20/Hacl.Impl.Salsa20.Core32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 33, "end_line": 66, "start_col": 0, "start_line": 65 }
module Hacl.Impl.Salsa20.Core32 open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.Sequence open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module Spec = Spec.Salsa20 let state = lbuffer uint32 16ul let index = i:size_t{size_v i < 16} inline_for_extraction val create_state: unit -> StackInline state (requires fun h -> True) (ensures fun h0 r h1 -> live h1 r /\ as_seq h1 r == Seq.create 16 (u32 0) /\ stack_allocated r h0 h1 (Seq.create 16 (u32 0))) let create_state () = create (size 16) (u32 0) inline_for_extraction val load_state: st:state -> b:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h st /\ live h b /\ disjoint st b) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Lib.ByteSequence.uints_from_bytes_le (as_seq h0 b)) let load_state st b = uints_from_bytes_le st b inline_for_extraction val store_state: b:lbuffer uint8 64ul -> st:state -> Stack unit (requires fun h -> live h st /\ live h b /\ disjoint st b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == Lib.ByteSequence.uints_to_bytes_le (as_seq h0 st)) let store_state st b = uints_to_bytes_le 16ul st b inline_for_extraction val set_counter: st:state -> c:size_t -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Seq.upd (as_seq h0 st) 8 (size_to_uint32 c))
{ "checked_file": "/", "dependencies": [ "Spec.Salsa20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Salsa20.Core32.fst" }
[ { "abbrev": true, "full_module": "Spec.Salsa20", "short_module": "Spec" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Salsa20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Salsa20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
st: Hacl.Impl.Salsa20.Core32.state -> c: Lib.IntTypes.size_t -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.Salsa20.Core32.state", "Lib.IntTypes.size_t", "Lib.Buffer.op_Array_Assignment", "Lib.IntTypes.uint32", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.size", "Lib.IntTypes.size_to_uint32", "Prims.unit" ]
[]
false
true
false
false
false
let set_counter st c =
st.(size 8) <- size_to_uint32 c
false
Hacl.Impl.Salsa20.Core32.fst
Hacl.Impl.Salsa20.Core32.copy_state
val copy_state: st:state -> ost:state -> Stack unit (requires fun h -> live h st /\ live h ost /\ disjoint st ost) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == as_seq h0 ost)
val copy_state: st:state -> ost:state -> Stack unit (requires fun h -> live h st /\ live h ost /\ disjoint st ost) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == as_seq h0 ost)
let copy_state st ost = copy #MUT #uint32 #(size 16) st ost
{ "file_name": "code/salsa20/Hacl.Impl.Salsa20.Core32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 59, "end_line": 78, "start_col": 0, "start_line": 78 }
module Hacl.Impl.Salsa20.Core32 open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.Sequence open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module Spec = Spec.Salsa20 let state = lbuffer uint32 16ul let index = i:size_t{size_v i < 16} inline_for_extraction val create_state: unit -> StackInline state (requires fun h -> True) (ensures fun h0 r h1 -> live h1 r /\ as_seq h1 r == Seq.create 16 (u32 0) /\ stack_allocated r h0 h1 (Seq.create 16 (u32 0))) let create_state () = create (size 16) (u32 0) inline_for_extraction val load_state: st:state -> b:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h st /\ live h b /\ disjoint st b) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Lib.ByteSequence.uints_from_bytes_le (as_seq h0 b)) let load_state st b = uints_from_bytes_le st b inline_for_extraction val store_state: b:lbuffer uint8 64ul -> st:state -> Stack unit (requires fun h -> live h st /\ live h b /\ disjoint st b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == Lib.ByteSequence.uints_to_bytes_le (as_seq h0 st)) let store_state st b = uints_to_bytes_le 16ul st b inline_for_extraction val set_counter: st:state -> c:size_t -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Seq.upd (as_seq h0 st) 8 (size_to_uint32 c)) let set_counter st c = st.(size 8) <- size_to_uint32 c inline_for_extraction val copy_state: st:state -> ost:state -> Stack unit (requires fun h -> live h st /\ live h ost /\ disjoint st ost) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == as_seq h0 ost)
{ "checked_file": "/", "dependencies": [ "Spec.Salsa20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Salsa20.Core32.fst" }
[ { "abbrev": true, "full_module": "Spec.Salsa20", "short_module": "Spec" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Salsa20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Salsa20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
st: Hacl.Impl.Salsa20.Core32.state -> ost: Hacl.Impl.Salsa20.Core32.state -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.Salsa20.Core32.state", "Lib.Buffer.copy", "Lib.Buffer.MUT", "Lib.IntTypes.uint32", "Lib.IntTypes.size", "Prims.unit" ]
[]
false
true
false
false
false
let copy_state st ost =
copy #MUT #uint32 #(size 16) st ost
false
Vale.X64.Machine_s.fst
Vale.X64.Machine_s.reg_R14
val reg_R14:reg
val reg_R14:reg
let reg_R14 : reg = Reg 0 14
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 47, "end_line": 102, "start_col": 19, "start_line": 102 }
module Vale.X64.Machine_s open FStar.Mul include Vale.Arch.HeapTypes_s irreducible let va_qattr = () unfold let pow2_32 = Vale.Def.Words_s.pow2_32 unfold let pow2_64 = Vale.Def.Words_s.pow2_64 unfold let pow2_128 = Vale.Def.Words_s.pow2_128 unfold let nat64 = Vale.Def.Types_s.nat64 let int_to_nat64 (i:int) : n:nat64{0 <= i && i < pow2_64 ==> i == n} = Vale.Def.Words_s.int_to_natN pow2_64 i unfold let nat128 = Vale.Def.Words_s.nat128 unfold let quad32 = Vale.Def.Types_s.quad32 type flag:eqtype = i:int{0 <= i /\ i < 16} [@va_qattr] unfold let fCarry : flag = 0 [@va_qattr] unfold let fOverflow : flag = 11 let n_reg_files = 2 let reg_file_id = rf:nat{rf < n_reg_files} let n_regs (rf:reg_file_id) : nat = match rf with | 0 -> 16 | 1 -> 16 let t_reg_file (rf:reg_file_id) : Type0 = match rf with | 0 -> nat64 | 1 -> quad32 let reg_id (rf:reg_file_id) : Type0 = r:nat{r < n_regs rf} [@va_qattr] type reg = | Reg: rf:reg_file_id -> r:reg_id rf -> reg let t_reg (r:reg) : Type0 = t_reg_file r.rf // Some register files can be used as integers (for addresses); others arbitrarily return 0 let t_reg_to_int (rf:reg_file_id) (v:t_reg_file rf) : int = match rf with | 0 -> v | 1 -> 0 type maddr:eqtype = | MConst: n:int -> maddr | MReg: r:reg -> offset:int -> maddr | MIndex: base:reg -> scale:int -> index:reg -> offset:int -> maddr type tmaddr:eqtype = maddr & taint [@va_qattr] type operand (tc tr:eqtype) : eqtype = | OConst: n:tc -> operand tc tr | OReg: r:tr -> operand tc tr | OMem: m:tmaddr -> operand tc tr | OStack: m:tmaddr -> operand tc tr [@va_qattr] let operand_rf (rf:reg_file_id) : eqtype = operand (t_reg_file rf) (reg_id rf) [@va_qattr] unfold let oreg (r:reg) : operand_rf r.rf = OReg r.r let reg_64 : Type0 = r:nat{r < 16} let reg_xmm : Type0 = r:nat{r < 16} [@va_qattr] unfold let rRax : reg_64 = 0 [@va_qattr] unfold let rRbx : reg_64 = 1 [@va_qattr] unfold let rRcx : reg_64 = 2 [@va_qattr] unfold let rRdx : reg_64 = 3 [@va_qattr] unfold let rRsi : reg_64 = 4 [@va_qattr] unfold let rRdi : reg_64 = 5 [@va_qattr] unfold let rRbp : reg_64 = 6 [@va_qattr] unfold let rRsp : reg_64 = 7 [@va_qattr] unfold let rR8 : reg_64 = 8 [@va_qattr] unfold let rR9 : reg_64 = 9 [@va_qattr] unfold let rR10 : reg_64 = 10 [@va_qattr] unfold let rR11 : reg_64 = 11 [@va_qattr] unfold let rR12 : reg_64 = 12 [@va_qattr] unfold let rR13 : reg_64 = 13 [@va_qattr] unfold let rR14 : reg_64 = 14 [@va_qattr] unfold let rR15 : reg_64 = 15 [@va_qattr] unfold let reg_Rax : reg = Reg 0 0 [@va_qattr] unfold let reg_Rbx : reg = Reg 0 1 [@va_qattr] unfold let reg_Rcx : reg = Reg 0 2 [@va_qattr] unfold let reg_Rdx : reg = Reg 0 3 [@va_qattr] unfold let reg_Rsi : reg = Reg 0 4 [@va_qattr] unfold let reg_Rdi : reg = Reg 0 5 [@va_qattr] unfold let reg_Rbp : reg = Reg 0 6 [@va_qattr] unfold let reg_Rsp : reg = Reg 0 7 [@va_qattr] unfold let reg_R8 : reg = Reg 0 8 [@va_qattr] unfold let reg_R9 : reg = Reg 0 9 [@va_qattr] unfold let reg_R10 : reg = Reg 0 10 [@va_qattr] unfold let reg_R11 : reg = Reg 0 11 [@va_qattr] unfold let reg_R12 : reg = Reg 0 12
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_s.fst" }
[ { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.X64.Machine_s.reg
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Machine_s.Reg" ]
[]
false
false
false
true
false
let reg_R14:reg =
Reg 0 14
false
Hacl.Impl.Salsa20.Core32.fst
Hacl.Impl.Salsa20.Core32.load_state
val load_state: st:state -> b:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h st /\ live h b /\ disjoint st b) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Lib.ByteSequence.uints_from_bytes_le (as_seq h0 b))
val load_state: st:state -> b:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h st /\ live h b /\ disjoint st b) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Lib.ByteSequence.uints_from_bytes_le (as_seq h0 b))
let load_state st b = uints_from_bytes_le st b
{ "file_name": "code/salsa20/Hacl.Impl.Salsa20.Core32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 26, "end_line": 40, "start_col": 0, "start_line": 39 }
module Hacl.Impl.Salsa20.Core32 open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.Sequence open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module Spec = Spec.Salsa20 let state = lbuffer uint32 16ul let index = i:size_t{size_v i < 16} inline_for_extraction val create_state: unit -> StackInline state (requires fun h -> True) (ensures fun h0 r h1 -> live h1 r /\ as_seq h1 r == Seq.create 16 (u32 0) /\ stack_allocated r h0 h1 (Seq.create 16 (u32 0))) let create_state () = create (size 16) (u32 0) inline_for_extraction val load_state: st:state -> b:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h st /\ live h b /\ disjoint st b) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Lib.ByteSequence.uints_from_bytes_le (as_seq h0 b))
{ "checked_file": "/", "dependencies": [ "Spec.Salsa20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Salsa20.Core32.fst" }
[ { "abbrev": true, "full_module": "Spec.Salsa20", "short_module": "Spec" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Salsa20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Salsa20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
st: Hacl.Impl.Salsa20.Core32.state -> b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 64ul -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.Salsa20.Core32.state", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Lib.ByteBuffer.uints_from_bytes_le", "Lib.IntTypes.U32", "Lib.IntTypes.SEC", "Prims.unit" ]
[]
false
true
false
false
false
let load_state st b =
uints_from_bytes_le st b
false
FStar.DM4F.Heap.ST.fsti
FStar.DM4F.Heap.ST.incr
val incr (r: ref int) : ST unit (requires (fun h -> h `contains_a_well_typed` r)) (ensures (fun h0 s h1 -> h0 `contains_a_well_typed` r /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ sel h1 r = sel h0 r + 1))
val incr (r: ref int) : ST unit (requires (fun h -> h `contains_a_well_typed` r)) (ensures (fun h0 s h1 -> h0 `contains_a_well_typed` r /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ sel h1 r = sel h0 r + 1))
let incr (r:ref int) : ST unit (requires (fun h -> h `contains_a_well_typed` r)) (ensures (fun h0 s h1 -> h0 `contains_a_well_typed` r /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ sel h1 r = sel h0 r + 1)) = r := !r + 1
{ "file_name": "examples/dm4free/FStar.DM4F.Heap.ST.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 17, "end_line": 129, "start_col": 0, "start_line": 123 }
(* 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. *) (* A state monad with local state built using FStar.DM4F.Heap. The very end of the file illustrates how recursion through the heap is forbidden because of the universe constraints. As such, in this model, storing stateful functions in the heap is forbidden. However, storing non-stateful functions, e.g,. Tot or Exception function in the heap is acceptable. *) module FStar.DM4F.Heap.ST open FStar.DM4F.Heap open FStar.DM4F.ST //////////////////////////////////////////////////////////////////////////////// // Instruct F* to build a new STATE effect from the elaborated effect STATE_h //////////////////////////////////////////////////////////////////////////////// reifiable reflectable total new_effect { STATE : a:Type -> Effect with repr = st heap ; bind = bind_st heap ; return = return_st heap ; get = get heap ; put = put heap } let get = STATE?.get let put = STATE?.put unfold let lift_pure_state (a:Type) (wp:pure_wp a) (h:heap) (p:STATE?.post a) = wp (fun a -> p (a, h)) sub_effect PURE ~> STATE = lift_pure_state //ST is an abbreviation for STATE with pre- and post-conditions // aka requires and ensures clauses effect ST (a:Type) (pre: STATE?.pre) (post: heap -> a -> heap -> Type0) = STATE a (fun n0 p -> pre n0 /\ (forall a n1. pre n0 /\ post n0 a n1 ==> p (a, n1))) //STNull is an abbreviation for stateful computations with trivial pre/post effect STNull (a:Type) = ST a (fun h -> True) (fun _ _ _ -> True) //////////////////////////////////////////////////////////////////////////////// //Next, given the primive global state actions STATE?.get and STATE?.put, //we implement local state operations for allocating, reading and writing refs //////////////////////////////////////////////////////////////////////////////// (* Allocation *) let alloc (#a:Type) (init:a) : ST (ref a) (requires (fun h -> True)) (ensures (fun h0 r h1 -> ~ (h0 `contains` r) /\ //the ref r is fresh h1 `contains_a_well_typed` r /\ //and is well-typed in h1 sel h1 r == init /\ //initialized to init modifies Set.empty h0 h1)) //and no existing ref is modified = let h0 = STATE?.get () in let r, h1 = alloc h0 init in STATE?.put h1; r let alloc_weak (#a:Type) (init:a) :ST (ref a) (requires (fun h0 -> True)) (ensures (fun h0 r h1 -> h1 `contains_a_well_typed` r /\ (forall (a:Type) (r':ref a). h0 `contains_a_well_typed` r' ==> h1 `contains_a_well_typed` r'))) = let h0 = STATE?.get () in let r, h1 = FStar.DM4F.Heap.alloc h0 init in STATE?.put h1; r (* Reading, aka dereference *) let read (#a:Type) (r:ref a) : ST a (requires (fun h -> h `contains_a_well_typed` r)) (ensures (fun h0 v h1 -> h0 == h1 /\ //heap does not change h1 `contains_a_well_typed` r /\ sel h1 r == v)) //returns the contents of r = let h0 = STATE?.get () in sel_tot h0 r let (!) = read let read_weak (#a:Type) (r:ref a) : ST a (requires (fun h0 -> h0 `contains_a_well_typed` r)) (ensures (fun h0 v h1 -> forall (a:Type) (r:ref a). h0 `contains_a_well_typed` r ==> h1 `contains_a_well_typed` r)) = let h0 = STATE?.get () in sel_tot h0 r (* Writing, aka assignment *) let write (#a:Type) (r:ref a) (v:a) : ST unit (requires (fun h -> h `contains_a_well_typed` r)) (ensures (fun h0 _ h1 -> h0 `contains_a_well_typed` r /\ h1 `contains_a_well_typed` r /\ //the heap remains well-typed h1 == upd h0 r v)) //and is updated at location r only = let h0 = STATE?.get () in STATE?.put (upd_tot h0 r v) let op_Colon_Equals = write let write_weak (#a:Type) (r:ref a) (v:a) : ST unit (requires (fun h0 -> h0 `contains_a_well_typed` r)) (ensures (fun h0 v h1 -> forall (a:Type) (r:ref a). h0 `contains_a_well_typed` r ==> h1 `contains_a_well_typed` r)) = let h0 = STATE?.get () in STATE?.put (upd_tot h0 r v) //////////////////////////////////////////////////////////////////////////////// //A simple example using the local state operations
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.ST.fst.checked", "FStar.DM4F.Heap.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.Heap.ST.fsti" }
[ { "abbrev": false, "full_module": "FStar.DM4F.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.DM4F.Heap.ref Prims.int -> FStar.DM4F.Heap.ST.ST Prims.unit
FStar.DM4F.Heap.ST.ST
[]
[]
[ "FStar.DM4F.Heap.ref", "Prims.int", "FStar.DM4F.Heap.ST.op_Colon_Equals", "Prims.unit", "Prims.op_Addition", "FStar.DM4F.Heap.ST.op_Bang", "FStar.DM4F.Heap.heap", "FStar.DM4F.Heap.contains_a_well_typed", "Prims.l_and", "FStar.DM4F.Heap.modifies", "FStar.Set.singleton", "Prims.nat", "FStar.DM4F.Heap.addr_of", "Prims.b2t", "Prims.op_Equality", "FStar.DM4F.Heap.sel" ]
[]
false
true
false
false
false
let incr (r: ref int) : ST unit (requires (fun h -> h `contains_a_well_typed` r)) (ensures (fun h0 s h1 -> h0 `contains_a_well_typed` r /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ sel h1 r = sel h0 r + 1)) =
r := !r + 1
false
FStar.DM4F.Heap.ST.fsti
FStar.DM4F.Heap.ST.incr_increases
val incr_increases : r: FStar.DM4F.Heap.ref Prims.int -> h0: FStar.DM4F.Heap.heap{FStar.DM4F.Heap.contains_a_well_typed h0 r} -> Prims.unit
let incr_increases (r:ref int) (h0:heap{h0 `contains_a_well_typed` r}) = assert (let _, h1 = (reify (incr' r)) h0 in sel h1 r = sel h0 r + 1)
{ "file_name": "examples/dm4free/FStar.DM4F.Heap.ST.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 36, "end_line": 137, "start_col": 0, "start_line": 135 }
(* 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. *) (* A state monad with local state built using FStar.DM4F.Heap. The very end of the file illustrates how recursion through the heap is forbidden because of the universe constraints. As such, in this model, storing stateful functions in the heap is forbidden. However, storing non-stateful functions, e.g,. Tot or Exception function in the heap is acceptable. *) module FStar.DM4F.Heap.ST open FStar.DM4F.Heap open FStar.DM4F.ST //////////////////////////////////////////////////////////////////////////////// // Instruct F* to build a new STATE effect from the elaborated effect STATE_h //////////////////////////////////////////////////////////////////////////////// reifiable reflectable total new_effect { STATE : a:Type -> Effect with repr = st heap ; bind = bind_st heap ; return = return_st heap ; get = get heap ; put = put heap } let get = STATE?.get let put = STATE?.put unfold let lift_pure_state (a:Type) (wp:pure_wp a) (h:heap) (p:STATE?.post a) = wp (fun a -> p (a, h)) sub_effect PURE ~> STATE = lift_pure_state //ST is an abbreviation for STATE with pre- and post-conditions // aka requires and ensures clauses effect ST (a:Type) (pre: STATE?.pre) (post: heap -> a -> heap -> Type0) = STATE a (fun n0 p -> pre n0 /\ (forall a n1. pre n0 /\ post n0 a n1 ==> p (a, n1))) //STNull is an abbreviation for stateful computations with trivial pre/post effect STNull (a:Type) = ST a (fun h -> True) (fun _ _ _ -> True) //////////////////////////////////////////////////////////////////////////////// //Next, given the primive global state actions STATE?.get and STATE?.put, //we implement local state operations for allocating, reading and writing refs //////////////////////////////////////////////////////////////////////////////// (* Allocation *) let alloc (#a:Type) (init:a) : ST (ref a) (requires (fun h -> True)) (ensures (fun h0 r h1 -> ~ (h0 `contains` r) /\ //the ref r is fresh h1 `contains_a_well_typed` r /\ //and is well-typed in h1 sel h1 r == init /\ //initialized to init modifies Set.empty h0 h1)) //and no existing ref is modified = let h0 = STATE?.get () in let r, h1 = alloc h0 init in STATE?.put h1; r let alloc_weak (#a:Type) (init:a) :ST (ref a) (requires (fun h0 -> True)) (ensures (fun h0 r h1 -> h1 `contains_a_well_typed` r /\ (forall (a:Type) (r':ref a). h0 `contains_a_well_typed` r' ==> h1 `contains_a_well_typed` r'))) = let h0 = STATE?.get () in let r, h1 = FStar.DM4F.Heap.alloc h0 init in STATE?.put h1; r (* Reading, aka dereference *) let read (#a:Type) (r:ref a) : ST a (requires (fun h -> h `contains_a_well_typed` r)) (ensures (fun h0 v h1 -> h0 == h1 /\ //heap does not change h1 `contains_a_well_typed` r /\ sel h1 r == v)) //returns the contents of r = let h0 = STATE?.get () in sel_tot h0 r let (!) = read let read_weak (#a:Type) (r:ref a) : ST a (requires (fun h0 -> h0 `contains_a_well_typed` r)) (ensures (fun h0 v h1 -> forall (a:Type) (r:ref a). h0 `contains_a_well_typed` r ==> h1 `contains_a_well_typed` r)) = let h0 = STATE?.get () in sel_tot h0 r (* Writing, aka assignment *) let write (#a:Type) (r:ref a) (v:a) : ST unit (requires (fun h -> h `contains_a_well_typed` r)) (ensures (fun h0 _ h1 -> h0 `contains_a_well_typed` r /\ h1 `contains_a_well_typed` r /\ //the heap remains well-typed h1 == upd h0 r v)) //and is updated at location r only = let h0 = STATE?.get () in STATE?.put (upd_tot h0 r v) let op_Colon_Equals = write let write_weak (#a:Type) (r:ref a) (v:a) : ST unit (requires (fun h0 -> h0 `contains_a_well_typed` r)) (ensures (fun h0 v h1 -> forall (a:Type) (r:ref a). h0 `contains_a_well_typed` r ==> h1 `contains_a_well_typed` r)) = let h0 = STATE?.get () in STATE?.put (upd_tot h0 r v) //////////////////////////////////////////////////////////////////////////////// //A simple example using the local state operations //////////////////////////////////////////////////////////////////////////////// let incr (r:ref int) : ST unit (requires (fun h -> h `contains_a_well_typed` r)) (ensures (fun h0 s h1 -> h0 `contains_a_well_typed` r /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ sel h1 r = sel h0 r + 1)) = r := !r + 1 let incr' (r:ref int) :ST unit (fun h0 -> h0 `contains_a_well_typed` r) (fun h0 _ h1 -> h1 `contains_a_well_typed` r) = write_weak r (read_weak r + 1)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.ST.fst.checked", "FStar.DM4F.Heap.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.Heap.ST.fsti" }
[ { "abbrev": false, "full_module": "FStar.DM4F.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.DM4F.Heap.ref Prims.int -> h0: FStar.DM4F.Heap.heap{FStar.DM4F.Heap.contains_a_well_typed h0 r} -> Prims.unit
Prims.Tot
[ "total" ]
[]
[ "FStar.DM4F.Heap.ref", "Prims.int", "FStar.DM4F.Heap.heap", "FStar.DM4F.Heap.contains_a_well_typed", "Prims._assert", "Prims.unit", "Prims.b2t", "Prims.op_Equality", "FStar.DM4F.Heap.sel", "Prims.op_Addition", "FStar.Pervasives.Native.tuple2", "FStar.DM4F.Heap.ST.incr'" ]
[]
false
false
false
false
false
let incr_increases (r: ref int) (h0: heap{h0 `contains_a_well_typed` r}) =
assert (let _, h1 = (reify (incr' r)) h0 in sel h1 r = sel h0 r + 1)
false
Hacl.Impl.Salsa20.Core32.fst
Hacl.Impl.Salsa20.Core32.store_state
val store_state: b:lbuffer uint8 64ul -> st:state -> Stack unit (requires fun h -> live h st /\ live h b /\ disjoint st b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == Lib.ByteSequence.uints_to_bytes_le (as_seq h0 st))
val store_state: b:lbuffer uint8 64ul -> st:state -> Stack unit (requires fun h -> live h st /\ live h b /\ disjoint st b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == Lib.ByteSequence.uints_to_bytes_le (as_seq h0 st))
let store_state st b = uints_to_bytes_le 16ul st b
{ "file_name": "code/salsa20/Hacl.Impl.Salsa20.Core32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 29, "end_line": 53, "start_col": 0, "start_line": 52 }
module Hacl.Impl.Salsa20.Core32 open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.Sequence open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module Spec = Spec.Salsa20 let state = lbuffer uint32 16ul let index = i:size_t{size_v i < 16} inline_for_extraction val create_state: unit -> StackInline state (requires fun h -> True) (ensures fun h0 r h1 -> live h1 r /\ as_seq h1 r == Seq.create 16 (u32 0) /\ stack_allocated r h0 h1 (Seq.create 16 (u32 0))) let create_state () = create (size 16) (u32 0) inline_for_extraction val load_state: st:state -> b:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h st /\ live h b /\ disjoint st b) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Lib.ByteSequence.uints_from_bytes_le (as_seq h0 b)) let load_state st b = uints_from_bytes_le st b inline_for_extraction val store_state: b:lbuffer uint8 64ul -> st:state -> Stack unit (requires fun h -> live h st /\ live h b /\ disjoint st b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == Lib.ByteSequence.uints_to_bytes_le (as_seq h0 st))
{ "checked_file": "/", "dependencies": [ "Spec.Salsa20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Salsa20.Core32.fst" }
[ { "abbrev": true, "full_module": "Spec.Salsa20", "short_module": "Spec" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Salsa20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Salsa20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 64ul -> st: Hacl.Impl.Salsa20.Core32.state -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Salsa20.Core32.state", "Lib.ByteBuffer.uints_to_bytes_le", "Lib.IntTypes.U32", "Lib.IntTypes.SEC", "Prims.unit" ]
[]
false
true
false
false
false
let store_state st b =
uints_to_bytes_le 16ul st b
false
Hacl.Streaming.Poly1305.fst
Hacl.Streaming.Poly1305.update_last_is_update
val update_last_is_update (input: S.seq uint8) (acc: Spec.Poly1305.felem) (r: Spec.Poly1305.felem): Lemma (requires (S.length input <= Spec.Poly1305.size_block)) (ensures (update_last (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r)))
val update_last_is_update (input: S.seq uint8) (acc: Spec.Poly1305.felem) (r: Spec.Poly1305.felem): Lemma (requires (S.length input <= Spec.Poly1305.size_block)) (ensures (update_last (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r)))
let update_last_is_update input acc r = if S.length input = Spec.Poly1305.size_block then update_last_block_is_update input acc r else update_last_not_block_is_update input acc r
{ "file_name": "code/streaming/Hacl.Streaming.Poly1305.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 50, "end_line": 282, "start_col": 0, "start_line": 279 }
module Hacl.Streaming.Poly1305 module HS = FStar.HyperStack module B = LowStar.Buffer module G = FStar.Ghost module S = FStar.Seq module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module I = Hacl.Streaming.Interface module P = Hacl.Impl.Poly1305 module F32xN = Hacl.Spec.Poly1305.Field32xN module ST = FStar.HyperStack.ST open LowStar.BufferOps open FStar.Mul /// Opening a bunch of modules for Poly1305 /// ======================================= inline_for_extraction noextract let uint8 = Lib.IntTypes.uint8 inline_for_extraction noextract let uint32 = Lib.IntTypes.uint32 open Hacl.Impl.Poly1305.Fields /// An instance of the stateful type class for poly1305 state /// ========================================================= /// /// We use a custom view that separates r and acc, to respect abstraction boundaries established by Poly1305. #set-options "--fuel 0 --ifuel 1 --z3rlimit 100" inline_for_extraction noextract let t (fs : field_spec) = b:B.buffer (limb fs) { B.length b == 25 } inline_for_extraction noextract let as_raw (#fs : field_spec) (x: t fs): B.buffer (limb fs) = x inline_for_extraction noextract let as_lib (#fs : field_spec) (x: t fs): P.poly1305_ctx fs = assert (Lib.IntTypes.(v (add #U32 (nlimb fs) (precomplen fs))) == 25); x inline_for_extraction noextract let poly1305_key = I.stateful_buffer uint8 32ul (Lib.IntTypes.u8 0) unit inline_for_extraction noextract let as_lib_k (x: B.buffer uint8 { B.length x = 32 }): Lib.Buffer.lbuffer uint8 32ul = x inline_for_extraction noextract let num_lanes (fs : field_spec) : F32xN.lanes = match fs with | M32 -> 1 | M128 -> 2 | M256 -> 4 inline_for_extraction noextract let stateful_poly1305_ctx (fs : field_spec) : I.stateful unit = I.Stateful (fun () -> t fs) (fun #_ _ s -> B.loc_addr_of_buffer (as_raw s)) (fun #_ _ s -> B.freeable (as_raw s)) (fun #_ h s -> B.live h (as_raw s) /\ P.state_inv_t h (as_lib s)) (fun () -> Spec.Poly1305.felem & Spec.Poly1305.felem) (fun () h s -> P.as_get_acc h (as_lib s), P.as_get_r h (as_lib s)) (fun #_ _ _ -> ()) (fun #_ l s h0 h1 -> P.reveal_ctx_inv (as_lib s) h0 h1; B.modifies_buffer_elim (as_raw s) l h0 h1) (fun #_ _ _ _ _ -> ()) (fun () -> [@inline_let] let n = num_lanes fs in let r = B.alloca (F32xN.zero n) 25ul in let h1 = ST.get () in P.ctx_inv_zeros #fs r h1; r) (fun () r -> [@inline_let] let n = num_lanes fs in let r = B.malloc r (F32xN.zero n) 25ul in let h1 = ST.get () in P.ctx_inv_zeros #fs r h1; r) (fun _ s -> B.free s) (fun _ src dst -> let h0 = ST.get () in B.blit src 0ul dst 0ul 25ul; let h1 = ST.get () in P.reveal_ctx_inv' (as_lib src) (as_lib dst) h0 h1) /// Interlude for spec equivalence proofs /// ===================================== /// /// A quick explanation about this proof of equivalence. At the spec level, /// ``poly1305_update`` needs both ``r`` and the accumulator ``acc``. This thus /// makes poly1305 update a function of two arguments. However, the streaming /// facility is constructed over specifications that take one single argument. /// Not a problem! We carry the pair ``(r, acc)`` as our "streaming functor /// accumulator", and we now have to show that a specification in terms of /// ``update (update (r, acc) init)`` is the same as poly1305. For that, we need /// to do a little proof of equivalence to show first that this is the same as /// ``(update r) ((update r) acc)`` (note that the update function now becomes a /// partial application), then use the update-multi-repeat conversion lemma to /// get the original specification of poly1305. inline_for_extraction noextract let block = (block: S.seq uint8 { S.length block = Spec.Poly1305.size_block }) inline_for_extraction noextract let update_ (acc, r) (block: block) = Spec.Poly1305.poly1305_update1 r Spec.Poly1305.size_block block acc, r /// Same as [update_], but with the input not necessarily a full block (can be smaller) inline_for_extraction noextract let update__ (acc, r) (input: S.seq uint8{S.length input <= Spec.Poly1305.size_block}) = Spec.Poly1305.poly1305_update1 r (S.length input) input acc, r inline_for_extraction noextract let update' r acc (block: block) = Spec.Poly1305.poly1305_update1 r Spec.Poly1305.size_block block acc inline_for_extraction noextract let update_multi = Lib.UpdateMulti.mk_update_multi Spec.Poly1305.size_block update_ inline_for_extraction noextract let update_multi' r = Lib.UpdateMulti.mk_update_multi Spec.Poly1305.size_block (update' r) #push-options "--fuel 1" inline_for_extraction noextract let rec with_or_without_r (acc r: Spec.Poly1305.felem) (blocks: S.seq uint8): Lemma (requires S.length blocks % Spec.Poly1305.size_block = 0) (ensures update_multi (acc, r) blocks == (update_multi' r acc blocks, r)) (decreases (S.length blocks)) = if S.length blocks = 0 then () else let block, rem = Lib.UpdateMulti.split_block Spec.Poly1305.size_block blocks 1 in let acc = update' r acc block in with_or_without_r acc r rem #pop-options inline_for_extraction noextract let update_last (acc, r) (input: S.seq uint8 { S.length input <= Spec.Poly1305.size_block }) = if S.length input = 0 then acc, r else Spec.Poly1305.poly1305_update1 r (S.length input) input acc, r inline_for_extraction noextract let update_last' r acc (input: S.seq uint8 { S.length input <= Spec.Poly1305.size_block }) = if S.length input = 0 then acc else Spec.Poly1305.poly1305_update1 r (S.length input) input acc inline_for_extraction noextract let finish_ k (acc, r) = Spec.Poly1305.poly1305_finish k acc inline_for_extraction noextract let spec k input = Spec.Poly1305.poly1305_mac input k val update_last_not_block_is_update (input: S.seq uint8) (acc: Spec.Poly1305.felem) (r: Spec.Poly1305.felem): Lemma (requires (S.length input < Spec.Poly1305.size_block)) (ensures (update_last (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r))) let update_last_not_block_is_update input acc r = let open Lib.UpdateMulti.Lemmas in let block_length = Spec.Poly1305.size_block in assert_norm (block_length < pow2 32); calc (==) { update_last (acc, r) input; (==) { } update_last' r acc input, r; (==) { Lib.UpdateMulti.update_multi_zero Spec.Poly1305.size_block (update' r) acc } update_last' r (update_multi' r acc S.empty) input, r; (==) { update_full_is_repeat_blocks block_length (update' r) (update_last' r) acc input input } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input (repeat_f block_length (update' r)) (repeat_l block_length (update_last' r) input) acc, r; (==) { Lib.Sequence.Lemmas.repeat_blocks_extensionality block_length input (repeat_f block_length (update' r)) Spec.Poly1305.(poly1305_update1 r size_block) (repeat_l block_length (update_last' r) input) Spec.Poly1305.(poly1305_update_last r) acc } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input Spec.Poly1305.(poly1305_update1 r size_block) Spec.Poly1305.(poly1305_update_last r) acc, r; } val update_last_block_is_update (input: S.seq uint8) (acc: Spec.Poly1305.felem) (r: Spec.Poly1305.felem): Lemma (requires (S.length input = Spec.Poly1305.size_block)) (ensures (update_last (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r))) open FStar.Tactics #push-options "--fuel 1 --print_implicits" let update_last_block_is_update input acc r = let open Lib.UpdateMulti.Lemmas in let block_length = Spec.Poly1305.size_block in assert_norm (block_length < pow2 32); assert(input `S.equal` S.append input S.empty); let acc1 = update' r acc input in let acc1' = update_multi' r acc input in // SH: fun fact: this lemma call and the following assert should be the // last part of the below calc. However, if put below/inside the calc, // the proof loops. Lib.Sequence.Lemmas.repeat_blocks_extensionality block_length input (repeat_f block_length (update' r)) Spec.Poly1305.(poly1305_update1 r size_block) (repeat_l block_length (update_last' r) input) Spec.Poly1305.(poly1305_update_last r) acc; assert( Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input (repeat_f block_length (update' r)) (repeat_l block_length (update_last' r) input) acc == Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input Spec.Poly1305.(poly1305_update1 r size_block) Spec.Poly1305.(poly1305_update_last r) acc); assert( let block, rem = Lib.UpdateMulti.split_block block_length input 1 in block `S.equal` input /\ rem `S.equal` S.empty); assert( Lib.UpdateMulti.mk_update_multi block_length (update' r) acc1 S.empty == acc1'); assert(acc1 == acc1'); calc (==) { update_last (acc, r) input; (==) { } update_last' r acc input, r; (==) { } update_last' r (update' r acc input) S.empty, r; (==) { } update_last' r (update_multi' r acc input) S.empty, r; (==) { update_full_is_repeat_blocks block_length (update' r) (update_last' r) acc input input } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input (repeat_f block_length (update' r)) (repeat_l block_length (update_last' r) input) acc, r; } #pop-options val update_last_is_update (input: S.seq uint8) (acc: Spec.Poly1305.felem) (r: Spec.Poly1305.felem): Lemma (requires (S.length input <= Spec.Poly1305.size_block)) (ensures (update_last (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r)))
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.UpdateMulti.Lemmas.fsti.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "Hacl.Poly1305_32.fsti.checked", "Hacl.Poly1305_256.fsti.checked", "Hacl.Poly1305_128.fsti.checked", "Hacl.Impl.Poly1305.Fields.fst.checked", "Hacl.Impl.Poly1305.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.Poly1305.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Poly1305.Fields", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": "F32xN" }, { "abbrev": true, "full_module": "Hacl.Impl.Poly1305", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Streaming.Interface", "short_module": "I" }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
input: FStar.Seq.Base.seq Hacl.Streaming.Poly1305.uint8 -> acc: Spec.Poly1305.felem -> r: Spec.Poly1305.felem -> FStar.Pervasives.Lemma (requires FStar.Seq.Base.length input <= Spec.Poly1305.size_block) (ensures Hacl.Streaming.Poly1305.update_last (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Hacl.Streaming.Poly1305.uint8", "Spec.Poly1305.felem", "Prims.op_Equality", "Prims.nat", "FStar.Seq.Base.length", "Spec.Poly1305.size_block", "Hacl.Streaming.Poly1305.update_last_block_is_update", "Prims.bool", "Hacl.Streaming.Poly1305.update_last_not_block_is_update", "Prims.unit" ]
[]
false
false
true
false
false
let update_last_is_update input acc r =
if S.length input = Spec.Poly1305.size_block then update_last_block_is_update input acc r else update_last_not_block_is_update input acc r
false
FStar.DM4F.Heap.ST.fsti
FStar.DM4F.Heap.ST.incr'
val incr' (r: ref int) : ST unit (fun h0 -> h0 `contains_a_well_typed` r) (fun h0 _ h1 -> h1 `contains_a_well_typed` r)
val incr' (r: ref int) : ST unit (fun h0 -> h0 `contains_a_well_typed` r) (fun h0 _ h1 -> h1 `contains_a_well_typed` r)
let incr' (r:ref int) :ST unit (fun h0 -> h0 `contains_a_well_typed` r) (fun h0 _ h1 -> h1 `contains_a_well_typed` r) = write_weak r (read_weak r + 1)
{ "file_name": "examples/dm4free/FStar.DM4F.Heap.ST.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 34, "end_line": 133, "start_col": 1, "start_line": 131 }
(* 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. *) (* A state monad with local state built using FStar.DM4F.Heap. The very end of the file illustrates how recursion through the heap is forbidden because of the universe constraints. As such, in this model, storing stateful functions in the heap is forbidden. However, storing non-stateful functions, e.g,. Tot or Exception function in the heap is acceptable. *) module FStar.DM4F.Heap.ST open FStar.DM4F.Heap open FStar.DM4F.ST //////////////////////////////////////////////////////////////////////////////// // Instruct F* to build a new STATE effect from the elaborated effect STATE_h //////////////////////////////////////////////////////////////////////////////// reifiable reflectable total new_effect { STATE : a:Type -> Effect with repr = st heap ; bind = bind_st heap ; return = return_st heap ; get = get heap ; put = put heap } let get = STATE?.get let put = STATE?.put unfold let lift_pure_state (a:Type) (wp:pure_wp a) (h:heap) (p:STATE?.post a) = wp (fun a -> p (a, h)) sub_effect PURE ~> STATE = lift_pure_state //ST is an abbreviation for STATE with pre- and post-conditions // aka requires and ensures clauses effect ST (a:Type) (pre: STATE?.pre) (post: heap -> a -> heap -> Type0) = STATE a (fun n0 p -> pre n0 /\ (forall a n1. pre n0 /\ post n0 a n1 ==> p (a, n1))) //STNull is an abbreviation for stateful computations with trivial pre/post effect STNull (a:Type) = ST a (fun h -> True) (fun _ _ _ -> True) //////////////////////////////////////////////////////////////////////////////// //Next, given the primive global state actions STATE?.get and STATE?.put, //we implement local state operations for allocating, reading and writing refs //////////////////////////////////////////////////////////////////////////////// (* Allocation *) let alloc (#a:Type) (init:a) : ST (ref a) (requires (fun h -> True)) (ensures (fun h0 r h1 -> ~ (h0 `contains` r) /\ //the ref r is fresh h1 `contains_a_well_typed` r /\ //and is well-typed in h1 sel h1 r == init /\ //initialized to init modifies Set.empty h0 h1)) //and no existing ref is modified = let h0 = STATE?.get () in let r, h1 = alloc h0 init in STATE?.put h1; r let alloc_weak (#a:Type) (init:a) :ST (ref a) (requires (fun h0 -> True)) (ensures (fun h0 r h1 -> h1 `contains_a_well_typed` r /\ (forall (a:Type) (r':ref a). h0 `contains_a_well_typed` r' ==> h1 `contains_a_well_typed` r'))) = let h0 = STATE?.get () in let r, h1 = FStar.DM4F.Heap.alloc h0 init in STATE?.put h1; r (* Reading, aka dereference *) let read (#a:Type) (r:ref a) : ST a (requires (fun h -> h `contains_a_well_typed` r)) (ensures (fun h0 v h1 -> h0 == h1 /\ //heap does not change h1 `contains_a_well_typed` r /\ sel h1 r == v)) //returns the contents of r = let h0 = STATE?.get () in sel_tot h0 r let (!) = read let read_weak (#a:Type) (r:ref a) : ST a (requires (fun h0 -> h0 `contains_a_well_typed` r)) (ensures (fun h0 v h1 -> forall (a:Type) (r:ref a). h0 `contains_a_well_typed` r ==> h1 `contains_a_well_typed` r)) = let h0 = STATE?.get () in sel_tot h0 r (* Writing, aka assignment *) let write (#a:Type) (r:ref a) (v:a) : ST unit (requires (fun h -> h `contains_a_well_typed` r)) (ensures (fun h0 _ h1 -> h0 `contains_a_well_typed` r /\ h1 `contains_a_well_typed` r /\ //the heap remains well-typed h1 == upd h0 r v)) //and is updated at location r only = let h0 = STATE?.get () in STATE?.put (upd_tot h0 r v) let op_Colon_Equals = write let write_weak (#a:Type) (r:ref a) (v:a) : ST unit (requires (fun h0 -> h0 `contains_a_well_typed` r)) (ensures (fun h0 v h1 -> forall (a:Type) (r:ref a). h0 `contains_a_well_typed` r ==> h1 `contains_a_well_typed` r)) = let h0 = STATE?.get () in STATE?.put (upd_tot h0 r v) //////////////////////////////////////////////////////////////////////////////// //A simple example using the local state operations //////////////////////////////////////////////////////////////////////////////// let incr (r:ref int) : ST unit (requires (fun h -> h `contains_a_well_typed` r)) (ensures (fun h0 s h1 -> h0 `contains_a_well_typed` r /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ sel h1 r = sel h0 r + 1)) = r := !r + 1
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.ST.fst.checked", "FStar.DM4F.Heap.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.Heap.ST.fsti" }
[ { "abbrev": false, "full_module": "FStar.DM4F.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.DM4F.Heap.ref Prims.int -> FStar.DM4F.Heap.ST.ST Prims.unit
FStar.DM4F.Heap.ST.ST
[]
[]
[ "FStar.DM4F.Heap.ref", "Prims.int", "FStar.DM4F.Heap.ST.write_weak", "Prims.unit", "Prims.op_Addition", "FStar.DM4F.Heap.ST.read_weak", "FStar.DM4F.Heap.heap", "FStar.DM4F.Heap.contains_a_well_typed" ]
[]
false
true
false
false
false
let incr' (r: ref int) : ST unit (fun h0 -> h0 `contains_a_well_typed` r) (fun h0 _ h1 -> h1 `contains_a_well_typed` r) =
write_weak r (read_weak r + 1)
false
Hacl.Streaming.Poly1305.fst
Hacl.Streaming.Poly1305.update__
val update__ : _: (Spec.Poly1305.felem * Spec.Poly1305.felem) -> input: FStar.Seq.Base.seq Hacl.Streaming.Poly1305.uint8 {FStar.Seq.Base.length input <= Spec.Poly1305.size_block} -> Spec.Poly1305.felem * Spec.Poly1305.felem
let update__ (acc, r) (input: S.seq uint8{S.length input <= Spec.Poly1305.size_block}) = Spec.Poly1305.poly1305_update1 r (S.length input) input acc, r
{ "file_name": "code/streaming/Hacl.Streaming.Poly1305.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 64, "end_line": 122, "start_col": 0, "start_line": 121 }
module Hacl.Streaming.Poly1305 module HS = FStar.HyperStack module B = LowStar.Buffer module G = FStar.Ghost module S = FStar.Seq module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module I = Hacl.Streaming.Interface module P = Hacl.Impl.Poly1305 module F32xN = Hacl.Spec.Poly1305.Field32xN module ST = FStar.HyperStack.ST open LowStar.BufferOps open FStar.Mul /// Opening a bunch of modules for Poly1305 /// ======================================= inline_for_extraction noextract let uint8 = Lib.IntTypes.uint8 inline_for_extraction noextract let uint32 = Lib.IntTypes.uint32 open Hacl.Impl.Poly1305.Fields /// An instance of the stateful type class for poly1305 state /// ========================================================= /// /// We use a custom view that separates r and acc, to respect abstraction boundaries established by Poly1305. #set-options "--fuel 0 --ifuel 1 --z3rlimit 100" inline_for_extraction noextract let t (fs : field_spec) = b:B.buffer (limb fs) { B.length b == 25 } inline_for_extraction noextract let as_raw (#fs : field_spec) (x: t fs): B.buffer (limb fs) = x inline_for_extraction noextract let as_lib (#fs : field_spec) (x: t fs): P.poly1305_ctx fs = assert (Lib.IntTypes.(v (add #U32 (nlimb fs) (precomplen fs))) == 25); x inline_for_extraction noextract let poly1305_key = I.stateful_buffer uint8 32ul (Lib.IntTypes.u8 0) unit inline_for_extraction noextract let as_lib_k (x: B.buffer uint8 { B.length x = 32 }): Lib.Buffer.lbuffer uint8 32ul = x inline_for_extraction noextract let num_lanes (fs : field_spec) : F32xN.lanes = match fs with | M32 -> 1 | M128 -> 2 | M256 -> 4 inline_for_extraction noextract let stateful_poly1305_ctx (fs : field_spec) : I.stateful unit = I.Stateful (fun () -> t fs) (fun #_ _ s -> B.loc_addr_of_buffer (as_raw s)) (fun #_ _ s -> B.freeable (as_raw s)) (fun #_ h s -> B.live h (as_raw s) /\ P.state_inv_t h (as_lib s)) (fun () -> Spec.Poly1305.felem & Spec.Poly1305.felem) (fun () h s -> P.as_get_acc h (as_lib s), P.as_get_r h (as_lib s)) (fun #_ _ _ -> ()) (fun #_ l s h0 h1 -> P.reveal_ctx_inv (as_lib s) h0 h1; B.modifies_buffer_elim (as_raw s) l h0 h1) (fun #_ _ _ _ _ -> ()) (fun () -> [@inline_let] let n = num_lanes fs in let r = B.alloca (F32xN.zero n) 25ul in let h1 = ST.get () in P.ctx_inv_zeros #fs r h1; r) (fun () r -> [@inline_let] let n = num_lanes fs in let r = B.malloc r (F32xN.zero n) 25ul in let h1 = ST.get () in P.ctx_inv_zeros #fs r h1; r) (fun _ s -> B.free s) (fun _ src dst -> let h0 = ST.get () in B.blit src 0ul dst 0ul 25ul; let h1 = ST.get () in P.reveal_ctx_inv' (as_lib src) (as_lib dst) h0 h1) /// Interlude for spec equivalence proofs /// ===================================== /// /// A quick explanation about this proof of equivalence. At the spec level, /// ``poly1305_update`` needs both ``r`` and the accumulator ``acc``. This thus /// makes poly1305 update a function of two arguments. However, the streaming /// facility is constructed over specifications that take one single argument. /// Not a problem! We carry the pair ``(r, acc)`` as our "streaming functor /// accumulator", and we now have to show that a specification in terms of /// ``update (update (r, acc) init)`` is the same as poly1305. For that, we need /// to do a little proof of equivalence to show first that this is the same as /// ``(update r) ((update r) acc)`` (note that the update function now becomes a /// partial application), then use the update-multi-repeat conversion lemma to /// get the original specification of poly1305. inline_for_extraction noextract let block = (block: S.seq uint8 { S.length block = Spec.Poly1305.size_block }) inline_for_extraction noextract let update_ (acc, r) (block: block) = Spec.Poly1305.poly1305_update1 r Spec.Poly1305.size_block block acc, r /// Same as [update_], but with the input not necessarily a full block (can be smaller)
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.UpdateMulti.Lemmas.fsti.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "Hacl.Poly1305_32.fsti.checked", "Hacl.Poly1305_256.fsti.checked", "Hacl.Poly1305_128.fsti.checked", "Hacl.Impl.Poly1305.Fields.fst.checked", "Hacl.Impl.Poly1305.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.Poly1305.fst" }
[ { "abbrev": false, "full_module": "Hacl.Impl.Poly1305.Fields", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": "F32xN" }, { "abbrev": true, "full_module": "Hacl.Impl.Poly1305", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Streaming.Interface", "short_module": "I" }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: (Spec.Poly1305.felem * Spec.Poly1305.felem) -> input: FStar.Seq.Base.seq Hacl.Streaming.Poly1305.uint8 {FStar.Seq.Base.length input <= Spec.Poly1305.size_block} -> Spec.Poly1305.felem * Spec.Poly1305.felem
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.tuple2", "Spec.Poly1305.felem", "FStar.Seq.Base.seq", "Hacl.Streaming.Poly1305.uint8", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.length", "Spec.Poly1305.size_block", "FStar.Pervasives.Native.Mktuple2", "Spec.Poly1305.poly1305_update1" ]
[]
false
false
false
false
false
let update__ (acc, r) (input: S.seq uint8 {S.length input <= Spec.Poly1305.size_block}) =
Spec.Poly1305.poly1305_update1 r (S.length input) input acc, r
false
FStar.DM4F.Heap.ST.fsti
FStar.DM4F.Heap.ST.copy_and_incr
val copy_and_incr (r: ref int) : ST (ref int) (requires (fun h -> h `contains_a_well_typed` r)) (ensures (fun h0 s h1 -> h0 `contains_a_well_typed` r /\ ~(h0 `contains` s) /\ h1 `contains_a_well_typed` s /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ sel h1 r = sel h0 r + 1 /\ sel h1 s = sel h0 r))
val copy_and_incr (r: ref int) : ST (ref int) (requires (fun h -> h `contains_a_well_typed` r)) (ensures (fun h0 s h1 -> h0 `contains_a_well_typed` r /\ ~(h0 `contains` s) /\ h1 `contains_a_well_typed` s /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ sel h1 r = sel h0 r + 1 /\ sel h1 s = sel h0 r))
let copy_and_incr (r:ref int) : ST (ref int) (requires (fun h -> h `contains_a_well_typed` r)) (ensures (fun h0 s h1 -> h0 `contains_a_well_typed` r /\ ~ (h0 `contains` s) /\ h1 `contains_a_well_typed` s /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ sel h1 r = sel h0 r + 1 /\ sel h1 s = sel h0 r)) = let s = alloc !r in incr r; s
{ "file_name": "examples/dm4free/FStar.DM4F.Heap.ST.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 7, "end_line": 150, "start_col": 0, "start_line": 139 }
(* 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. *) (* A state monad with local state built using FStar.DM4F.Heap. The very end of the file illustrates how recursion through the heap is forbidden because of the universe constraints. As such, in this model, storing stateful functions in the heap is forbidden. However, storing non-stateful functions, e.g,. Tot or Exception function in the heap is acceptable. *) module FStar.DM4F.Heap.ST open FStar.DM4F.Heap open FStar.DM4F.ST //////////////////////////////////////////////////////////////////////////////// // Instruct F* to build a new STATE effect from the elaborated effect STATE_h //////////////////////////////////////////////////////////////////////////////// reifiable reflectable total new_effect { STATE : a:Type -> Effect with repr = st heap ; bind = bind_st heap ; return = return_st heap ; get = get heap ; put = put heap } let get = STATE?.get let put = STATE?.put unfold let lift_pure_state (a:Type) (wp:pure_wp a) (h:heap) (p:STATE?.post a) = wp (fun a -> p (a, h)) sub_effect PURE ~> STATE = lift_pure_state //ST is an abbreviation for STATE with pre- and post-conditions // aka requires and ensures clauses effect ST (a:Type) (pre: STATE?.pre) (post: heap -> a -> heap -> Type0) = STATE a (fun n0 p -> pre n0 /\ (forall a n1. pre n0 /\ post n0 a n1 ==> p (a, n1))) //STNull is an abbreviation for stateful computations with trivial pre/post effect STNull (a:Type) = ST a (fun h -> True) (fun _ _ _ -> True) //////////////////////////////////////////////////////////////////////////////// //Next, given the primive global state actions STATE?.get and STATE?.put, //we implement local state operations for allocating, reading and writing refs //////////////////////////////////////////////////////////////////////////////// (* Allocation *) let alloc (#a:Type) (init:a) : ST (ref a) (requires (fun h -> True)) (ensures (fun h0 r h1 -> ~ (h0 `contains` r) /\ //the ref r is fresh h1 `contains_a_well_typed` r /\ //and is well-typed in h1 sel h1 r == init /\ //initialized to init modifies Set.empty h0 h1)) //and no existing ref is modified = let h0 = STATE?.get () in let r, h1 = alloc h0 init in STATE?.put h1; r let alloc_weak (#a:Type) (init:a) :ST (ref a) (requires (fun h0 -> True)) (ensures (fun h0 r h1 -> h1 `contains_a_well_typed` r /\ (forall (a:Type) (r':ref a). h0 `contains_a_well_typed` r' ==> h1 `contains_a_well_typed` r'))) = let h0 = STATE?.get () in let r, h1 = FStar.DM4F.Heap.alloc h0 init in STATE?.put h1; r (* Reading, aka dereference *) let read (#a:Type) (r:ref a) : ST a (requires (fun h -> h `contains_a_well_typed` r)) (ensures (fun h0 v h1 -> h0 == h1 /\ //heap does not change h1 `contains_a_well_typed` r /\ sel h1 r == v)) //returns the contents of r = let h0 = STATE?.get () in sel_tot h0 r let (!) = read let read_weak (#a:Type) (r:ref a) : ST a (requires (fun h0 -> h0 `contains_a_well_typed` r)) (ensures (fun h0 v h1 -> forall (a:Type) (r:ref a). h0 `contains_a_well_typed` r ==> h1 `contains_a_well_typed` r)) = let h0 = STATE?.get () in sel_tot h0 r (* Writing, aka assignment *) let write (#a:Type) (r:ref a) (v:a) : ST unit (requires (fun h -> h `contains_a_well_typed` r)) (ensures (fun h0 _ h1 -> h0 `contains_a_well_typed` r /\ h1 `contains_a_well_typed` r /\ //the heap remains well-typed h1 == upd h0 r v)) //and is updated at location r only = let h0 = STATE?.get () in STATE?.put (upd_tot h0 r v) let op_Colon_Equals = write let write_weak (#a:Type) (r:ref a) (v:a) : ST unit (requires (fun h0 -> h0 `contains_a_well_typed` r)) (ensures (fun h0 v h1 -> forall (a:Type) (r:ref a). h0 `contains_a_well_typed` r ==> h1 `contains_a_well_typed` r)) = let h0 = STATE?.get () in STATE?.put (upd_tot h0 r v) //////////////////////////////////////////////////////////////////////////////// //A simple example using the local state operations //////////////////////////////////////////////////////////////////////////////// let incr (r:ref int) : ST unit (requires (fun h -> h `contains_a_well_typed` r)) (ensures (fun h0 s h1 -> h0 `contains_a_well_typed` r /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ sel h1 r = sel h0 r + 1)) = r := !r + 1 let incr' (r:ref int) :ST unit (fun h0 -> h0 `contains_a_well_typed` r) (fun h0 _ h1 -> h1 `contains_a_well_typed` r) = write_weak r (read_weak r + 1) let incr_increases (r:ref int) (h0:heap{h0 `contains_a_well_typed` r}) = assert (let _, h1 = (reify (incr' r)) h0 in sel h1 r = sel h0 r + 1)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.ST.fst.checked", "FStar.DM4F.Heap.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.Heap.ST.fsti" }
[ { "abbrev": false, "full_module": "FStar.DM4F.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.DM4F.Heap.ref Prims.int -> FStar.DM4F.Heap.ST.ST (FStar.DM4F.Heap.ref Prims.int)
FStar.DM4F.Heap.ST.ST
[]
[]
[ "FStar.DM4F.Heap.ref", "Prims.int", "Prims.unit", "FStar.DM4F.Heap.ST.incr", "FStar.DM4F.Heap.ST.alloc", "FStar.DM4F.Heap.ST.op_Bang", "FStar.DM4F.Heap.heap", "FStar.DM4F.Heap.contains_a_well_typed", "Prims.l_and", "Prims.l_not", "FStar.DM4F.Heap.contains", "FStar.DM4F.Heap.modifies", "FStar.Set.singleton", "Prims.nat", "FStar.DM4F.Heap.addr_of", "Prims.b2t", "Prims.op_Equality", "FStar.DM4F.Heap.sel", "Prims.op_Addition" ]
[]
false
true
false
false
false
let copy_and_incr (r: ref int) : ST (ref int) (requires (fun h -> h `contains_a_well_typed` r)) (ensures (fun h0 s h1 -> h0 `contains_a_well_typed` r /\ ~(h0 `contains` s) /\ h1 `contains_a_well_typed` s /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ sel h1 r = sel h0 r + 1 /\ sel h1 s = sel h0 r)) =
let s = alloc !r in incr r; s
false
Hacl.Impl.Salsa20.Core32.fst
Hacl.Impl.Salsa20.Core32.quarter_round
val quarter_round: st:state -> a:index -> b:index -> c:index -> d:index -> Stack unit (requires fun h -> live h st /\ v b <> v d /\ v c <> v a) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.quarter_round (v a) (v b) (v c) (v d) (as_seq h0 st))
val quarter_round: st:state -> a:index -> b:index -> c:index -> d:index -> Stack unit (requires fun h -> live h st /\ v b <> v d /\ v c <> v a) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.quarter_round (v a) (v b) (v c) (v d) (as_seq h0 st))
let quarter_round st a b c d = line st b a d (size 7); line st c b a (size 9); line st d c b (size 13); line st a d c (size 18)
{ "file_name": "code/salsa20/Hacl.Impl.Salsa20.Core32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 25, "end_line": 149, "start_col": 0, "start_line": 145 }
module Hacl.Impl.Salsa20.Core32 open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.Sequence open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module Spec = Spec.Salsa20 let state = lbuffer uint32 16ul let index = i:size_t{size_v i < 16} inline_for_extraction val create_state: unit -> StackInline state (requires fun h -> True) (ensures fun h0 r h1 -> live h1 r /\ as_seq h1 r == Seq.create 16 (u32 0) /\ stack_allocated r h0 h1 (Seq.create 16 (u32 0))) let create_state () = create (size 16) (u32 0) inline_for_extraction val load_state: st:state -> b:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h st /\ live h b /\ disjoint st b) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Lib.ByteSequence.uints_from_bytes_le (as_seq h0 b)) let load_state st b = uints_from_bytes_le st b inline_for_extraction val store_state: b:lbuffer uint8 64ul -> st:state -> Stack unit (requires fun h -> live h st /\ live h b /\ disjoint st b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == Lib.ByteSequence.uints_to_bytes_le (as_seq h0 st)) let store_state st b = uints_to_bytes_le 16ul st b inline_for_extraction val set_counter: st:state -> c:size_t -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Seq.upd (as_seq h0 st) 8 (size_to_uint32 c)) let set_counter st c = st.(size 8) <- size_to_uint32 c inline_for_extraction val copy_state: st:state -> ost:state -> Stack unit (requires fun h -> live h st /\ live h ost /\ disjoint st ost) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == as_seq h0 ost) let copy_state st ost = copy #MUT #uint32 #(size 16) st ost inline_for_extraction val sum_state: st:state -> ost:state -> Stack unit (requires fun h -> live h st /\ live h ost /\ eq_or_disjoint st ost) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Lib.Sequence.map2 (+.) (as_seq h0 st) (as_seq h0 ost)) let sum_state st ost = map2T #MUT #MUT #uint32 #uint32 #uint32 (size 16) st ( +. ) st ost inline_for_extraction val xor_block: o:lbuffer uint8 64ul -> st:state -> b:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h o /\ live h st /\ live h b) (ensures fun h0 _ h1 -> modifies (loc o) h0 h1 /\ as_seq h1 o == Spec.xor_block (as_seq h0 st) (as_seq h0 b)) #set-options "--z3rlimit 100" let xor_block o st b = push_frame(); let bl = create_state() in load_state bl b; map2T (size 16) bl ( ^. ) bl st; store_state o bl; pop_frame() inline_for_extraction val line: st:state -> a:index -> b:index -> d:index -> r:rotval U32 -> Stack unit (requires fun h -> live h st /\ v a <> v d) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.line (v a) (v b) (v d) r (as_seq h0 st)) let line st a b d r = let sta = st.(a) in let stb = st.(b) in let std = st.(d) in let sta = sta ^. ((stb +. std) <<<. r) in st.(a) <- sta val quarter_round: st:state -> a:index -> b:index -> c:index -> d:index -> Stack unit (requires fun h -> live h st /\ v b <> v d /\ v c <> v a) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.quarter_round (v a) (v b) (v c) (v d) (as_seq h0 st))
{ "checked_file": "/", "dependencies": [ "Spec.Salsa20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Salsa20.Core32.fst" }
[ { "abbrev": true, "full_module": "Spec.Salsa20", "short_module": "Spec" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Salsa20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Salsa20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
st: Hacl.Impl.Salsa20.Core32.state -> a: Hacl.Impl.Salsa20.Core32.index -> b: Hacl.Impl.Salsa20.Core32.index -> c: Hacl.Impl.Salsa20.Core32.index -> d: Hacl.Impl.Salsa20.Core32.index -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.Salsa20.Core32.state", "Hacl.Impl.Salsa20.Core32.index", "Hacl.Impl.Salsa20.Core32.line", "Lib.IntTypes.size", "Prims.unit" ]
[]
false
true
false
false
false
let quarter_round st a b c d =
line st b a d (size 7); line st c b a (size 9); line st d c b (size 13); line st a d c (size 18)
false
FStar.DM4F.Heap.ST.fsti
FStar.DM4F.Heap.ST.alloc_addition_and_incr
val alloc_addition_and_incr (r: ref int) : ST (ref (int -> Tot int)) (requires (fun h -> h `contains_a_well_typed` r)) (ensures (fun h0 s h1 -> h0 `contains_a_well_typed` r /\ ~(h0 `contains` s) /\ h1 `contains_a_well_typed` s /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ (forall y. sel h1 s y = sel h0 r + y)))
val alloc_addition_and_incr (r: ref int) : ST (ref (int -> Tot int)) (requires (fun h -> h `contains_a_well_typed` r)) (ensures (fun h0 s h1 -> h0 `contains_a_well_typed` r /\ ~(h0 `contains` s) /\ h1 `contains_a_well_typed` s /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ (forall y. sel h1 s y = sel h0 r + y)))
let alloc_addition_and_incr (r:ref int) : ST (ref (int -> Tot int)) (requires (fun h -> h `contains_a_well_typed` r)) (ensures (fun h0 s h1 -> h0 `contains_a_well_typed` r /\ ~ (h0 `contains` s) /\ h1 `contains_a_well_typed` s /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ (forall y. sel h1 s y = sel h0 r + y))) = let x = !r in let s = alloc (fun y -> x + y) in s
{ "file_name": "examples/dm4free/FStar.DM4F.Heap.ST.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 7, "end_line": 166, "start_col": 0, "start_line": 156 }
(* 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. *) (* A state monad with local state built using FStar.DM4F.Heap. The very end of the file illustrates how recursion through the heap is forbidden because of the universe constraints. As such, in this model, storing stateful functions in the heap is forbidden. However, storing non-stateful functions, e.g,. Tot or Exception function in the heap is acceptable. *) module FStar.DM4F.Heap.ST open FStar.DM4F.Heap open FStar.DM4F.ST //////////////////////////////////////////////////////////////////////////////// // Instruct F* to build a new STATE effect from the elaborated effect STATE_h //////////////////////////////////////////////////////////////////////////////// reifiable reflectable total new_effect { STATE : a:Type -> Effect with repr = st heap ; bind = bind_st heap ; return = return_st heap ; get = get heap ; put = put heap } let get = STATE?.get let put = STATE?.put unfold let lift_pure_state (a:Type) (wp:pure_wp a) (h:heap) (p:STATE?.post a) = wp (fun a -> p (a, h)) sub_effect PURE ~> STATE = lift_pure_state //ST is an abbreviation for STATE with pre- and post-conditions // aka requires and ensures clauses effect ST (a:Type) (pre: STATE?.pre) (post: heap -> a -> heap -> Type0) = STATE a (fun n0 p -> pre n0 /\ (forall a n1. pre n0 /\ post n0 a n1 ==> p (a, n1))) //STNull is an abbreviation for stateful computations with trivial pre/post effect STNull (a:Type) = ST a (fun h -> True) (fun _ _ _ -> True) //////////////////////////////////////////////////////////////////////////////// //Next, given the primive global state actions STATE?.get and STATE?.put, //we implement local state operations for allocating, reading and writing refs //////////////////////////////////////////////////////////////////////////////// (* Allocation *) let alloc (#a:Type) (init:a) : ST (ref a) (requires (fun h -> True)) (ensures (fun h0 r h1 -> ~ (h0 `contains` r) /\ //the ref r is fresh h1 `contains_a_well_typed` r /\ //and is well-typed in h1 sel h1 r == init /\ //initialized to init modifies Set.empty h0 h1)) //and no existing ref is modified = let h0 = STATE?.get () in let r, h1 = alloc h0 init in STATE?.put h1; r let alloc_weak (#a:Type) (init:a) :ST (ref a) (requires (fun h0 -> True)) (ensures (fun h0 r h1 -> h1 `contains_a_well_typed` r /\ (forall (a:Type) (r':ref a). h0 `contains_a_well_typed` r' ==> h1 `contains_a_well_typed` r'))) = let h0 = STATE?.get () in let r, h1 = FStar.DM4F.Heap.alloc h0 init in STATE?.put h1; r (* Reading, aka dereference *) let read (#a:Type) (r:ref a) : ST a (requires (fun h -> h `contains_a_well_typed` r)) (ensures (fun h0 v h1 -> h0 == h1 /\ //heap does not change h1 `contains_a_well_typed` r /\ sel h1 r == v)) //returns the contents of r = let h0 = STATE?.get () in sel_tot h0 r let (!) = read let read_weak (#a:Type) (r:ref a) : ST a (requires (fun h0 -> h0 `contains_a_well_typed` r)) (ensures (fun h0 v h1 -> forall (a:Type) (r:ref a). h0 `contains_a_well_typed` r ==> h1 `contains_a_well_typed` r)) = let h0 = STATE?.get () in sel_tot h0 r (* Writing, aka assignment *) let write (#a:Type) (r:ref a) (v:a) : ST unit (requires (fun h -> h `contains_a_well_typed` r)) (ensures (fun h0 _ h1 -> h0 `contains_a_well_typed` r /\ h1 `contains_a_well_typed` r /\ //the heap remains well-typed h1 == upd h0 r v)) //and is updated at location r only = let h0 = STATE?.get () in STATE?.put (upd_tot h0 r v) let op_Colon_Equals = write let write_weak (#a:Type) (r:ref a) (v:a) : ST unit (requires (fun h0 -> h0 `contains_a_well_typed` r)) (ensures (fun h0 v h1 -> forall (a:Type) (r:ref a). h0 `contains_a_well_typed` r ==> h1 `contains_a_well_typed` r)) = let h0 = STATE?.get () in STATE?.put (upd_tot h0 r v) //////////////////////////////////////////////////////////////////////////////// //A simple example using the local state operations //////////////////////////////////////////////////////////////////////////////// let incr (r:ref int) : ST unit (requires (fun h -> h `contains_a_well_typed` r)) (ensures (fun h0 s h1 -> h0 `contains_a_well_typed` r /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ sel h1 r = sel h0 r + 1)) = r := !r + 1 let incr' (r:ref int) :ST unit (fun h0 -> h0 `contains_a_well_typed` r) (fun h0 _ h1 -> h1 `contains_a_well_typed` r) = write_weak r (read_weak r + 1) let incr_increases (r:ref int) (h0:heap{h0 `contains_a_well_typed` r}) = assert (let _, h1 = (reify (incr' r)) h0 in sel h1 r = sel h0 r + 1) let copy_and_incr (r:ref int) : ST (ref int) (requires (fun h -> h `contains_a_well_typed` r)) (ensures (fun h0 s h1 -> h0 `contains_a_well_typed` r /\ ~ (h0 `contains` s) /\ h1 `contains_a_well_typed` s /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ sel h1 r = sel h0 r + 1 /\ sel h1 s = sel h0 r)) = let s = alloc !r in incr r; s //////////////////////////////////////////////////////////////////////////////// //A safe higher-order example // Storing non-heap reading functions in the heap is fine
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.DM4F.ST.fst.checked", "FStar.DM4F.Heap.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.Heap.ST.fsti" }
[ { "abbrev": false, "full_module": "FStar.DM4F.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.DM4F.Heap.ref Prims.int -> FStar.DM4F.Heap.ST.ST (FStar.DM4F.Heap.ref (_: Prims.int -> Prims.int))
FStar.DM4F.Heap.ST.ST
[]
[]
[ "FStar.DM4F.Heap.ref", "Prims.int", "FStar.DM4F.Heap.ST.alloc", "Prims.op_Addition", "FStar.DM4F.Heap.ST.op_Bang", "FStar.DM4F.Heap.heap", "FStar.DM4F.Heap.contains_a_well_typed", "Prims.l_and", "Prims.l_not", "FStar.DM4F.Heap.contains", "FStar.DM4F.Heap.modifies", "FStar.Set.singleton", "Prims.nat", "FStar.DM4F.Heap.addr_of", "Prims.l_Forall", "Prims.b2t", "Prims.op_Equality", "FStar.DM4F.Heap.sel" ]
[]
false
true
false
false
false
let alloc_addition_and_incr (r: ref int) : ST (ref (int -> Tot int)) (requires (fun h -> h `contains_a_well_typed` r)) (ensures (fun h0 s h1 -> h0 `contains_a_well_typed` r /\ ~(h0 `contains` s) /\ h1 `contains_a_well_typed` s /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ (forall y. sel h1 s y = sel h0 r + y))) =
let x = !r in let s = alloc (fun y -> x + y) in s
false
Hacl.Bignum.Multiplication.fst
Hacl.Bignum.Multiplication.bn_sqr
val bn_sqr: #t:limb_t -> bn_sqr_st t
val bn_sqr: #t:limb_t -> bn_sqr_st t
let bn_sqr #t aLen a res = push_frame (); [@inline_let] let resLen = aLen +! aLen in memset res (uint #t 0) resLen; let h0 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v resLen)) (as_seq h0 res); [@inline_let] let spec h = SS.bn_sqr_f (as_seq h a) in loop1 h0 aLen res spec (fun j -> Loops.unfold_repeati (v aLen) (spec h0) (as_seq h0 res) (v j); let ab = sub a 0ul j in let a_j = a.(j) in res.(j +! j) <- bn_mul1_lshift_add j ab a_j resLen j res ); let c0 = Hacl.Bignum.Addition.bn_add_eq_len_u resLen res res res in LowStar.Ignore.ignore c0; let tmp = create resLen (uint #t 0) in bn_sqr_diag aLen a tmp; let c1 = Hacl.Bignum.Addition.bn_add_eq_len_u resLen res tmp res in LowStar.Ignore.ignore c1; pop_frame ()
{ "file_name": "code/bignum/Hacl.Bignum.Multiplication.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 14, "end_line": 233, "start_col": 0, "start_line": 208 }
module Hacl.Bignum.Multiplication open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base open Hacl.Impl.Lib module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Multiplication module SS = Hacl.Spec.Bignum.Squaring module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val bn_mul1: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> l:limb t -> res:lbignum t aLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ eq_or_disjoint a res) (ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l) let bn_mul1 #t aLen a l res = push_frame (); let c = create 1ul (uint #t 0) in [@inline_let] let refl h i = LSeq.index (as_seq h c) 0 in [@inline_let] let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\ B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in [@inline_let] let spec h = S.bn_mul1_f (as_seq h a) l in let h0 = ST.get () in fill_elems4 h0 aLen res refl footprint spec (fun i -> let h1 = ST.get () in let a_i = a.(i) in let res_i = sub res i 1ul in c.(0ul) <- mul_wide_add_st a_i l c.(0ul) res_i; lemma_eq_disjoint aLen aLen 1ul res a c i h0 h1 ); let c = c.(0ul) in pop_frame (); c inline_for_extraction noextract val bn_mul1_add_in_place: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> l:limb t -> res:lbignum t aLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_mul1_add_in_place (as_seq h0 a) l (as_seq h0 res)) let bn_mul1_add_in_place #t aLen a l res = push_frame (); let c = create 1ul (uint #t 0) in [@inline_let] let refl h i = LSeq.index (as_seq h c) 0 in [@inline_let] let footprint (i:size_nat{i <= v aLen}) : GTot (l:B.loc{B.loc_disjoint l (loc res) /\ B.address_liveness_insensitive_locs `B.loc_includes` l}) = loc c in [@inline_let] let spec h = S.bn_mul1_add_in_place_f (as_seq h a) l (as_seq h res) in let h0 = ST.get () in fill_elems4 h0 aLen res refl footprint spec (fun i -> let a_i = a.(i) in let res_i = sub res i 1ul in c.(0ul) <- mul_wide_add2_st a_i l c.(0ul) res_i ); let c = c.(0ul) in pop_frame (); c inline_for_extraction noextract val bn_mul1_lshift_add: #t:limb_t -> aLen:size_t -> a:lbignum t aLen -> b_j:limb t -> resLen:size_t -> j:size_t{v j + v aLen <= v resLen} -> res:lbignum t resLen -> Stack (limb t) (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\ (c, as_seq h1 res) == S.bn_mul1_lshift_add (as_seq h0 a) b_j (v j) (as_seq h0 res)) let bn_mul1_lshift_add #t aLen a b_j resLen j res = let res_j = sub res j aLen in let h0 = ST.get () in update_sub_f_carry h0 res j aLen (fun h -> S.bn_mul1_add_in_place (as_seq h0 a) b_j (as_seq h0 res_j)) (fun _ -> bn_mul1_add_in_place aLen a b_j res_j) inline_for_extraction noextract let bn_mul_st (t:limb_t) = aLen:size_t -> a:lbignum t aLen -> bLen:size_t{v aLen + v bLen <= max_size_t} -> b:lbignum t bLen -> res:lbignum t (aLen +! bLen) -> Stack unit (requires fun h -> live h a /\ live h b /\ live h res /\ disjoint res a /\ disjoint res b /\ eq_or_disjoint a b) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b)) inline_for_extraction noextract val bn_mul: #t:limb_t -> bn_mul_st t let bn_mul #t aLen a bLen b res = [@inline_let] let resLen = aLen +! bLen in memset res (uint #t 0) resLen; let h0 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v resLen)) (as_seq h0 res); [@ inline_let] let spec h = S.bn_mul_ (as_seq h a) (as_seq h b) in loop1 h0 bLen res spec (fun j -> Loops.unfold_repeati (v bLen) (spec h0) (as_seq h0 res) (v j); let bj = b.(j) in res.(aLen +! j) <- bn_mul1_lshift_add aLen a bj (aLen +! bLen) j res ) [@CInline] let bn_mul_u32 : bn_mul_st U32 = bn_mul [@CInline] let bn_mul_u64 : bn_mul_st U64 = bn_mul inline_for_extraction noextract let bn_mul_u (#t:limb_t) : bn_mul_st t = match t with | U32 -> bn_mul_u32 | U64 -> bn_mul_u64 inline_for_extraction noextract val bn_sqr_diag: #t:limb_t -> aLen:size_t{v aLen + v aLen <= max_size_t} -> a:lbignum t aLen -> res:lbignum t (aLen +! aLen) -> Stack unit (requires fun h -> live h a /\ live h res /\ disjoint res a /\ as_seq h res == LSeq.create (v aLen + v aLen) (uint #t 0)) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == SS.bn_sqr_diag (as_seq h0 a)) let bn_sqr_diag #t aLen a res = let h0 = ST.get () in [@inline_let] let spec h = SS.bn_sqr_diag_f (as_seq h a) in loop1 h0 aLen res spec (fun i -> Loops.unfold_repeati (v aLen) (spec h0) (as_seq h0 res) (v i); let (hi, lo) = mul_wide a.(i) a.(i) in res.(2ul *! i) <- lo; res.(2ul *! i +! 1ul) <- hi) // This code is taken from BoringSSL // https://github.com/google/boringssl/blob/master/crypto/fipsmodule/bn/mul.c#L551 inline_for_extraction noextract let bn_sqr_st (t:limb_t) = aLen:size_t{0 < v aLen /\ v aLen + v aLen <= max_size_t} -> a:lbignum t aLen -> res:lbignum t (aLen +! aLen) -> Stack unit (requires fun h -> live h a /\ live h res /\ disjoint res a) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ as_seq h1 res == SS.bn_sqr (as_seq h0 a)) inline_for_extraction noextract
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Ignore.fsti.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Squaring.fst.checked", "Hacl.Spec.Bignum.Multiplication.fst.checked", "Hacl.Impl.Lib.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.Addition.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.Multiplication.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Squaring", "short_module": "SS" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Multiplication", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Lib", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Bignum.Multiplication.bn_sqr_st t
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Lib.IntTypes.size_t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Lib.IntTypes.max_size_t", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "LowStar.Ignore.ignore", "Hacl.Spec.Bignum.Base.carry", "Hacl.Bignum.Addition.bn_add_eq_len_u", "Hacl.Bignum.Multiplication.bn_sqr_diag", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.create", "Lib.IntTypes.uint", "Lib.IntTypes.SEC", "Lib.Buffer.lbuffer", "Lib.Buffer.loop1", "Lib.Buffer.op_Array_Assignment", "Hacl.Bignum.Multiplication.bn_mul1_lshift_add", "Lib.Buffer.op_Array_Access", "Lib.Buffer.sub", "FStar.UInt32.__uint_to_t", "Lib.LoopCombinators.unfold_repeati", "Hacl.Spec.Bignum.Definitions.lbignum", "Lib.Buffer.as_seq", "FStar.Monotonic.HyperStack.mem", "Prims.nat", "Hacl.Spec.Bignum.Squaring.bn_sqr_f", "Lib.Sequence.eq_intro", "Lib.Sequence.sub", "FStar.HyperStack.ST.get", "Lib.Buffer.memset", "Lib.IntTypes.int_t", "FStar.HyperStack.ST.push_frame" ]
[]
false
false
false
false
false
let bn_sqr #t aLen a res =
push_frame (); [@@ inline_let ]let resLen = aLen +! aLen in memset res (uint #t 0) resLen; let h0 = ST.get () in LSeq.eq_intro (LSeq.sub (as_seq h0 res) 0 (v resLen)) (as_seq h0 res); [@@ inline_let ]let spec h = SS.bn_sqr_f (as_seq h a) in loop1 h0 aLen res spec (fun j -> Loops.unfold_repeati (v aLen) (spec h0) (as_seq h0 res) (v j); let ab = sub a 0ul j in let a_j = a.(j) in res.(j +! j) <- bn_mul1_lshift_add j ab a_j resLen j res); let c0 = Hacl.Bignum.Addition.bn_add_eq_len_u resLen res res res in LowStar.Ignore.ignore c0; let tmp = create resLen (uint #t 0) in bn_sqr_diag aLen a tmp; let c1 = Hacl.Bignum.Addition.bn_add_eq_len_u resLen res tmp res in LowStar.Ignore.ignore c1; pop_frame ()
false
Hacl.Streaming.Poly1305.fst
Hacl.Streaming.Poly1305.with_or_without_r
val with_or_without_r (acc r: Spec.Poly1305.felem) (blocks: S.seq uint8) : Lemma (requires S.length blocks % Spec.Poly1305.size_block = 0) (ensures update_multi (acc, r) blocks == (update_multi' r acc blocks, r)) (decreases (S.length blocks))
val with_or_without_r (acc r: Spec.Poly1305.felem) (blocks: S.seq uint8) : Lemma (requires S.length blocks % Spec.Poly1305.size_block = 0) (ensures update_multi (acc, r) blocks == (update_multi' r acc blocks, r)) (decreases (S.length blocks))
let rec with_or_without_r (acc r: Spec.Poly1305.felem) (blocks: S.seq uint8): Lemma (requires S.length blocks % Spec.Poly1305.size_block = 0) (ensures update_multi (acc, r) blocks == (update_multi' r acc blocks, r)) (decreases (S.length blocks)) = if S.length blocks = 0 then () else let block, rem = Lib.UpdateMulti.split_block Spec.Poly1305.size_block blocks 1 in let acc = update' r acc block in with_or_without_r acc r rem
{ "file_name": "code/streaming/Hacl.Streaming.Poly1305.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 31, "end_line": 151, "start_col": 0, "start_line": 138 }
module Hacl.Streaming.Poly1305 module HS = FStar.HyperStack module B = LowStar.Buffer module G = FStar.Ghost module S = FStar.Seq module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module I = Hacl.Streaming.Interface module P = Hacl.Impl.Poly1305 module F32xN = Hacl.Spec.Poly1305.Field32xN module ST = FStar.HyperStack.ST open LowStar.BufferOps open FStar.Mul /// Opening a bunch of modules for Poly1305 /// ======================================= inline_for_extraction noextract let uint8 = Lib.IntTypes.uint8 inline_for_extraction noextract let uint32 = Lib.IntTypes.uint32 open Hacl.Impl.Poly1305.Fields /// An instance of the stateful type class for poly1305 state /// ========================================================= /// /// We use a custom view that separates r and acc, to respect abstraction boundaries established by Poly1305. #set-options "--fuel 0 --ifuel 1 --z3rlimit 100" inline_for_extraction noextract let t (fs : field_spec) = b:B.buffer (limb fs) { B.length b == 25 } inline_for_extraction noextract let as_raw (#fs : field_spec) (x: t fs): B.buffer (limb fs) = x inline_for_extraction noextract let as_lib (#fs : field_spec) (x: t fs): P.poly1305_ctx fs = assert (Lib.IntTypes.(v (add #U32 (nlimb fs) (precomplen fs))) == 25); x inline_for_extraction noextract let poly1305_key = I.stateful_buffer uint8 32ul (Lib.IntTypes.u8 0) unit inline_for_extraction noextract let as_lib_k (x: B.buffer uint8 { B.length x = 32 }): Lib.Buffer.lbuffer uint8 32ul = x inline_for_extraction noextract let num_lanes (fs : field_spec) : F32xN.lanes = match fs with | M32 -> 1 | M128 -> 2 | M256 -> 4 inline_for_extraction noextract let stateful_poly1305_ctx (fs : field_spec) : I.stateful unit = I.Stateful (fun () -> t fs) (fun #_ _ s -> B.loc_addr_of_buffer (as_raw s)) (fun #_ _ s -> B.freeable (as_raw s)) (fun #_ h s -> B.live h (as_raw s) /\ P.state_inv_t h (as_lib s)) (fun () -> Spec.Poly1305.felem & Spec.Poly1305.felem) (fun () h s -> P.as_get_acc h (as_lib s), P.as_get_r h (as_lib s)) (fun #_ _ _ -> ()) (fun #_ l s h0 h1 -> P.reveal_ctx_inv (as_lib s) h0 h1; B.modifies_buffer_elim (as_raw s) l h0 h1) (fun #_ _ _ _ _ -> ()) (fun () -> [@inline_let] let n = num_lanes fs in let r = B.alloca (F32xN.zero n) 25ul in let h1 = ST.get () in P.ctx_inv_zeros #fs r h1; r) (fun () r -> [@inline_let] let n = num_lanes fs in let r = B.malloc r (F32xN.zero n) 25ul in let h1 = ST.get () in P.ctx_inv_zeros #fs r h1; r) (fun _ s -> B.free s) (fun _ src dst -> let h0 = ST.get () in B.blit src 0ul dst 0ul 25ul; let h1 = ST.get () in P.reveal_ctx_inv' (as_lib src) (as_lib dst) h0 h1) /// Interlude for spec equivalence proofs /// ===================================== /// /// A quick explanation about this proof of equivalence. At the spec level, /// ``poly1305_update`` needs both ``r`` and the accumulator ``acc``. This thus /// makes poly1305 update a function of two arguments. However, the streaming /// facility is constructed over specifications that take one single argument. /// Not a problem! We carry the pair ``(r, acc)`` as our "streaming functor /// accumulator", and we now have to show that a specification in terms of /// ``update (update (r, acc) init)`` is the same as poly1305. For that, we need /// to do a little proof of equivalence to show first that this is the same as /// ``(update r) ((update r) acc)`` (note that the update function now becomes a /// partial application), then use the update-multi-repeat conversion lemma to /// get the original specification of poly1305. inline_for_extraction noextract let block = (block: S.seq uint8 { S.length block = Spec.Poly1305.size_block }) inline_for_extraction noextract let update_ (acc, r) (block: block) = Spec.Poly1305.poly1305_update1 r Spec.Poly1305.size_block block acc, r /// Same as [update_], but with the input not necessarily a full block (can be smaller) inline_for_extraction noextract let update__ (acc, r) (input: S.seq uint8{S.length input <= Spec.Poly1305.size_block}) = Spec.Poly1305.poly1305_update1 r (S.length input) input acc, r inline_for_extraction noextract let update' r acc (block: block) = Spec.Poly1305.poly1305_update1 r Spec.Poly1305.size_block block acc inline_for_extraction noextract let update_multi = Lib.UpdateMulti.mk_update_multi Spec.Poly1305.size_block update_ inline_for_extraction noextract let update_multi' r = Lib.UpdateMulti.mk_update_multi Spec.Poly1305.size_block (update' r) #push-options "--fuel 1"
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.UpdateMulti.Lemmas.fsti.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "Hacl.Poly1305_32.fsti.checked", "Hacl.Poly1305_256.fsti.checked", "Hacl.Poly1305_128.fsti.checked", "Hacl.Impl.Poly1305.Fields.fst.checked", "Hacl.Impl.Poly1305.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.Poly1305.fst" }
[ { "abbrev": false, "full_module": "Hacl.Impl.Poly1305.Fields", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": "F32xN" }, { "abbrev": true, "full_module": "Hacl.Impl.Poly1305", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Streaming.Interface", "short_module": "I" }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
acc: Spec.Poly1305.felem -> r: Spec.Poly1305.felem -> blocks: FStar.Seq.Base.seq Hacl.Streaming.Poly1305.uint8 -> FStar.Pervasives.Lemma (requires FStar.Seq.Base.length blocks % Spec.Poly1305.size_block = 0) (ensures Hacl.Streaming.Poly1305.update_multi (acc, r) blocks == (Hacl.Streaming.Poly1305.update_multi' r acc blocks, r)) (decreases FStar.Seq.Base.length blocks)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "Spec.Poly1305.felem", "FStar.Seq.Base.seq", "Hacl.Streaming.Poly1305.uint8", "Prims.op_Equality", "Prims.int", "FStar.Seq.Base.length", "Prims.bool", "Lib.UpdateMulti.uint8", "Hacl.Streaming.Poly1305.with_or_without_r", "Hacl.Streaming.Poly1305.update'", "Prims.unit", "FStar.Pervasives.Native.tuple2", "Lib.UpdateMulti.split_block", "Spec.Poly1305.size_block", "Prims.b2t", "Prims.op_Modulus", "Prims.squash", "Prims.eq2", "Hacl.Streaming.Poly1305.update_multi", "FStar.Pervasives.Native.Mktuple2", "Hacl.Streaming.Poly1305.update_multi'", "Prims.Nil", "FStar.Pervasives.pattern" ]
[ "recursion" ]
false
false
true
false
false
let rec with_or_without_r (acc r: Spec.Poly1305.felem) (blocks: S.seq uint8) : Lemma (requires S.length blocks % Spec.Poly1305.size_block = 0) (ensures update_multi (acc, r) blocks == (update_multi' r acc blocks, r)) (decreases (S.length blocks)) =
if S.length blocks = 0 then () else let block, rem = Lib.UpdateMulti.split_block Spec.Poly1305.size_block blocks 1 in let acc = update' r acc block in with_or_without_r acc r rem
false
Hacl.Impl.Salsa20.Core32.fst
Hacl.Impl.Salsa20.Core32.xor_block
val xor_block: o:lbuffer uint8 64ul -> st:state -> b:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h o /\ live h st /\ live h b) (ensures fun h0 _ h1 -> modifies (loc o) h0 h1 /\ as_seq h1 o == Spec.xor_block (as_seq h0 st) (as_seq h0 b))
val xor_block: o:lbuffer uint8 64ul -> st:state -> b:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h o /\ live h st /\ live h b) (ensures fun h0 _ h1 -> modifies (loc o) h0 h1 /\ as_seq h1 o == Spec.xor_block (as_seq h0 st) (as_seq h0 b))
let xor_block o st b = push_frame(); let bl = create_state() in load_state bl b; map2T (size 16) bl ( ^. ) bl st; store_state o bl; pop_frame()
{ "file_name": "code/salsa20/Hacl.Impl.Salsa20.Core32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 13, "end_line": 110, "start_col": 0, "start_line": 104 }
module Hacl.Impl.Salsa20.Core32 open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.Sequence open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module Spec = Spec.Salsa20 let state = lbuffer uint32 16ul let index = i:size_t{size_v i < 16} inline_for_extraction val create_state: unit -> StackInline state (requires fun h -> True) (ensures fun h0 r h1 -> live h1 r /\ as_seq h1 r == Seq.create 16 (u32 0) /\ stack_allocated r h0 h1 (Seq.create 16 (u32 0))) let create_state () = create (size 16) (u32 0) inline_for_extraction val load_state: st:state -> b:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h st /\ live h b /\ disjoint st b) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Lib.ByteSequence.uints_from_bytes_le (as_seq h0 b)) let load_state st b = uints_from_bytes_le st b inline_for_extraction val store_state: b:lbuffer uint8 64ul -> st:state -> Stack unit (requires fun h -> live h st /\ live h b /\ disjoint st b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == Lib.ByteSequence.uints_to_bytes_le (as_seq h0 st)) let store_state st b = uints_to_bytes_le 16ul st b inline_for_extraction val set_counter: st:state -> c:size_t -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Seq.upd (as_seq h0 st) 8 (size_to_uint32 c)) let set_counter st c = st.(size 8) <- size_to_uint32 c inline_for_extraction val copy_state: st:state -> ost:state -> Stack unit (requires fun h -> live h st /\ live h ost /\ disjoint st ost) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == as_seq h0 ost) let copy_state st ost = copy #MUT #uint32 #(size 16) st ost inline_for_extraction val sum_state: st:state -> ost:state -> Stack unit (requires fun h -> live h st /\ live h ost /\ eq_or_disjoint st ost) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Lib.Sequence.map2 (+.) (as_seq h0 st) (as_seq h0 ost)) let sum_state st ost = map2T #MUT #MUT #uint32 #uint32 #uint32 (size 16) st ( +. ) st ost inline_for_extraction val xor_block: o:lbuffer uint8 64ul -> st:state -> b:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h o /\ live h st /\ live h b) (ensures fun h0 _ h1 -> modifies (loc o) h0 h1 /\ as_seq h1 o == Spec.xor_block (as_seq h0 st) (as_seq h0 b))
{ "checked_file": "/", "dependencies": [ "Spec.Salsa20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Salsa20.Core32.fst" }
[ { "abbrev": true, "full_module": "Spec.Salsa20", "short_module": "Spec" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Salsa20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Salsa20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
o: Lib.Buffer.lbuffer Lib.IntTypes.uint8 64ul -> st: Hacl.Impl.Salsa20.Core32.state -> b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 64ul -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Salsa20.Core32.state", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Impl.Salsa20.Core32.store_state", "Lib.Buffer.map2T", "Lib.Buffer.MUT", "Lib.IntTypes.uint32", "Lib.IntTypes.size", "Lib.IntTypes.op_Hat_Dot", "Lib.IntTypes.U32", "Lib.IntTypes.SEC", "Hacl.Impl.Salsa20.Core32.load_state", "Hacl.Impl.Salsa20.Core32.create_state", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let xor_block o st b =
push_frame (); let bl = create_state () in load_state bl b; map2T (size 16) bl ( ^. ) bl st; store_state o bl; pop_frame ()
false
Hacl.Streaming.Poly1305.fst
Hacl.Streaming.Poly1305.stateful_poly1305_ctx
val stateful_poly1305_ctx (fs: field_spec) : I.stateful unit
val stateful_poly1305_ctx (fs: field_spec) : I.stateful unit
let stateful_poly1305_ctx (fs : field_spec) : I.stateful unit = I.Stateful (fun () -> t fs) (fun #_ _ s -> B.loc_addr_of_buffer (as_raw s)) (fun #_ _ s -> B.freeable (as_raw s)) (fun #_ h s -> B.live h (as_raw s) /\ P.state_inv_t h (as_lib s)) (fun () -> Spec.Poly1305.felem & Spec.Poly1305.felem) (fun () h s -> P.as_get_acc h (as_lib s), P.as_get_r h (as_lib s)) (fun #_ _ _ -> ()) (fun #_ l s h0 h1 -> P.reveal_ctx_inv (as_lib s) h0 h1; B.modifies_buffer_elim (as_raw s) l h0 h1) (fun #_ _ _ _ _ -> ()) (fun () -> [@inline_let] let n = num_lanes fs in let r = B.alloca (F32xN.zero n) 25ul in let h1 = ST.get () in P.ctx_inv_zeros #fs r h1; r) (fun () r -> [@inline_let] let n = num_lanes fs in let r = B.malloc r (F32xN.zero n) 25ul in let h1 = ST.get () in P.ctx_inv_zeros #fs r h1; r) (fun _ s -> B.free s) (fun _ src dst -> let h0 = ST.get () in B.blit src 0ul dst 0ul 25ul; let h1 = ST.get () in P.reveal_ctx_inv' (as_lib src) (as_lib dst) h0 h1)
{ "file_name": "code/streaming/Hacl.Streaming.Poly1305.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 56, "end_line": 95, "start_col": 0, "start_line": 62 }
module Hacl.Streaming.Poly1305 module HS = FStar.HyperStack module B = LowStar.Buffer module G = FStar.Ghost module S = FStar.Seq module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module I = Hacl.Streaming.Interface module P = Hacl.Impl.Poly1305 module F32xN = Hacl.Spec.Poly1305.Field32xN module ST = FStar.HyperStack.ST open LowStar.BufferOps open FStar.Mul /// Opening a bunch of modules for Poly1305 /// ======================================= inline_for_extraction noextract let uint8 = Lib.IntTypes.uint8 inline_for_extraction noextract let uint32 = Lib.IntTypes.uint32 open Hacl.Impl.Poly1305.Fields /// An instance of the stateful type class for poly1305 state /// ========================================================= /// /// We use a custom view that separates r and acc, to respect abstraction boundaries established by Poly1305. #set-options "--fuel 0 --ifuel 1 --z3rlimit 100" inline_for_extraction noextract let t (fs : field_spec) = b:B.buffer (limb fs) { B.length b == 25 } inline_for_extraction noextract let as_raw (#fs : field_spec) (x: t fs): B.buffer (limb fs) = x inline_for_extraction noextract let as_lib (#fs : field_spec) (x: t fs): P.poly1305_ctx fs = assert (Lib.IntTypes.(v (add #U32 (nlimb fs) (precomplen fs))) == 25); x inline_for_extraction noextract let poly1305_key = I.stateful_buffer uint8 32ul (Lib.IntTypes.u8 0) unit inline_for_extraction noextract let as_lib_k (x: B.buffer uint8 { B.length x = 32 }): Lib.Buffer.lbuffer uint8 32ul = x inline_for_extraction noextract let num_lanes (fs : field_spec) : F32xN.lanes = match fs with | M32 -> 1 | M128 -> 2 | M256 -> 4
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.UpdateMulti.Lemmas.fsti.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "Hacl.Poly1305_32.fsti.checked", "Hacl.Poly1305_256.fsti.checked", "Hacl.Poly1305_128.fsti.checked", "Hacl.Impl.Poly1305.Fields.fst.checked", "Hacl.Impl.Poly1305.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.Poly1305.fst" }
[ { "abbrev": false, "full_module": "Hacl.Impl.Poly1305.Fields", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": "F32xN" }, { "abbrev": true, "full_module": "Hacl.Impl.Poly1305", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Streaming.Interface", "short_module": "I" }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
fs: Hacl.Impl.Poly1305.Fields.field_spec -> Hacl.Streaming.Interface.stateful Prims.unit
Prims.Tot
[ "total" ]
[]
[ "Hacl.Impl.Poly1305.Fields.field_spec", "Hacl.Streaming.Interface.Stateful", "Prims.unit", "Hacl.Streaming.Poly1305.t", "FStar.Monotonic.HyperStack.mem", "LowStar.Monotonic.Buffer.loc_addr_of_buffer", "Hacl.Impl.Poly1305.Fields.limb", "LowStar.Buffer.trivial_preorder", "Hacl.Streaming.Poly1305.as_raw", "LowStar.Monotonic.Buffer.loc", "LowStar.Monotonic.Buffer.freeable", "Prims.l_and", "LowStar.Monotonic.Buffer.live", "Hacl.Impl.Poly1305.state_inv_t", "Hacl.Streaming.Poly1305.as_lib", "FStar.Pervasives.Native.tuple2", "Spec.Poly1305.felem", "FStar.Pervasives.Native.Mktuple2", "Hacl.Impl.Poly1305.as_get_acc", "Hacl.Impl.Poly1305.as_get_r", "LowStar.Monotonic.Buffer.modifies_buffer_elim", "Hacl.Impl.Poly1305.reveal_ctx_inv", "Hacl.Impl.Poly1305.ctx_inv_zeros", "FStar.HyperStack.ST.get", "LowStar.Monotonic.Buffer.mbuffer", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "Prims.eq2", "Prims.nat", "LowStar.Monotonic.Buffer.length", "FStar.UInt32.v", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Prims.b2t", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "LowStar.Buffer.alloca", "Hacl.Spec.Poly1305.Field32xN.zero", "FStar.UInt32.__uint_to_t", "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Streaming.Poly1305.num_lanes", "FStar.Monotonic.HyperHeap.rid", "LowStar.Monotonic.Buffer.frameOf", "LowStar.Buffer.malloc", "FStar.Ghost.erased", "LowStar.Monotonic.Buffer.free", "Hacl.Impl.Poly1305.reveal_ctx_inv'", "LowStar.Monotonic.Buffer.blit", "Hacl.Streaming.Interface.stateful" ]
[]
false
false
false
true
false
let stateful_poly1305_ctx (fs: field_spec) : I.stateful unit =
I.Stateful (fun () -> t fs) (fun #_ _ s -> B.loc_addr_of_buffer (as_raw s)) (fun #_ _ s -> B.freeable (as_raw s)) (fun #_ h s -> B.live h (as_raw s) /\ P.state_inv_t h (as_lib s)) (fun () -> Spec.Poly1305.felem & Spec.Poly1305.felem) (fun () h s -> P.as_get_acc h (as_lib s), P.as_get_r h (as_lib s)) (fun #_ _ _ -> ()) (fun #_ l s h0 h1 -> P.reveal_ctx_inv (as_lib s) h0 h1; B.modifies_buffer_elim (as_raw s) l h0 h1) (fun #_ _ _ _ _ -> ()) (fun () -> [@@ inline_let ]let n = num_lanes fs in let r = B.alloca (F32xN.zero n) 25ul in let h1 = ST.get () in P.ctx_inv_zeros #fs r h1; r) (fun () r -> [@@ inline_let ]let n = num_lanes fs in let r = B.malloc r (F32xN.zero n) 25ul in let h1 = ST.get () in P.ctx_inv_zeros #fs r h1; r) (fun _ s -> B.free s) (fun _ src dst -> let h0 = ST.get () in B.blit src 0ul dst 0ul 25ul; let h1 = ST.get () in P.reveal_ctx_inv' (as_lib src) (as_lib dst) h0 h1)
false
Hacl.Streaming.Poly1305.fst
Hacl.Streaming.Poly1305.update_multi_is_update
val update_multi_is_update (input: S.seq uint8) (acc: Spec.Poly1305.felem) (r: Spec.Poly1305.felem): Lemma (requires (S.length input % Spec.Poly1305.size_block = 0)) (ensures (update_multi (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r)))
val update_multi_is_update (input: S.seq uint8) (acc: Spec.Poly1305.felem) (r: Spec.Poly1305.felem): Lemma (requires (S.length input % Spec.Poly1305.size_block = 0)) (ensures (update_multi (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r)))
let update_multi_is_update input acc r = let open Lib.UpdateMulti.Lemmas in let block_length = Spec.Poly1305.size_block in assert_norm (block_length < pow2 32); calc (==) { update_multi (acc, r) input; (==) { with_or_without_r acc r input } update_multi' r acc input, r; (==) { } update_last' r (update_multi' r acc input) S.empty, r; (==) { update_full_is_repeat_blocks block_length (update' r) (update_last' r) acc input input } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input (repeat_f block_length (update' r)) (repeat_l block_length (update_last' r) input) acc, r; (==) { Lib.Sequence.Lemmas.repeat_blocks_extensionality block_length input (repeat_f block_length (update' r)) Spec.Poly1305.(poly1305_update1 r size_block) (repeat_l block_length (update_last' r) input) Spec.Poly1305.(poly1305_update_last r) acc } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input Spec.Poly1305.(poly1305_update1 r size_block) Spec.Poly1305.(poly1305_update_last r) acc, r; }
{ "file_name": "code/streaming/Hacl.Streaming.Poly1305.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 318, "start_col": 0, "start_line": 292 }
module Hacl.Streaming.Poly1305 module HS = FStar.HyperStack module B = LowStar.Buffer module G = FStar.Ghost module S = FStar.Seq module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module I = Hacl.Streaming.Interface module P = Hacl.Impl.Poly1305 module F32xN = Hacl.Spec.Poly1305.Field32xN module ST = FStar.HyperStack.ST open LowStar.BufferOps open FStar.Mul /// Opening a bunch of modules for Poly1305 /// ======================================= inline_for_extraction noextract let uint8 = Lib.IntTypes.uint8 inline_for_extraction noextract let uint32 = Lib.IntTypes.uint32 open Hacl.Impl.Poly1305.Fields /// An instance of the stateful type class for poly1305 state /// ========================================================= /// /// We use a custom view that separates r and acc, to respect abstraction boundaries established by Poly1305. #set-options "--fuel 0 --ifuel 1 --z3rlimit 100" inline_for_extraction noextract let t (fs : field_spec) = b:B.buffer (limb fs) { B.length b == 25 } inline_for_extraction noextract let as_raw (#fs : field_spec) (x: t fs): B.buffer (limb fs) = x inline_for_extraction noextract let as_lib (#fs : field_spec) (x: t fs): P.poly1305_ctx fs = assert (Lib.IntTypes.(v (add #U32 (nlimb fs) (precomplen fs))) == 25); x inline_for_extraction noextract let poly1305_key = I.stateful_buffer uint8 32ul (Lib.IntTypes.u8 0) unit inline_for_extraction noextract let as_lib_k (x: B.buffer uint8 { B.length x = 32 }): Lib.Buffer.lbuffer uint8 32ul = x inline_for_extraction noextract let num_lanes (fs : field_spec) : F32xN.lanes = match fs with | M32 -> 1 | M128 -> 2 | M256 -> 4 inline_for_extraction noextract let stateful_poly1305_ctx (fs : field_spec) : I.stateful unit = I.Stateful (fun () -> t fs) (fun #_ _ s -> B.loc_addr_of_buffer (as_raw s)) (fun #_ _ s -> B.freeable (as_raw s)) (fun #_ h s -> B.live h (as_raw s) /\ P.state_inv_t h (as_lib s)) (fun () -> Spec.Poly1305.felem & Spec.Poly1305.felem) (fun () h s -> P.as_get_acc h (as_lib s), P.as_get_r h (as_lib s)) (fun #_ _ _ -> ()) (fun #_ l s h0 h1 -> P.reveal_ctx_inv (as_lib s) h0 h1; B.modifies_buffer_elim (as_raw s) l h0 h1) (fun #_ _ _ _ _ -> ()) (fun () -> [@inline_let] let n = num_lanes fs in let r = B.alloca (F32xN.zero n) 25ul in let h1 = ST.get () in P.ctx_inv_zeros #fs r h1; r) (fun () r -> [@inline_let] let n = num_lanes fs in let r = B.malloc r (F32xN.zero n) 25ul in let h1 = ST.get () in P.ctx_inv_zeros #fs r h1; r) (fun _ s -> B.free s) (fun _ src dst -> let h0 = ST.get () in B.blit src 0ul dst 0ul 25ul; let h1 = ST.get () in P.reveal_ctx_inv' (as_lib src) (as_lib dst) h0 h1) /// Interlude for spec equivalence proofs /// ===================================== /// /// A quick explanation about this proof of equivalence. At the spec level, /// ``poly1305_update`` needs both ``r`` and the accumulator ``acc``. This thus /// makes poly1305 update a function of two arguments. However, the streaming /// facility is constructed over specifications that take one single argument. /// Not a problem! We carry the pair ``(r, acc)`` as our "streaming functor /// accumulator", and we now have to show that a specification in terms of /// ``update (update (r, acc) init)`` is the same as poly1305. For that, we need /// to do a little proof of equivalence to show first that this is the same as /// ``(update r) ((update r) acc)`` (note that the update function now becomes a /// partial application), then use the update-multi-repeat conversion lemma to /// get the original specification of poly1305. inline_for_extraction noextract let block = (block: S.seq uint8 { S.length block = Spec.Poly1305.size_block }) inline_for_extraction noextract let update_ (acc, r) (block: block) = Spec.Poly1305.poly1305_update1 r Spec.Poly1305.size_block block acc, r /// Same as [update_], but with the input not necessarily a full block (can be smaller) inline_for_extraction noextract let update__ (acc, r) (input: S.seq uint8{S.length input <= Spec.Poly1305.size_block}) = Spec.Poly1305.poly1305_update1 r (S.length input) input acc, r inline_for_extraction noextract let update' r acc (block: block) = Spec.Poly1305.poly1305_update1 r Spec.Poly1305.size_block block acc inline_for_extraction noextract let update_multi = Lib.UpdateMulti.mk_update_multi Spec.Poly1305.size_block update_ inline_for_extraction noextract let update_multi' r = Lib.UpdateMulti.mk_update_multi Spec.Poly1305.size_block (update' r) #push-options "--fuel 1" inline_for_extraction noextract let rec with_or_without_r (acc r: Spec.Poly1305.felem) (blocks: S.seq uint8): Lemma (requires S.length blocks % Spec.Poly1305.size_block = 0) (ensures update_multi (acc, r) blocks == (update_multi' r acc blocks, r)) (decreases (S.length blocks)) = if S.length blocks = 0 then () else let block, rem = Lib.UpdateMulti.split_block Spec.Poly1305.size_block blocks 1 in let acc = update' r acc block in with_or_without_r acc r rem #pop-options inline_for_extraction noextract let update_last (acc, r) (input: S.seq uint8 { S.length input <= Spec.Poly1305.size_block }) = if S.length input = 0 then acc, r else Spec.Poly1305.poly1305_update1 r (S.length input) input acc, r inline_for_extraction noextract let update_last' r acc (input: S.seq uint8 { S.length input <= Spec.Poly1305.size_block }) = if S.length input = 0 then acc else Spec.Poly1305.poly1305_update1 r (S.length input) input acc inline_for_extraction noextract let finish_ k (acc, r) = Spec.Poly1305.poly1305_finish k acc inline_for_extraction noextract let spec k input = Spec.Poly1305.poly1305_mac input k val update_last_not_block_is_update (input: S.seq uint8) (acc: Spec.Poly1305.felem) (r: Spec.Poly1305.felem): Lemma (requires (S.length input < Spec.Poly1305.size_block)) (ensures (update_last (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r))) let update_last_not_block_is_update input acc r = let open Lib.UpdateMulti.Lemmas in let block_length = Spec.Poly1305.size_block in assert_norm (block_length < pow2 32); calc (==) { update_last (acc, r) input; (==) { } update_last' r acc input, r; (==) { Lib.UpdateMulti.update_multi_zero Spec.Poly1305.size_block (update' r) acc } update_last' r (update_multi' r acc S.empty) input, r; (==) { update_full_is_repeat_blocks block_length (update' r) (update_last' r) acc input input } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input (repeat_f block_length (update' r)) (repeat_l block_length (update_last' r) input) acc, r; (==) { Lib.Sequence.Lemmas.repeat_blocks_extensionality block_length input (repeat_f block_length (update' r)) Spec.Poly1305.(poly1305_update1 r size_block) (repeat_l block_length (update_last' r) input) Spec.Poly1305.(poly1305_update_last r) acc } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input Spec.Poly1305.(poly1305_update1 r size_block) Spec.Poly1305.(poly1305_update_last r) acc, r; } val update_last_block_is_update (input: S.seq uint8) (acc: Spec.Poly1305.felem) (r: Spec.Poly1305.felem): Lemma (requires (S.length input = Spec.Poly1305.size_block)) (ensures (update_last (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r))) open FStar.Tactics #push-options "--fuel 1 --print_implicits" let update_last_block_is_update input acc r = let open Lib.UpdateMulti.Lemmas in let block_length = Spec.Poly1305.size_block in assert_norm (block_length < pow2 32); assert(input `S.equal` S.append input S.empty); let acc1 = update' r acc input in let acc1' = update_multi' r acc input in // SH: fun fact: this lemma call and the following assert should be the // last part of the below calc. However, if put below/inside the calc, // the proof loops. Lib.Sequence.Lemmas.repeat_blocks_extensionality block_length input (repeat_f block_length (update' r)) Spec.Poly1305.(poly1305_update1 r size_block) (repeat_l block_length (update_last' r) input) Spec.Poly1305.(poly1305_update_last r) acc; assert( Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input (repeat_f block_length (update' r)) (repeat_l block_length (update_last' r) input) acc == Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input Spec.Poly1305.(poly1305_update1 r size_block) Spec.Poly1305.(poly1305_update_last r) acc); assert( let block, rem = Lib.UpdateMulti.split_block block_length input 1 in block `S.equal` input /\ rem `S.equal` S.empty); assert( Lib.UpdateMulti.mk_update_multi block_length (update' r) acc1 S.empty == acc1'); assert(acc1 == acc1'); calc (==) { update_last (acc, r) input; (==) { } update_last' r acc input, r; (==) { } update_last' r (update' r acc input) S.empty, r; (==) { } update_last' r (update_multi' r acc input) S.empty, r; (==) { update_full_is_repeat_blocks block_length (update' r) (update_last' r) acc input input } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input (repeat_f block_length (update' r)) (repeat_l block_length (update_last' r) input) acc, r; } #pop-options val update_last_is_update (input: S.seq uint8) (acc: Spec.Poly1305.felem) (r: Spec.Poly1305.felem): Lemma (requires (S.length input <= Spec.Poly1305.size_block)) (ensures (update_last (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r))) let update_last_is_update input acc r = if S.length input = Spec.Poly1305.size_block then update_last_block_is_update input acc r else update_last_not_block_is_update input acc r val update_multi_is_update (input: S.seq uint8) (acc: Spec.Poly1305.felem) (r: Spec.Poly1305.felem): Lemma (requires (S.length input % Spec.Poly1305.size_block = 0)) (ensures (update_multi (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r)))
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.UpdateMulti.Lemmas.fsti.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "Hacl.Poly1305_32.fsti.checked", "Hacl.Poly1305_256.fsti.checked", "Hacl.Poly1305_128.fsti.checked", "Hacl.Impl.Poly1305.Fields.fst.checked", "Hacl.Impl.Poly1305.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.Poly1305.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Poly1305.Fields", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": "F32xN" }, { "abbrev": true, "full_module": "Hacl.Impl.Poly1305", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Streaming.Interface", "short_module": "I" }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
input: FStar.Seq.Base.seq Hacl.Streaming.Poly1305.uint8 -> acc: Spec.Poly1305.felem -> r: Spec.Poly1305.felem -> FStar.Pervasives.Lemma (requires FStar.Seq.Base.length input % Spec.Poly1305.size_block = 0) (ensures Hacl.Streaming.Poly1305.update_multi (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Hacl.Streaming.Poly1305.uint8", "Spec.Poly1305.felem", "FStar.Calc.calc_finish", "FStar.Pervasives.Native.tuple2", "Prims.eq2", "Hacl.Streaming.Poly1305.update_multi", "FStar.Pervasives.Native.Mktuple2", "Lib.Sequence.repeat_blocks", "Lib.UpdateMulti.Lemmas.uint8", "Spec.Poly1305.poly1305_update1", "Spec.Poly1305.size_block", "Spec.Poly1305.poly1305_update_last", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "Lib.UpdateMulti.Lemmas.repeat_f", "Hacl.Streaming.Poly1305.update'", "Lib.UpdateMulti.Lemmas.repeat_l", "Hacl.Streaming.Poly1305.update_last'", "Hacl.Streaming.Poly1305.update_multi'", "FStar.Seq.Base.empty", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Hacl.Streaming.Poly1305.with_or_without_r", "Prims.squash", "Lib.UpdateMulti.Lemmas.update_full_is_repeat_blocks", "Lib.Sequence.Lemmas.repeat_blocks_extensionality", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.nat", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction" ]
[]
false
false
true
false
false
let update_multi_is_update input acc r =
let open Lib.UpdateMulti.Lemmas in let block_length = Spec.Poly1305.size_block in assert_norm (block_length < pow2 32); calc ( == ) { update_multi (acc, r) input; ( == ) { with_or_without_r acc r input } update_multi' r acc input, r; ( == ) { () } update_last' r (update_multi' r acc input) S.empty, r; ( == ) { update_full_is_repeat_blocks block_length (update' r) (update_last' r) acc input input } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input (repeat_f block_length (update' r)) (repeat_l block_length (update_last' r) input) acc, r; ( == ) { Lib.Sequence.Lemmas.repeat_blocks_extensionality block_length input (repeat_f block_length (update' r)) Spec.Poly1305.(poly1305_update1 r size_block) (repeat_l block_length (update_last' r) input) Spec.Poly1305.(poly1305_update_last r) acc } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input Spec.Poly1305.(poly1305_update1 r size_block) Spec.Poly1305.(poly1305_update_last r) acc, r; }
false
Hacl.Streaming.Poly1305.fst
Hacl.Streaming.Poly1305.poly_is_incremental
val poly_is_incremental: key: S.seq uint8 { S.length key = 32 } -> input:S.seq uint8 { S.length input <= pow2 32 - 1 } -> Lemma (ensures ( let hash = Lib.UpdateMulti.update_full Spec.Poly1305.size_block update_ update_last (Spec.Poly1305.poly1305_init key) input in finish_ key hash `S.equal` spec key input))
val poly_is_incremental: key: S.seq uint8 { S.length key = 32 } -> input:S.seq uint8 { S.length input <= pow2 32 - 1 } -> Lemma (ensures ( let hash = Lib.UpdateMulti.update_full Spec.Poly1305.size_block update_ update_last (Spec.Poly1305.poly1305_init key) input in finish_ key hash `S.equal` spec key input))
let poly_is_incremental key input = let open Lib.UpdateMulti.Lemmas in let block_length = Spec.Poly1305.size_block in assert_norm (block_length < pow2 32); let n = S.length input / block_length in let bs, l = S.split input (n * block_length) in FStar.Math.Lemmas.multiple_modulo_lemma n block_length; let acc, r = Spec.Poly1305.poly1305_init key in calc (S.equal) { finish_ key (update_last (update_multi (acc, r) bs) l); (S.equal) { with_or_without_r acc r bs } Spec.Poly1305.poly1305_finish key (update_last' r (update_multi' r acc bs) l); (S.equal) { update_full_is_repeat_blocks block_length (update' r) (update_last' r) acc input input } Spec.Poly1305.poly1305_finish key (Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input (repeat_f block_length (update' r)) (repeat_l block_length (update_last' r) input) acc); (S.equal) { Lib.Sequence.Lemmas.repeat_blocks_extensionality block_length input (repeat_f block_length (update' r)) Spec.Poly1305.(poly1305_update1 r size_block) (repeat_l block_length (update_last' r) input) Spec.Poly1305.(poly1305_update_last r) acc } Spec.Poly1305.poly1305_finish key (Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input Spec.Poly1305.(poly1305_update1 r size_block) Spec.Poly1305.(poly1305_update_last r) acc); }
{ "file_name": "code/streaming/Hacl.Streaming.Poly1305.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 356, "start_col": 0, "start_line": 327 }
module Hacl.Streaming.Poly1305 module HS = FStar.HyperStack module B = LowStar.Buffer module G = FStar.Ghost module S = FStar.Seq module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module I = Hacl.Streaming.Interface module P = Hacl.Impl.Poly1305 module F32xN = Hacl.Spec.Poly1305.Field32xN module ST = FStar.HyperStack.ST open LowStar.BufferOps open FStar.Mul /// Opening a bunch of modules for Poly1305 /// ======================================= inline_for_extraction noextract let uint8 = Lib.IntTypes.uint8 inline_for_extraction noextract let uint32 = Lib.IntTypes.uint32 open Hacl.Impl.Poly1305.Fields /// An instance of the stateful type class for poly1305 state /// ========================================================= /// /// We use a custom view that separates r and acc, to respect abstraction boundaries established by Poly1305. #set-options "--fuel 0 --ifuel 1 --z3rlimit 100" inline_for_extraction noextract let t (fs : field_spec) = b:B.buffer (limb fs) { B.length b == 25 } inline_for_extraction noextract let as_raw (#fs : field_spec) (x: t fs): B.buffer (limb fs) = x inline_for_extraction noextract let as_lib (#fs : field_spec) (x: t fs): P.poly1305_ctx fs = assert (Lib.IntTypes.(v (add #U32 (nlimb fs) (precomplen fs))) == 25); x inline_for_extraction noextract let poly1305_key = I.stateful_buffer uint8 32ul (Lib.IntTypes.u8 0) unit inline_for_extraction noextract let as_lib_k (x: B.buffer uint8 { B.length x = 32 }): Lib.Buffer.lbuffer uint8 32ul = x inline_for_extraction noextract let num_lanes (fs : field_spec) : F32xN.lanes = match fs with | M32 -> 1 | M128 -> 2 | M256 -> 4 inline_for_extraction noextract let stateful_poly1305_ctx (fs : field_spec) : I.stateful unit = I.Stateful (fun () -> t fs) (fun #_ _ s -> B.loc_addr_of_buffer (as_raw s)) (fun #_ _ s -> B.freeable (as_raw s)) (fun #_ h s -> B.live h (as_raw s) /\ P.state_inv_t h (as_lib s)) (fun () -> Spec.Poly1305.felem & Spec.Poly1305.felem) (fun () h s -> P.as_get_acc h (as_lib s), P.as_get_r h (as_lib s)) (fun #_ _ _ -> ()) (fun #_ l s h0 h1 -> P.reveal_ctx_inv (as_lib s) h0 h1; B.modifies_buffer_elim (as_raw s) l h0 h1) (fun #_ _ _ _ _ -> ()) (fun () -> [@inline_let] let n = num_lanes fs in let r = B.alloca (F32xN.zero n) 25ul in let h1 = ST.get () in P.ctx_inv_zeros #fs r h1; r) (fun () r -> [@inline_let] let n = num_lanes fs in let r = B.malloc r (F32xN.zero n) 25ul in let h1 = ST.get () in P.ctx_inv_zeros #fs r h1; r) (fun _ s -> B.free s) (fun _ src dst -> let h0 = ST.get () in B.blit src 0ul dst 0ul 25ul; let h1 = ST.get () in P.reveal_ctx_inv' (as_lib src) (as_lib dst) h0 h1) /// Interlude for spec equivalence proofs /// ===================================== /// /// A quick explanation about this proof of equivalence. At the spec level, /// ``poly1305_update`` needs both ``r`` and the accumulator ``acc``. This thus /// makes poly1305 update a function of two arguments. However, the streaming /// facility is constructed over specifications that take one single argument. /// Not a problem! We carry the pair ``(r, acc)`` as our "streaming functor /// accumulator", and we now have to show that a specification in terms of /// ``update (update (r, acc) init)`` is the same as poly1305. For that, we need /// to do a little proof of equivalence to show first that this is the same as /// ``(update r) ((update r) acc)`` (note that the update function now becomes a /// partial application), then use the update-multi-repeat conversion lemma to /// get the original specification of poly1305. inline_for_extraction noextract let block = (block: S.seq uint8 { S.length block = Spec.Poly1305.size_block }) inline_for_extraction noextract let update_ (acc, r) (block: block) = Spec.Poly1305.poly1305_update1 r Spec.Poly1305.size_block block acc, r /// Same as [update_], but with the input not necessarily a full block (can be smaller) inline_for_extraction noextract let update__ (acc, r) (input: S.seq uint8{S.length input <= Spec.Poly1305.size_block}) = Spec.Poly1305.poly1305_update1 r (S.length input) input acc, r inline_for_extraction noextract let update' r acc (block: block) = Spec.Poly1305.poly1305_update1 r Spec.Poly1305.size_block block acc inline_for_extraction noextract let update_multi = Lib.UpdateMulti.mk_update_multi Spec.Poly1305.size_block update_ inline_for_extraction noextract let update_multi' r = Lib.UpdateMulti.mk_update_multi Spec.Poly1305.size_block (update' r) #push-options "--fuel 1" inline_for_extraction noextract let rec with_or_without_r (acc r: Spec.Poly1305.felem) (blocks: S.seq uint8): Lemma (requires S.length blocks % Spec.Poly1305.size_block = 0) (ensures update_multi (acc, r) blocks == (update_multi' r acc blocks, r)) (decreases (S.length blocks)) = if S.length blocks = 0 then () else let block, rem = Lib.UpdateMulti.split_block Spec.Poly1305.size_block blocks 1 in let acc = update' r acc block in with_or_without_r acc r rem #pop-options inline_for_extraction noextract let update_last (acc, r) (input: S.seq uint8 { S.length input <= Spec.Poly1305.size_block }) = if S.length input = 0 then acc, r else Spec.Poly1305.poly1305_update1 r (S.length input) input acc, r inline_for_extraction noextract let update_last' r acc (input: S.seq uint8 { S.length input <= Spec.Poly1305.size_block }) = if S.length input = 0 then acc else Spec.Poly1305.poly1305_update1 r (S.length input) input acc inline_for_extraction noextract let finish_ k (acc, r) = Spec.Poly1305.poly1305_finish k acc inline_for_extraction noextract let spec k input = Spec.Poly1305.poly1305_mac input k val update_last_not_block_is_update (input: S.seq uint8) (acc: Spec.Poly1305.felem) (r: Spec.Poly1305.felem): Lemma (requires (S.length input < Spec.Poly1305.size_block)) (ensures (update_last (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r))) let update_last_not_block_is_update input acc r = let open Lib.UpdateMulti.Lemmas in let block_length = Spec.Poly1305.size_block in assert_norm (block_length < pow2 32); calc (==) { update_last (acc, r) input; (==) { } update_last' r acc input, r; (==) { Lib.UpdateMulti.update_multi_zero Spec.Poly1305.size_block (update' r) acc } update_last' r (update_multi' r acc S.empty) input, r; (==) { update_full_is_repeat_blocks block_length (update' r) (update_last' r) acc input input } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input (repeat_f block_length (update' r)) (repeat_l block_length (update_last' r) input) acc, r; (==) { Lib.Sequence.Lemmas.repeat_blocks_extensionality block_length input (repeat_f block_length (update' r)) Spec.Poly1305.(poly1305_update1 r size_block) (repeat_l block_length (update_last' r) input) Spec.Poly1305.(poly1305_update_last r) acc } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input Spec.Poly1305.(poly1305_update1 r size_block) Spec.Poly1305.(poly1305_update_last r) acc, r; } val update_last_block_is_update (input: S.seq uint8) (acc: Spec.Poly1305.felem) (r: Spec.Poly1305.felem): Lemma (requires (S.length input = Spec.Poly1305.size_block)) (ensures (update_last (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r))) open FStar.Tactics #push-options "--fuel 1 --print_implicits" let update_last_block_is_update input acc r = let open Lib.UpdateMulti.Lemmas in let block_length = Spec.Poly1305.size_block in assert_norm (block_length < pow2 32); assert(input `S.equal` S.append input S.empty); let acc1 = update' r acc input in let acc1' = update_multi' r acc input in // SH: fun fact: this lemma call and the following assert should be the // last part of the below calc. However, if put below/inside the calc, // the proof loops. Lib.Sequence.Lemmas.repeat_blocks_extensionality block_length input (repeat_f block_length (update' r)) Spec.Poly1305.(poly1305_update1 r size_block) (repeat_l block_length (update_last' r) input) Spec.Poly1305.(poly1305_update_last r) acc; assert( Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input (repeat_f block_length (update' r)) (repeat_l block_length (update_last' r) input) acc == Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input Spec.Poly1305.(poly1305_update1 r size_block) Spec.Poly1305.(poly1305_update_last r) acc); assert( let block, rem = Lib.UpdateMulti.split_block block_length input 1 in block `S.equal` input /\ rem `S.equal` S.empty); assert( Lib.UpdateMulti.mk_update_multi block_length (update' r) acc1 S.empty == acc1'); assert(acc1 == acc1'); calc (==) { update_last (acc, r) input; (==) { } update_last' r acc input, r; (==) { } update_last' r (update' r acc input) S.empty, r; (==) { } update_last' r (update_multi' r acc input) S.empty, r; (==) { update_full_is_repeat_blocks block_length (update' r) (update_last' r) acc input input } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input (repeat_f block_length (update' r)) (repeat_l block_length (update_last' r) input) acc, r; } #pop-options val update_last_is_update (input: S.seq uint8) (acc: Spec.Poly1305.felem) (r: Spec.Poly1305.felem): Lemma (requires (S.length input <= Spec.Poly1305.size_block)) (ensures (update_last (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r))) let update_last_is_update input acc r = if S.length input = Spec.Poly1305.size_block then update_last_block_is_update input acc r else update_last_not_block_is_update input acc r val update_multi_is_update (input: S.seq uint8) (acc: Spec.Poly1305.felem) (r: Spec.Poly1305.felem): Lemma (requires (S.length input % Spec.Poly1305.size_block = 0)) (ensures (update_multi (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r))) let update_multi_is_update input acc r = let open Lib.UpdateMulti.Lemmas in let block_length = Spec.Poly1305.size_block in assert_norm (block_length < pow2 32); calc (==) { update_multi (acc, r) input; (==) { with_or_without_r acc r input } update_multi' r acc input, r; (==) { } update_last' r (update_multi' r acc input) S.empty, r; (==) { update_full_is_repeat_blocks block_length (update' r) (update_last' r) acc input input } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input (repeat_f block_length (update' r)) (repeat_l block_length (update_last' r) input) acc, r; (==) { Lib.Sequence.Lemmas.repeat_blocks_extensionality block_length input (repeat_f block_length (update' r)) Spec.Poly1305.(poly1305_update1 r size_block) (repeat_l block_length (update_last' r) input) Spec.Poly1305.(poly1305_update_last r) acc } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input Spec.Poly1305.(poly1305_update1 r size_block) Spec.Poly1305.(poly1305_update_last r) acc, r; } val poly_is_incremental: key: S.seq uint8 { S.length key = 32 } -> input:S.seq uint8 { S.length input <= pow2 32 - 1 } -> Lemma (ensures ( let hash = Lib.UpdateMulti.update_full Spec.Poly1305.size_block update_ update_last (Spec.Poly1305.poly1305_init key) input in finish_ key hash `S.equal` spec key input))
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.UpdateMulti.Lemmas.fsti.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "Hacl.Poly1305_32.fsti.checked", "Hacl.Poly1305_256.fsti.checked", "Hacl.Poly1305_128.fsti.checked", "Hacl.Impl.Poly1305.Fields.fst.checked", "Hacl.Impl.Poly1305.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.Poly1305.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Poly1305.Fields", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": "F32xN" }, { "abbrev": true, "full_module": "Hacl.Impl.Poly1305", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Streaming.Interface", "short_module": "I" }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
key: FStar.Seq.Base.seq Hacl.Streaming.Poly1305.uint8 {FStar.Seq.Base.length key = 32} -> input: FStar.Seq.Base.seq Hacl.Streaming.Poly1305.uint8 {FStar.Seq.Base.length input <= Prims.pow2 32 - 1} -> FStar.Pervasives.Lemma (ensures (let hash = Lib.UpdateMulti.update_full Spec.Poly1305.size_block Hacl.Streaming.Poly1305.update_ Hacl.Streaming.Poly1305.update_last (Spec.Poly1305.poly1305_init key) input in FStar.Seq.Base.equal (Hacl.Streaming.Poly1305.finish_ key hash) (Hacl.Streaming.Poly1305.spec key input)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Hacl.Streaming.Poly1305.uint8", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Seq.Base.length", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "Spec.Poly1305.felem", "FStar.Calc.calc_finish", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "FStar.Seq.Base.equal", "Hacl.Streaming.Poly1305.finish_", "Hacl.Streaming.Poly1305.update_last", "Hacl.Streaming.Poly1305.update_multi", "FStar.Pervasives.Native.Mktuple2", "Spec.Poly1305.poly1305_finish", "Lib.Sequence.repeat_blocks", "Lib.UpdateMulti.Lemmas.uint8", "Spec.Poly1305.poly1305_update1", "Spec.Poly1305.size_block", "Spec.Poly1305.poly1305_update_last", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "Lib.UpdateMulti.Lemmas.repeat_f", "Hacl.Streaming.Poly1305.update'", "Lib.UpdateMulti.Lemmas.repeat_l", "Hacl.Streaming.Poly1305.update_last'", "Hacl.Streaming.Poly1305.update_multi'", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Hacl.Streaming.Poly1305.with_or_without_r", "Prims.squash", "Lib.UpdateMulti.Lemmas.update_full_is_repeat_blocks", "Lib.Sequence.Lemmas.repeat_blocks_extensionality", "FStar.Pervasives.Native.tuple2", "Spec.Poly1305.poly1305_init", "FStar.Math.Lemmas.multiple_modulo_lemma", "FStar.Seq.Properties.split", "FStar.Mul.op_Star", "Prims.op_Division", "FStar.Pervasives.assert_norm", "Prims.op_LessThan", "Prims.nat" ]
[]
false
false
true
false
false
let poly_is_incremental key input =
let open Lib.UpdateMulti.Lemmas in let block_length = Spec.Poly1305.size_block in assert_norm (block_length < pow2 32); let n = S.length input / block_length in let bs, l = S.split input (n * block_length) in FStar.Math.Lemmas.multiple_modulo_lemma n block_length; let acc, r = Spec.Poly1305.poly1305_init key in calc (S.equal) { finish_ key (update_last (update_multi (acc, r) bs) l); (S.equal) { with_or_without_r acc r bs } Spec.Poly1305.poly1305_finish key (update_last' r (update_multi' r acc bs) l); (S.equal) { update_full_is_repeat_blocks block_length (update' r) (update_last' r) acc input input } Spec.Poly1305.poly1305_finish key (Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input (repeat_f block_length (update' r)) (repeat_l block_length (update_last' r) input) acc); (S.equal) { Lib.Sequence.Lemmas.repeat_blocks_extensionality block_length input (repeat_f block_length (update' r)) Spec.Poly1305.(poly1305_update1 r size_block) (repeat_l block_length (update_last' r) input) Spec.Poly1305.(poly1305_update_last r) acc } Spec.Poly1305.poly1305_finish key (Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input Spec.Poly1305.(poly1305_update1 r size_block) Spec.Poly1305.(poly1305_update_last r) acc); }
false
Hacl.Streaming.Poly1305.fst
Hacl.Streaming.Poly1305.update_last_block_is_update
val update_last_block_is_update (input: S.seq uint8) (acc: Spec.Poly1305.felem) (r: Spec.Poly1305.felem): Lemma (requires (S.length input = Spec.Poly1305.size_block)) (ensures (update_last (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r)))
val update_last_block_is_update (input: S.seq uint8) (acc: Spec.Poly1305.felem) (r: Spec.Poly1305.felem): Lemma (requires (S.length input = Spec.Poly1305.size_block)) (ensures (update_last (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r)))
let update_last_block_is_update input acc r = let open Lib.UpdateMulti.Lemmas in let block_length = Spec.Poly1305.size_block in assert_norm (block_length < pow2 32); assert(input `S.equal` S.append input S.empty); let acc1 = update' r acc input in let acc1' = update_multi' r acc input in // SH: fun fact: this lemma call and the following assert should be the // last part of the below calc. However, if put below/inside the calc, // the proof loops. Lib.Sequence.Lemmas.repeat_blocks_extensionality block_length input (repeat_f block_length (update' r)) Spec.Poly1305.(poly1305_update1 r size_block) (repeat_l block_length (update_last' r) input) Spec.Poly1305.(poly1305_update_last r) acc; assert( Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input (repeat_f block_length (update' r)) (repeat_l block_length (update_last' r) input) acc == Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input Spec.Poly1305.(poly1305_update1 r size_block) Spec.Poly1305.(poly1305_update_last r) acc); assert( let block, rem = Lib.UpdateMulti.split_block block_length input 1 in block `S.equal` input /\ rem `S.equal` S.empty); assert( Lib.UpdateMulti.mk_update_multi block_length (update' r) acc1 S.empty == acc1'); assert(acc1 == acc1'); calc (==) { update_last (acc, r) input; (==) { } update_last' r acc input, r; (==) { } update_last' r (update' r acc input) S.empty, r; (==) { } update_last' r (update_multi' r acc input) S.empty, r; (==) { update_full_is_repeat_blocks block_length (update' r) (update_last' r) acc input input } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input (repeat_f block_length (update' r)) (repeat_l block_length (update_last' r) input) acc, r; }
{ "file_name": "code/streaming/Hacl.Streaming.Poly1305.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 268, "start_col": 0, "start_line": 223 }
module Hacl.Streaming.Poly1305 module HS = FStar.HyperStack module B = LowStar.Buffer module G = FStar.Ghost module S = FStar.Seq module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module I = Hacl.Streaming.Interface module P = Hacl.Impl.Poly1305 module F32xN = Hacl.Spec.Poly1305.Field32xN module ST = FStar.HyperStack.ST open LowStar.BufferOps open FStar.Mul /// Opening a bunch of modules for Poly1305 /// ======================================= inline_for_extraction noextract let uint8 = Lib.IntTypes.uint8 inline_for_extraction noextract let uint32 = Lib.IntTypes.uint32 open Hacl.Impl.Poly1305.Fields /// An instance of the stateful type class for poly1305 state /// ========================================================= /// /// We use a custom view that separates r and acc, to respect abstraction boundaries established by Poly1305. #set-options "--fuel 0 --ifuel 1 --z3rlimit 100" inline_for_extraction noextract let t (fs : field_spec) = b:B.buffer (limb fs) { B.length b == 25 } inline_for_extraction noextract let as_raw (#fs : field_spec) (x: t fs): B.buffer (limb fs) = x inline_for_extraction noextract let as_lib (#fs : field_spec) (x: t fs): P.poly1305_ctx fs = assert (Lib.IntTypes.(v (add #U32 (nlimb fs) (precomplen fs))) == 25); x inline_for_extraction noextract let poly1305_key = I.stateful_buffer uint8 32ul (Lib.IntTypes.u8 0) unit inline_for_extraction noextract let as_lib_k (x: B.buffer uint8 { B.length x = 32 }): Lib.Buffer.lbuffer uint8 32ul = x inline_for_extraction noextract let num_lanes (fs : field_spec) : F32xN.lanes = match fs with | M32 -> 1 | M128 -> 2 | M256 -> 4 inline_for_extraction noextract let stateful_poly1305_ctx (fs : field_spec) : I.stateful unit = I.Stateful (fun () -> t fs) (fun #_ _ s -> B.loc_addr_of_buffer (as_raw s)) (fun #_ _ s -> B.freeable (as_raw s)) (fun #_ h s -> B.live h (as_raw s) /\ P.state_inv_t h (as_lib s)) (fun () -> Spec.Poly1305.felem & Spec.Poly1305.felem) (fun () h s -> P.as_get_acc h (as_lib s), P.as_get_r h (as_lib s)) (fun #_ _ _ -> ()) (fun #_ l s h0 h1 -> P.reveal_ctx_inv (as_lib s) h0 h1; B.modifies_buffer_elim (as_raw s) l h0 h1) (fun #_ _ _ _ _ -> ()) (fun () -> [@inline_let] let n = num_lanes fs in let r = B.alloca (F32xN.zero n) 25ul in let h1 = ST.get () in P.ctx_inv_zeros #fs r h1; r) (fun () r -> [@inline_let] let n = num_lanes fs in let r = B.malloc r (F32xN.zero n) 25ul in let h1 = ST.get () in P.ctx_inv_zeros #fs r h1; r) (fun _ s -> B.free s) (fun _ src dst -> let h0 = ST.get () in B.blit src 0ul dst 0ul 25ul; let h1 = ST.get () in P.reveal_ctx_inv' (as_lib src) (as_lib dst) h0 h1) /// Interlude for spec equivalence proofs /// ===================================== /// /// A quick explanation about this proof of equivalence. At the spec level, /// ``poly1305_update`` needs both ``r`` and the accumulator ``acc``. This thus /// makes poly1305 update a function of two arguments. However, the streaming /// facility is constructed over specifications that take one single argument. /// Not a problem! We carry the pair ``(r, acc)`` as our "streaming functor /// accumulator", and we now have to show that a specification in terms of /// ``update (update (r, acc) init)`` is the same as poly1305. For that, we need /// to do a little proof of equivalence to show first that this is the same as /// ``(update r) ((update r) acc)`` (note that the update function now becomes a /// partial application), then use the update-multi-repeat conversion lemma to /// get the original specification of poly1305. inline_for_extraction noextract let block = (block: S.seq uint8 { S.length block = Spec.Poly1305.size_block }) inline_for_extraction noextract let update_ (acc, r) (block: block) = Spec.Poly1305.poly1305_update1 r Spec.Poly1305.size_block block acc, r /// Same as [update_], but with the input not necessarily a full block (can be smaller) inline_for_extraction noextract let update__ (acc, r) (input: S.seq uint8{S.length input <= Spec.Poly1305.size_block}) = Spec.Poly1305.poly1305_update1 r (S.length input) input acc, r inline_for_extraction noextract let update' r acc (block: block) = Spec.Poly1305.poly1305_update1 r Spec.Poly1305.size_block block acc inline_for_extraction noextract let update_multi = Lib.UpdateMulti.mk_update_multi Spec.Poly1305.size_block update_ inline_for_extraction noextract let update_multi' r = Lib.UpdateMulti.mk_update_multi Spec.Poly1305.size_block (update' r) #push-options "--fuel 1" inline_for_extraction noextract let rec with_or_without_r (acc r: Spec.Poly1305.felem) (blocks: S.seq uint8): Lemma (requires S.length blocks % Spec.Poly1305.size_block = 0) (ensures update_multi (acc, r) blocks == (update_multi' r acc blocks, r)) (decreases (S.length blocks)) = if S.length blocks = 0 then () else let block, rem = Lib.UpdateMulti.split_block Spec.Poly1305.size_block blocks 1 in let acc = update' r acc block in with_or_without_r acc r rem #pop-options inline_for_extraction noextract let update_last (acc, r) (input: S.seq uint8 { S.length input <= Spec.Poly1305.size_block }) = if S.length input = 0 then acc, r else Spec.Poly1305.poly1305_update1 r (S.length input) input acc, r inline_for_extraction noextract let update_last' r acc (input: S.seq uint8 { S.length input <= Spec.Poly1305.size_block }) = if S.length input = 0 then acc else Spec.Poly1305.poly1305_update1 r (S.length input) input acc inline_for_extraction noextract let finish_ k (acc, r) = Spec.Poly1305.poly1305_finish k acc inline_for_extraction noextract let spec k input = Spec.Poly1305.poly1305_mac input k val update_last_not_block_is_update (input: S.seq uint8) (acc: Spec.Poly1305.felem) (r: Spec.Poly1305.felem): Lemma (requires (S.length input < Spec.Poly1305.size_block)) (ensures (update_last (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r))) let update_last_not_block_is_update input acc r = let open Lib.UpdateMulti.Lemmas in let block_length = Spec.Poly1305.size_block in assert_norm (block_length < pow2 32); calc (==) { update_last (acc, r) input; (==) { } update_last' r acc input, r; (==) { Lib.UpdateMulti.update_multi_zero Spec.Poly1305.size_block (update' r) acc } update_last' r (update_multi' r acc S.empty) input, r; (==) { update_full_is_repeat_blocks block_length (update' r) (update_last' r) acc input input } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input (repeat_f block_length (update' r)) (repeat_l block_length (update_last' r) input) acc, r; (==) { Lib.Sequence.Lemmas.repeat_blocks_extensionality block_length input (repeat_f block_length (update' r)) Spec.Poly1305.(poly1305_update1 r size_block) (repeat_l block_length (update_last' r) input) Spec.Poly1305.(poly1305_update_last r) acc } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input Spec.Poly1305.(poly1305_update1 r size_block) Spec.Poly1305.(poly1305_update_last r) acc, r; } val update_last_block_is_update (input: S.seq uint8) (acc: Spec.Poly1305.felem) (r: Spec.Poly1305.felem): Lemma (requires (S.length input = Spec.Poly1305.size_block)) (ensures (update_last (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r))) open FStar.Tactics
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.UpdateMulti.Lemmas.fsti.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "Hacl.Poly1305_32.fsti.checked", "Hacl.Poly1305_256.fsti.checked", "Hacl.Poly1305_128.fsti.checked", "Hacl.Impl.Poly1305.Fields.fst.checked", "Hacl.Impl.Poly1305.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.Poly1305.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Poly1305.Fields", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": "F32xN" }, { "abbrev": true, "full_module": "Hacl.Impl.Poly1305", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Streaming.Interface", "short_module": "I" }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
input: FStar.Seq.Base.seq Hacl.Streaming.Poly1305.uint8 -> acc: Spec.Poly1305.felem -> r: Spec.Poly1305.felem -> FStar.Pervasives.Lemma (requires FStar.Seq.Base.length input = Spec.Poly1305.size_block) (ensures Hacl.Streaming.Poly1305.update_last (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Hacl.Streaming.Poly1305.uint8", "Spec.Poly1305.felem", "FStar.Calc.calc_finish", "FStar.Pervasives.Native.tuple2", "Prims.eq2", "Hacl.Streaming.Poly1305.update_last", "FStar.Pervasives.Native.Mktuple2", "Lib.Sequence.repeat_blocks", "Lib.UpdateMulti.Lemmas.uint8", "Lib.UpdateMulti.Lemmas.repeat_f", "Hacl.Streaming.Poly1305.update'", "Lib.UpdateMulti.Lemmas.repeat_l", "Hacl.Streaming.Poly1305.update_last'", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "Hacl.Streaming.Poly1305.update_multi'", "FStar.Seq.Base.empty", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.squash", "Lib.UpdateMulti.Lemmas.update_full_is_repeat_blocks", "Prims._assert", "Lib.UpdateMulti.mk_update_multi", "Lib.UpdateMulti.uint8", "Prims.l_and", "FStar.Seq.Base.equal", "Lib.UpdateMulti.split_block", "Spec.Poly1305.poly1305_update1", "Spec.Poly1305.size_block", "Spec.Poly1305.poly1305_update_last", "Lib.Sequence.Lemmas.repeat_blocks_extensionality", "FStar.Seq.Base.append", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.nat", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction" ]
[]
false
false
true
false
false
let update_last_block_is_update input acc r =
let open Lib.UpdateMulti.Lemmas in let block_length = Spec.Poly1305.size_block in assert_norm (block_length < pow2 32); assert (input `S.equal` (S.append input S.empty)); let acc1 = update' r acc input in let acc1' = update_multi' r acc input in Lib.Sequence.Lemmas.repeat_blocks_extensionality block_length input (repeat_f block_length (update' r)) Spec.Poly1305.(poly1305_update1 r size_block) (repeat_l block_length (update_last' r) input) Spec.Poly1305.(poly1305_update_last r) acc; assert (Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input (repeat_f block_length (update' r)) (repeat_l block_length (update_last' r) input) acc == Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input Spec.Poly1305.(poly1305_update1 r size_block) Spec.Poly1305.(poly1305_update_last r) acc); assert (let block, rem = Lib.UpdateMulti.split_block block_length input 1 in block `S.equal` input /\ rem `S.equal` S.empty); assert (Lib.UpdateMulti.mk_update_multi block_length (update' r) acc1 S.empty == acc1'); assert (acc1 == acc1'); calc ( == ) { update_last (acc, r) input; ( == ) { () } update_last' r acc input, r; ( == ) { () } update_last' r (update' r acc input) S.empty, r; ( == ) { () } update_last' r (update_multi' r acc input) S.empty, r; ( == ) { update_full_is_repeat_blocks block_length (update' r) (update_last' r) acc input input } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input (repeat_f block_length (update' r)) (repeat_l block_length (update_last' r) input) acc, r; }
false
Hacl.Streaming.Poly1305.fst
Hacl.Streaming.Poly1305.update_last_not_block_is_update
val update_last_not_block_is_update (input: S.seq uint8) (acc: Spec.Poly1305.felem) (r: Spec.Poly1305.felem): Lemma (requires (S.length input < Spec.Poly1305.size_block)) (ensures (update_last (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r)))
val update_last_not_block_is_update (input: S.seq uint8) (acc: Spec.Poly1305.felem) (r: Spec.Poly1305.felem): Lemma (requires (S.length input < Spec.Poly1305.size_block)) (ensures (update_last (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r)))
let update_last_not_block_is_update input acc r = let open Lib.UpdateMulti.Lemmas in let block_length = Spec.Poly1305.size_block in assert_norm (block_length < pow2 32); calc (==) { update_last (acc, r) input; (==) { } update_last' r acc input, r; (==) { Lib.UpdateMulti.update_multi_zero Spec.Poly1305.size_block (update' r) acc } update_last' r (update_multi' r acc S.empty) input, r; (==) { update_full_is_repeat_blocks block_length (update' r) (update_last' r) acc input input } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input (repeat_f block_length (update' r)) (repeat_l block_length (update_last' r) input) acc, r; (==) { Lib.Sequence.Lemmas.repeat_blocks_extensionality block_length input (repeat_f block_length (update' r)) Spec.Poly1305.(poly1305_update1 r size_block) (repeat_l block_length (update_last' r) input) Spec.Poly1305.(poly1305_update_last r) acc } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input Spec.Poly1305.(poly1305_update1 r size_block) Spec.Poly1305.(poly1305_update_last r) acc, r; }
{ "file_name": "code/streaming/Hacl.Streaming.Poly1305.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 210, "start_col": 0, "start_line": 184 }
module Hacl.Streaming.Poly1305 module HS = FStar.HyperStack module B = LowStar.Buffer module G = FStar.Ghost module S = FStar.Seq module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module I = Hacl.Streaming.Interface module P = Hacl.Impl.Poly1305 module F32xN = Hacl.Spec.Poly1305.Field32xN module ST = FStar.HyperStack.ST open LowStar.BufferOps open FStar.Mul /// Opening a bunch of modules for Poly1305 /// ======================================= inline_for_extraction noextract let uint8 = Lib.IntTypes.uint8 inline_for_extraction noextract let uint32 = Lib.IntTypes.uint32 open Hacl.Impl.Poly1305.Fields /// An instance of the stateful type class for poly1305 state /// ========================================================= /// /// We use a custom view that separates r and acc, to respect abstraction boundaries established by Poly1305. #set-options "--fuel 0 --ifuel 1 --z3rlimit 100" inline_for_extraction noextract let t (fs : field_spec) = b:B.buffer (limb fs) { B.length b == 25 } inline_for_extraction noextract let as_raw (#fs : field_spec) (x: t fs): B.buffer (limb fs) = x inline_for_extraction noextract let as_lib (#fs : field_spec) (x: t fs): P.poly1305_ctx fs = assert (Lib.IntTypes.(v (add #U32 (nlimb fs) (precomplen fs))) == 25); x inline_for_extraction noextract let poly1305_key = I.stateful_buffer uint8 32ul (Lib.IntTypes.u8 0) unit inline_for_extraction noextract let as_lib_k (x: B.buffer uint8 { B.length x = 32 }): Lib.Buffer.lbuffer uint8 32ul = x inline_for_extraction noextract let num_lanes (fs : field_spec) : F32xN.lanes = match fs with | M32 -> 1 | M128 -> 2 | M256 -> 4 inline_for_extraction noextract let stateful_poly1305_ctx (fs : field_spec) : I.stateful unit = I.Stateful (fun () -> t fs) (fun #_ _ s -> B.loc_addr_of_buffer (as_raw s)) (fun #_ _ s -> B.freeable (as_raw s)) (fun #_ h s -> B.live h (as_raw s) /\ P.state_inv_t h (as_lib s)) (fun () -> Spec.Poly1305.felem & Spec.Poly1305.felem) (fun () h s -> P.as_get_acc h (as_lib s), P.as_get_r h (as_lib s)) (fun #_ _ _ -> ()) (fun #_ l s h0 h1 -> P.reveal_ctx_inv (as_lib s) h0 h1; B.modifies_buffer_elim (as_raw s) l h0 h1) (fun #_ _ _ _ _ -> ()) (fun () -> [@inline_let] let n = num_lanes fs in let r = B.alloca (F32xN.zero n) 25ul in let h1 = ST.get () in P.ctx_inv_zeros #fs r h1; r) (fun () r -> [@inline_let] let n = num_lanes fs in let r = B.malloc r (F32xN.zero n) 25ul in let h1 = ST.get () in P.ctx_inv_zeros #fs r h1; r) (fun _ s -> B.free s) (fun _ src dst -> let h0 = ST.get () in B.blit src 0ul dst 0ul 25ul; let h1 = ST.get () in P.reveal_ctx_inv' (as_lib src) (as_lib dst) h0 h1) /// Interlude for spec equivalence proofs /// ===================================== /// /// A quick explanation about this proof of equivalence. At the spec level, /// ``poly1305_update`` needs both ``r`` and the accumulator ``acc``. This thus /// makes poly1305 update a function of two arguments. However, the streaming /// facility is constructed over specifications that take one single argument. /// Not a problem! We carry the pair ``(r, acc)`` as our "streaming functor /// accumulator", and we now have to show that a specification in terms of /// ``update (update (r, acc) init)`` is the same as poly1305. For that, we need /// to do a little proof of equivalence to show first that this is the same as /// ``(update r) ((update r) acc)`` (note that the update function now becomes a /// partial application), then use the update-multi-repeat conversion lemma to /// get the original specification of poly1305. inline_for_extraction noextract let block = (block: S.seq uint8 { S.length block = Spec.Poly1305.size_block }) inline_for_extraction noextract let update_ (acc, r) (block: block) = Spec.Poly1305.poly1305_update1 r Spec.Poly1305.size_block block acc, r /// Same as [update_], but with the input not necessarily a full block (can be smaller) inline_for_extraction noextract let update__ (acc, r) (input: S.seq uint8{S.length input <= Spec.Poly1305.size_block}) = Spec.Poly1305.poly1305_update1 r (S.length input) input acc, r inline_for_extraction noextract let update' r acc (block: block) = Spec.Poly1305.poly1305_update1 r Spec.Poly1305.size_block block acc inline_for_extraction noextract let update_multi = Lib.UpdateMulti.mk_update_multi Spec.Poly1305.size_block update_ inline_for_extraction noextract let update_multi' r = Lib.UpdateMulti.mk_update_multi Spec.Poly1305.size_block (update' r) #push-options "--fuel 1" inline_for_extraction noextract let rec with_or_without_r (acc r: Spec.Poly1305.felem) (blocks: S.seq uint8): Lemma (requires S.length blocks % Spec.Poly1305.size_block = 0) (ensures update_multi (acc, r) blocks == (update_multi' r acc blocks, r)) (decreases (S.length blocks)) = if S.length blocks = 0 then () else let block, rem = Lib.UpdateMulti.split_block Spec.Poly1305.size_block blocks 1 in let acc = update' r acc block in with_or_without_r acc r rem #pop-options inline_for_extraction noextract let update_last (acc, r) (input: S.seq uint8 { S.length input <= Spec.Poly1305.size_block }) = if S.length input = 0 then acc, r else Spec.Poly1305.poly1305_update1 r (S.length input) input acc, r inline_for_extraction noextract let update_last' r acc (input: S.seq uint8 { S.length input <= Spec.Poly1305.size_block }) = if S.length input = 0 then acc else Spec.Poly1305.poly1305_update1 r (S.length input) input acc inline_for_extraction noextract let finish_ k (acc, r) = Spec.Poly1305.poly1305_finish k acc inline_for_extraction noextract let spec k input = Spec.Poly1305.poly1305_mac input k val update_last_not_block_is_update (input: S.seq uint8) (acc: Spec.Poly1305.felem) (r: Spec.Poly1305.felem): Lemma (requires (S.length input < Spec.Poly1305.size_block)) (ensures (update_last (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r)))
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.UpdateMulti.Lemmas.fsti.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "Hacl.Poly1305_32.fsti.checked", "Hacl.Poly1305_256.fsti.checked", "Hacl.Poly1305_128.fsti.checked", "Hacl.Impl.Poly1305.Fields.fst.checked", "Hacl.Impl.Poly1305.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.Poly1305.fst" }
[ { "abbrev": false, "full_module": "Hacl.Impl.Poly1305.Fields", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": "F32xN" }, { "abbrev": true, "full_module": "Hacl.Impl.Poly1305", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Streaming.Interface", "short_module": "I" }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
input: FStar.Seq.Base.seq Hacl.Streaming.Poly1305.uint8 -> acc: Spec.Poly1305.felem -> r: Spec.Poly1305.felem -> FStar.Pervasives.Lemma (requires FStar.Seq.Base.length input < Spec.Poly1305.size_block) (ensures Hacl.Streaming.Poly1305.update_last (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Hacl.Streaming.Poly1305.uint8", "Spec.Poly1305.felem", "FStar.Calc.calc_finish", "FStar.Pervasives.Native.tuple2", "Prims.eq2", "Hacl.Streaming.Poly1305.update_last", "FStar.Pervasives.Native.Mktuple2", "Lib.Sequence.repeat_blocks", "Lib.UpdateMulti.Lemmas.uint8", "Spec.Poly1305.poly1305_update1", "Spec.Poly1305.size_block", "Spec.Poly1305.poly1305_update_last", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "Lib.UpdateMulti.Lemmas.repeat_f", "Hacl.Streaming.Poly1305.update'", "Lib.UpdateMulti.Lemmas.repeat_l", "Hacl.Streaming.Poly1305.update_last'", "Hacl.Streaming.Poly1305.update_multi'", "FStar.Seq.Base.empty", "Lib.UpdateMulti.uint8", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.squash", "Lib.UpdateMulti.update_multi_zero", "Lib.UpdateMulti.Lemmas.update_full_is_repeat_blocks", "Lib.Sequence.Lemmas.repeat_blocks_extensionality", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.nat", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction" ]
[]
false
false
true
false
false
let update_last_not_block_is_update input acc r =
let open Lib.UpdateMulti.Lemmas in let block_length = Spec.Poly1305.size_block in assert_norm (block_length < pow2 32); calc ( == ) { update_last (acc, r) input; ( == ) { () } update_last' r acc input, r; ( == ) { Lib.UpdateMulti.update_multi_zero Spec.Poly1305.size_block (update' r) acc } update_last' r (update_multi' r acc S.empty) input, r; ( == ) { update_full_is_repeat_blocks block_length (update' r) (update_last' r) acc input input } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input (repeat_f block_length (update' r)) (repeat_l block_length (update_last' r) input) acc, r; ( == ) { Lib.Sequence.Lemmas.repeat_blocks_extensionality block_length input (repeat_f block_length (update' r)) Spec.Poly1305.(poly1305_update1 r size_block) (repeat_l block_length (update_last' r) input) Spec.Poly1305.(poly1305_update_last r) acc } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input Spec.Poly1305.(poly1305_update1 r size_block) Spec.Poly1305.(poly1305_update_last r) acc, r; }
false
Hacl.Impl.Salsa20.Core32.fst
Hacl.Impl.Salsa20.Core32.double_round
val double_round: st:state -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.double_round (as_seq h0 st))
val double_round: st:state -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.double_round (as_seq h0 st))
let double_round st = quarter_round st (size 0) (size 4) (size 8) (size 12); quarter_round st (size 5) (size 9) (size 13) (size 1); quarter_round st (size 10) (size 14) (size 2) (size 6); quarter_round st (size 15) (size 3) (size 7) (size 11); quarter_round st (size 0) (size 1) (size 2) (size 3); quarter_round st (size 5) (size 6) (size 7) (size 4); quarter_round st (size 10) (size 11) (size 8) (size 9); quarter_round st (size 15) (size 12) (size 13) (size 14)
{ "file_name": "code/salsa20/Hacl.Impl.Salsa20.Core32.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 58, "end_line": 171, "start_col": 0, "start_line": 162 }
module Hacl.Impl.Salsa20.Core32 open FStar.HyperStack open FStar.HyperStack.All open Lib.IntTypes open Lib.Sequence open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module Spec = Spec.Salsa20 let state = lbuffer uint32 16ul let index = i:size_t{size_v i < 16} inline_for_extraction val create_state: unit -> StackInline state (requires fun h -> True) (ensures fun h0 r h1 -> live h1 r /\ as_seq h1 r == Seq.create 16 (u32 0) /\ stack_allocated r h0 h1 (Seq.create 16 (u32 0))) let create_state () = create (size 16) (u32 0) inline_for_extraction val load_state: st:state -> b:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h st /\ live h b /\ disjoint st b) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Lib.ByteSequence.uints_from_bytes_le (as_seq h0 b)) let load_state st b = uints_from_bytes_le st b inline_for_extraction val store_state: b:lbuffer uint8 64ul -> st:state -> Stack unit (requires fun h -> live h st /\ live h b /\ disjoint st b) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == Lib.ByteSequence.uints_to_bytes_le (as_seq h0 st)) let store_state st b = uints_to_bytes_le 16ul st b inline_for_extraction val set_counter: st:state -> c:size_t -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Seq.upd (as_seq h0 st) 8 (size_to_uint32 c)) let set_counter st c = st.(size 8) <- size_to_uint32 c inline_for_extraction val copy_state: st:state -> ost:state -> Stack unit (requires fun h -> live h st /\ live h ost /\ disjoint st ost) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == as_seq h0 ost) let copy_state st ost = copy #MUT #uint32 #(size 16) st ost inline_for_extraction val sum_state: st:state -> ost:state -> Stack unit (requires fun h -> live h st /\ live h ost /\ eq_or_disjoint st ost) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Lib.Sequence.map2 (+.) (as_seq h0 st) (as_seq h0 ost)) let sum_state st ost = map2T #MUT #MUT #uint32 #uint32 #uint32 (size 16) st ( +. ) st ost inline_for_extraction val xor_block: o:lbuffer uint8 64ul -> st:state -> b:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h o /\ live h st /\ live h b) (ensures fun h0 _ h1 -> modifies (loc o) h0 h1 /\ as_seq h1 o == Spec.xor_block (as_seq h0 st) (as_seq h0 b)) #set-options "--z3rlimit 100" let xor_block o st b = push_frame(); let bl = create_state() in load_state bl b; map2T (size 16) bl ( ^. ) bl st; store_state o bl; pop_frame() inline_for_extraction val line: st:state -> a:index -> b:index -> d:index -> r:rotval U32 -> Stack unit (requires fun h -> live h st /\ v a <> v d) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.line (v a) (v b) (v d) r (as_seq h0 st)) let line st a b d r = let sta = st.(a) in let stb = st.(b) in let std = st.(d) in let sta = sta ^. ((stb +. std) <<<. r) in st.(a) <- sta val quarter_round: st:state -> a:index -> b:index -> c:index -> d:index -> Stack unit (requires fun h -> live h st /\ v b <> v d /\ v c <> v a) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.quarter_round (v a) (v b) (v c) (v d) (as_seq h0 st)) [@ CInline ] let quarter_round st a b c d = line st b a d (size 7); line st c b a (size 9); line st d c b (size 13); line st a d c (size 18) #reset-options "--z3rlimit 50" val double_round: st:state -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.double_round (as_seq h0 st))
{ "checked_file": "/", "dependencies": [ "Spec.Salsa20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Salsa20.Core32.fst" }
[ { "abbrev": true, "full_module": "Spec.Salsa20", "short_module": "Spec" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Salsa20", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Salsa20", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
st: Hacl.Impl.Salsa20.Core32.state -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.Salsa20.Core32.state", "Hacl.Impl.Salsa20.Core32.quarter_round", "Lib.IntTypes.size", "Prims.unit" ]
[]
false
true
false
false
false
let double_round st =
quarter_round st (size 0) (size 4) (size 8) (size 12); quarter_round st (size 5) (size 9) (size 13) (size 1); quarter_round st (size 10) (size 14) (size 2) (size 6); quarter_round st (size 15) (size 3) (size 7) (size 11); quarter_round st (size 0) (size 1) (size 2) (size 3); quarter_round st (size 5) (size 6) (size 7) (size 4); quarter_round st (size 10) (size 11) (size 8) (size 9); quarter_round st (size 15) (size 12) (size 13) (size 14)
false
Hacl.Streaming.Poly1305.fst
Hacl.Streaming.Poly1305.poly_is_incremental_lazy
val poly_is_incremental_lazy: key: S.seq uint8 { S.length key = 32 } -> input:S.seq uint8 { S.length input <= pow2 32 - 1 } -> Lemma (ensures ( let hash = Lib.UpdateMulti.update_full_lazy Spec.Poly1305.size_block update_ update_last (Spec.Poly1305.poly1305_init key) input in finish_ key hash `S.equal` spec key input))
val poly_is_incremental_lazy: key: S.seq uint8 { S.length key = 32 } -> input:S.seq uint8 { S.length input <= pow2 32 - 1 } -> Lemma (ensures ( let hash = Lib.UpdateMulti.update_full_lazy Spec.Poly1305.size_block update_ update_last (Spec.Poly1305.poly1305_init key) input in finish_ key hash `S.equal` spec key input))
let poly_is_incremental_lazy key input = let open Lib.UpdateMulti.Lemmas in let block_length = Spec.Poly1305.size_block in assert_norm (block_length < pow2 32); let n = S.length input / block_length in let rem = S.length input % block_length in let n', rem' = if rem = 0 && n > 0 then n - 1, block_length else n, rem in (**) let bs, l = S.split input (n' * block_length) in let acc, r = Spec.Poly1305.poly1305_init key in let acc1 = update_multi (acc, r) bs in let acc_f = update_last acc1 l in if rem = 0 && n > 0 then begin assert(acc_f == update__ acc1 l); assert( let block, rem = Lib.UpdateMulti.split_block Spec.Poly1305.size_block l 1 in block `S.equal` l /\ rem `S.equal` S.empty); let acc2 = update__ acc1 l in assert_norm(Lib.UpdateMulti.mk_update_multi Spec.Poly1305.size_block update_ acc2 S.empty == acc2); assert(acc_f == update_multi acc1 l); Lib.UpdateMulti.update_multi_associative Spec.Poly1305.size_block update_ (acc, r) bs l; assert(input `S.equal` S.append bs l); assert(acc_f = update_multi (acc, r) input); assert(update_last acc_f S.empty == acc_f); assert(input `S.equal` S.append input S.empty); poly_is_incremental key input end else poly_is_incremental key input
{ "file_name": "code/streaming/Hacl.Streaming.Poly1305.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 36, "end_line": 396, "start_col": 0, "start_line": 368 }
module Hacl.Streaming.Poly1305 module HS = FStar.HyperStack module B = LowStar.Buffer module G = FStar.Ghost module S = FStar.Seq module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module I = Hacl.Streaming.Interface module P = Hacl.Impl.Poly1305 module F32xN = Hacl.Spec.Poly1305.Field32xN module ST = FStar.HyperStack.ST open LowStar.BufferOps open FStar.Mul /// Opening a bunch of modules for Poly1305 /// ======================================= inline_for_extraction noextract let uint8 = Lib.IntTypes.uint8 inline_for_extraction noextract let uint32 = Lib.IntTypes.uint32 open Hacl.Impl.Poly1305.Fields /// An instance of the stateful type class for poly1305 state /// ========================================================= /// /// We use a custom view that separates r and acc, to respect abstraction boundaries established by Poly1305. #set-options "--fuel 0 --ifuel 1 --z3rlimit 100" inline_for_extraction noextract let t (fs : field_spec) = b:B.buffer (limb fs) { B.length b == 25 } inline_for_extraction noextract let as_raw (#fs : field_spec) (x: t fs): B.buffer (limb fs) = x inline_for_extraction noextract let as_lib (#fs : field_spec) (x: t fs): P.poly1305_ctx fs = assert (Lib.IntTypes.(v (add #U32 (nlimb fs) (precomplen fs))) == 25); x inline_for_extraction noextract let poly1305_key = I.stateful_buffer uint8 32ul (Lib.IntTypes.u8 0) unit inline_for_extraction noextract let as_lib_k (x: B.buffer uint8 { B.length x = 32 }): Lib.Buffer.lbuffer uint8 32ul = x inline_for_extraction noextract let num_lanes (fs : field_spec) : F32xN.lanes = match fs with | M32 -> 1 | M128 -> 2 | M256 -> 4 inline_for_extraction noextract let stateful_poly1305_ctx (fs : field_spec) : I.stateful unit = I.Stateful (fun () -> t fs) (fun #_ _ s -> B.loc_addr_of_buffer (as_raw s)) (fun #_ _ s -> B.freeable (as_raw s)) (fun #_ h s -> B.live h (as_raw s) /\ P.state_inv_t h (as_lib s)) (fun () -> Spec.Poly1305.felem & Spec.Poly1305.felem) (fun () h s -> P.as_get_acc h (as_lib s), P.as_get_r h (as_lib s)) (fun #_ _ _ -> ()) (fun #_ l s h0 h1 -> P.reveal_ctx_inv (as_lib s) h0 h1; B.modifies_buffer_elim (as_raw s) l h0 h1) (fun #_ _ _ _ _ -> ()) (fun () -> [@inline_let] let n = num_lanes fs in let r = B.alloca (F32xN.zero n) 25ul in let h1 = ST.get () in P.ctx_inv_zeros #fs r h1; r) (fun () r -> [@inline_let] let n = num_lanes fs in let r = B.malloc r (F32xN.zero n) 25ul in let h1 = ST.get () in P.ctx_inv_zeros #fs r h1; r) (fun _ s -> B.free s) (fun _ src dst -> let h0 = ST.get () in B.blit src 0ul dst 0ul 25ul; let h1 = ST.get () in P.reveal_ctx_inv' (as_lib src) (as_lib dst) h0 h1) /// Interlude for spec equivalence proofs /// ===================================== /// /// A quick explanation about this proof of equivalence. At the spec level, /// ``poly1305_update`` needs both ``r`` and the accumulator ``acc``. This thus /// makes poly1305 update a function of two arguments. However, the streaming /// facility is constructed over specifications that take one single argument. /// Not a problem! We carry the pair ``(r, acc)`` as our "streaming functor /// accumulator", and we now have to show that a specification in terms of /// ``update (update (r, acc) init)`` is the same as poly1305. For that, we need /// to do a little proof of equivalence to show first that this is the same as /// ``(update r) ((update r) acc)`` (note that the update function now becomes a /// partial application), then use the update-multi-repeat conversion lemma to /// get the original specification of poly1305. inline_for_extraction noextract let block = (block: S.seq uint8 { S.length block = Spec.Poly1305.size_block }) inline_for_extraction noextract let update_ (acc, r) (block: block) = Spec.Poly1305.poly1305_update1 r Spec.Poly1305.size_block block acc, r /// Same as [update_], but with the input not necessarily a full block (can be smaller) inline_for_extraction noextract let update__ (acc, r) (input: S.seq uint8{S.length input <= Spec.Poly1305.size_block}) = Spec.Poly1305.poly1305_update1 r (S.length input) input acc, r inline_for_extraction noextract let update' r acc (block: block) = Spec.Poly1305.poly1305_update1 r Spec.Poly1305.size_block block acc inline_for_extraction noextract let update_multi = Lib.UpdateMulti.mk_update_multi Spec.Poly1305.size_block update_ inline_for_extraction noextract let update_multi' r = Lib.UpdateMulti.mk_update_multi Spec.Poly1305.size_block (update' r) #push-options "--fuel 1" inline_for_extraction noextract let rec with_or_without_r (acc r: Spec.Poly1305.felem) (blocks: S.seq uint8): Lemma (requires S.length blocks % Spec.Poly1305.size_block = 0) (ensures update_multi (acc, r) blocks == (update_multi' r acc blocks, r)) (decreases (S.length blocks)) = if S.length blocks = 0 then () else let block, rem = Lib.UpdateMulti.split_block Spec.Poly1305.size_block blocks 1 in let acc = update' r acc block in with_or_without_r acc r rem #pop-options inline_for_extraction noextract let update_last (acc, r) (input: S.seq uint8 { S.length input <= Spec.Poly1305.size_block }) = if S.length input = 0 then acc, r else Spec.Poly1305.poly1305_update1 r (S.length input) input acc, r inline_for_extraction noextract let update_last' r acc (input: S.seq uint8 { S.length input <= Spec.Poly1305.size_block }) = if S.length input = 0 then acc else Spec.Poly1305.poly1305_update1 r (S.length input) input acc inline_for_extraction noextract let finish_ k (acc, r) = Spec.Poly1305.poly1305_finish k acc inline_for_extraction noextract let spec k input = Spec.Poly1305.poly1305_mac input k val update_last_not_block_is_update (input: S.seq uint8) (acc: Spec.Poly1305.felem) (r: Spec.Poly1305.felem): Lemma (requires (S.length input < Spec.Poly1305.size_block)) (ensures (update_last (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r))) let update_last_not_block_is_update input acc r = let open Lib.UpdateMulti.Lemmas in let block_length = Spec.Poly1305.size_block in assert_norm (block_length < pow2 32); calc (==) { update_last (acc, r) input; (==) { } update_last' r acc input, r; (==) { Lib.UpdateMulti.update_multi_zero Spec.Poly1305.size_block (update' r) acc } update_last' r (update_multi' r acc S.empty) input, r; (==) { update_full_is_repeat_blocks block_length (update' r) (update_last' r) acc input input } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input (repeat_f block_length (update' r)) (repeat_l block_length (update_last' r) input) acc, r; (==) { Lib.Sequence.Lemmas.repeat_blocks_extensionality block_length input (repeat_f block_length (update' r)) Spec.Poly1305.(poly1305_update1 r size_block) (repeat_l block_length (update_last' r) input) Spec.Poly1305.(poly1305_update_last r) acc } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input Spec.Poly1305.(poly1305_update1 r size_block) Spec.Poly1305.(poly1305_update_last r) acc, r; } val update_last_block_is_update (input: S.seq uint8) (acc: Spec.Poly1305.felem) (r: Spec.Poly1305.felem): Lemma (requires (S.length input = Spec.Poly1305.size_block)) (ensures (update_last (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r))) open FStar.Tactics #push-options "--fuel 1 --print_implicits" let update_last_block_is_update input acc r = let open Lib.UpdateMulti.Lemmas in let block_length = Spec.Poly1305.size_block in assert_norm (block_length < pow2 32); assert(input `S.equal` S.append input S.empty); let acc1 = update' r acc input in let acc1' = update_multi' r acc input in // SH: fun fact: this lemma call and the following assert should be the // last part of the below calc. However, if put below/inside the calc, // the proof loops. Lib.Sequence.Lemmas.repeat_blocks_extensionality block_length input (repeat_f block_length (update' r)) Spec.Poly1305.(poly1305_update1 r size_block) (repeat_l block_length (update_last' r) input) Spec.Poly1305.(poly1305_update_last r) acc; assert( Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input (repeat_f block_length (update' r)) (repeat_l block_length (update_last' r) input) acc == Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input Spec.Poly1305.(poly1305_update1 r size_block) Spec.Poly1305.(poly1305_update_last r) acc); assert( let block, rem = Lib.UpdateMulti.split_block block_length input 1 in block `S.equal` input /\ rem `S.equal` S.empty); assert( Lib.UpdateMulti.mk_update_multi block_length (update' r) acc1 S.empty == acc1'); assert(acc1 == acc1'); calc (==) { update_last (acc, r) input; (==) { } update_last' r acc input, r; (==) { } update_last' r (update' r acc input) S.empty, r; (==) { } update_last' r (update_multi' r acc input) S.empty, r; (==) { update_full_is_repeat_blocks block_length (update' r) (update_last' r) acc input input } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input (repeat_f block_length (update' r)) (repeat_l block_length (update_last' r) input) acc, r; } #pop-options val update_last_is_update (input: S.seq uint8) (acc: Spec.Poly1305.felem) (r: Spec.Poly1305.felem): Lemma (requires (S.length input <= Spec.Poly1305.size_block)) (ensures (update_last (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r))) let update_last_is_update input acc r = if S.length input = Spec.Poly1305.size_block then update_last_block_is_update input acc r else update_last_not_block_is_update input acc r val update_multi_is_update (input: S.seq uint8) (acc: Spec.Poly1305.felem) (r: Spec.Poly1305.felem): Lemma (requires (S.length input % Spec.Poly1305.size_block = 0)) (ensures (update_multi (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r))) let update_multi_is_update input acc r = let open Lib.UpdateMulti.Lemmas in let block_length = Spec.Poly1305.size_block in assert_norm (block_length < pow2 32); calc (==) { update_multi (acc, r) input; (==) { with_or_without_r acc r input } update_multi' r acc input, r; (==) { } update_last' r (update_multi' r acc input) S.empty, r; (==) { update_full_is_repeat_blocks block_length (update' r) (update_last' r) acc input input } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input (repeat_f block_length (update' r)) (repeat_l block_length (update_last' r) input) acc, r; (==) { Lib.Sequence.Lemmas.repeat_blocks_extensionality block_length input (repeat_f block_length (update' r)) Spec.Poly1305.(poly1305_update1 r size_block) (repeat_l block_length (update_last' r) input) Spec.Poly1305.(poly1305_update_last r) acc } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input Spec.Poly1305.(poly1305_update1 r size_block) Spec.Poly1305.(poly1305_update_last r) acc, r; } val poly_is_incremental: key: S.seq uint8 { S.length key = 32 } -> input:S.seq uint8 { S.length input <= pow2 32 - 1 } -> Lemma (ensures ( let hash = Lib.UpdateMulti.update_full Spec.Poly1305.size_block update_ update_last (Spec.Poly1305.poly1305_init key) input in finish_ key hash `S.equal` spec key input)) let poly_is_incremental key input = let open Lib.UpdateMulti.Lemmas in let block_length = Spec.Poly1305.size_block in assert_norm (block_length < pow2 32); let n = S.length input / block_length in let bs, l = S.split input (n * block_length) in FStar.Math.Lemmas.multiple_modulo_lemma n block_length; let acc, r = Spec.Poly1305.poly1305_init key in calc (S.equal) { finish_ key (update_last (update_multi (acc, r) bs) l); (S.equal) { with_or_without_r acc r bs } Spec.Poly1305.poly1305_finish key (update_last' r (update_multi' r acc bs) l); (S.equal) { update_full_is_repeat_blocks block_length (update' r) (update_last' r) acc input input } Spec.Poly1305.poly1305_finish key (Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input (repeat_f block_length (update' r)) (repeat_l block_length (update_last' r) input) acc); (S.equal) { Lib.Sequence.Lemmas.repeat_blocks_extensionality block_length input (repeat_f block_length (update' r)) Spec.Poly1305.(poly1305_update1 r size_block) (repeat_l block_length (update_last' r) input) Spec.Poly1305.(poly1305_update_last r) acc } Spec.Poly1305.poly1305_finish key (Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input Spec.Poly1305.(poly1305_update1 r size_block) Spec.Poly1305.(poly1305_update_last r) acc); } /// Same lemma as above, but we take into account the fact that the hash stream /// processes the buffer lazily. val poly_is_incremental_lazy: key: S.seq uint8 { S.length key = 32 } -> input:S.seq uint8 { S.length input <= pow2 32 - 1 } -> Lemma (ensures ( let hash = Lib.UpdateMulti.update_full_lazy Spec.Poly1305.size_block update_ update_last (Spec.Poly1305.poly1305_init key) input in finish_ key hash `S.equal` spec key input))
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.UpdateMulti.Lemmas.fsti.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "Hacl.Poly1305_32.fsti.checked", "Hacl.Poly1305_256.fsti.checked", "Hacl.Poly1305_128.fsti.checked", "Hacl.Impl.Poly1305.Fields.fst.checked", "Hacl.Impl.Poly1305.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.Poly1305.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Poly1305.Fields", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": "F32xN" }, { "abbrev": true, "full_module": "Hacl.Impl.Poly1305", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Streaming.Interface", "short_module": "I" }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
key: FStar.Seq.Base.seq Hacl.Streaming.Poly1305.uint8 {FStar.Seq.Base.length key = 32} -> input: FStar.Seq.Base.seq Hacl.Streaming.Poly1305.uint8 {FStar.Seq.Base.length input <= Prims.pow2 32 - 1} -> FStar.Pervasives.Lemma (ensures (let hash = Lib.UpdateMulti.update_full_lazy Spec.Poly1305.size_block Hacl.Streaming.Poly1305.update_ Hacl.Streaming.Poly1305.update_last (Spec.Poly1305.poly1305_init key) input in FStar.Seq.Base.equal (Hacl.Streaming.Poly1305.finish_ key hash) (Hacl.Streaming.Poly1305.spec key input)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Hacl.Streaming.Poly1305.uint8", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Seq.Base.length", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "Spec.Poly1305.felem", "Prims.op_AmpAmp", "Prims.op_GreaterThan", "Hacl.Streaming.Poly1305.poly_is_incremental", "Prims.unit", "Prims._assert", "FStar.Seq.Base.equal", "FStar.Seq.Base.append", "FStar.Seq.Base.empty", "Prims.eq2", "FStar.Pervasives.Native.tuple2", "Hacl.Streaming.Poly1305.update_last", "Hacl.Streaming.Poly1305.update_multi", "FStar.Pervasives.Native.Mktuple2", "Lib.UpdateMulti.update_multi_associative", "Spec.Poly1305.size_block", "Hacl.Streaming.Poly1305.update_", "FStar.Pervasives.assert_norm", "Lib.UpdateMulti.mk_update_multi", "Lib.UpdateMulti.uint8", "Hacl.Streaming.Poly1305.update__", "Prims.l_and", "Lib.UpdateMulti.split_block", "Prims.bool", "Spec.Poly1305.poly1305_init", "FStar.Seq.Properties.split", "FStar.Mul.op_Star", "Prims.op_Modulus", "Prims.op_Division", "Prims.op_LessThan", "Prims.nat" ]
[]
false
false
true
false
false
let poly_is_incremental_lazy key input =
let open Lib.UpdateMulti.Lemmas in let block_length = Spec.Poly1305.size_block in assert_norm (block_length < pow2 32); let n = S.length input / block_length in let rem = S.length input % block_length in let n', rem' = if rem = 0 && n > 0 then n - 1, block_length else n, rem in let bs, l = S.split input (n' * block_length) in let acc, r = Spec.Poly1305.poly1305_init key in let acc1 = update_multi (acc, r) bs in let acc_f = update_last acc1 l in if rem = 0 && n > 0 then (assert (acc_f == update__ acc1 l); assert (let block, rem = Lib.UpdateMulti.split_block Spec.Poly1305.size_block l 1 in block `S.equal` l /\ rem `S.equal` S.empty); let acc2 = update__ acc1 l in assert_norm (Lib.UpdateMulti.mk_update_multi Spec.Poly1305.size_block update_ acc2 S.empty == acc2); assert (acc_f == update_multi acc1 l); Lib.UpdateMulti.update_multi_associative Spec.Poly1305.size_block update_ (acc, r) bs l; assert (input `S.equal` (S.append bs l)); assert (acc_f = update_multi (acc, r) input); assert (update_last acc_f S.empty == acc_f); assert (input `S.equal` (S.append input S.empty)); poly_is_incremental key input) else poly_is_incremental key input
false
FStar.Tactics.Util.fst
FStar.Tactics.Util.mapi
val mapi: (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b)
val mapi: (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b)
let mapi f l = __mapi 0 f l
{ "file_name": "ulib/FStar.Tactics.Util.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 27, "end_line": 33, "start_col": 0, "start_line": 33 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.Util open FStar.Tactics.Effect open FStar.List.Tot.Base (* Tac list functions, since there's no effect polymorphism *) val map: ('a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec map f x = match x with | [] -> [] | a::tl -> f a::map f tl val __mapi: nat -> (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec __mapi i f x = match x with | [] -> [] | a::tl -> f i a::__mapi (i+1) f tl
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.Util.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: Prims.nat -> _: 'a -> FStar.Tactics.Effect.Tac 'b) -> l: Prims.list 'a -> FStar.Tactics.Effect.Tac (Prims.list 'b)
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.nat", "Prims.list", "FStar.Tactics.Util.__mapi" ]
[]
false
true
false
false
false
let mapi f l =
__mapi 0 f l
false
FStar.Tactics.Util.fst
FStar.Tactics.Util.iteri
val iteri: (int -> 'a -> Tac unit) -> list 'a -> Tac unit
val iteri: (int -> 'a -> Tac unit) -> list 'a -> Tac unit
let iteri f x = iteri_aux 0 f x
{ "file_name": "ulib/FStar.Tactics.Util.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 31, "end_line": 46, "start_col": 0, "start_line": 46 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.Util open FStar.Tactics.Effect open FStar.List.Tot.Base (* Tac list functions, since there's no effect polymorphism *) val map: ('a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec map f x = match x with | [] -> [] | a::tl -> f a::map f tl val __mapi: nat -> (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec __mapi i f x = match x with | [] -> [] | a::tl -> f i a::__mapi (i+1) f tl val mapi: (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b) let mapi f l = __mapi 0 f l val iter : ('a -> Tac unit) -> list 'a -> Tac unit let rec iter f x = match x with | [] -> () | a::tl -> f a; iter f tl val iteri_aux: int -> (int -> 'a -> Tac unit) -> list 'a -> Tac unit let rec iteri_aux i f x = match x with | [] -> () | a::tl -> f i a; iteri_aux (i+1) f tl
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.Util.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: Prims.int -> _: 'a -> FStar.Tactics.Effect.Tac Prims.unit) -> x: Prims.list 'a -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.int", "Prims.unit", "Prims.list", "FStar.Tactics.Util.iteri_aux" ]
[]
false
true
false
false
false
let iteri f x =
iteri_aux 0 f x
false
FStar.Tactics.Util.fst
FStar.Tactics.Util.map
val map: ('a -> Tac 'b) -> list 'a -> Tac (list 'b)
val map: ('a -> Tac 'b) -> list 'a -> Tac (list 'b)
let rec map f x = match x with | [] -> [] | a::tl -> f a::map f tl
{ "file_name": "ulib/FStar.Tactics.Util.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 26, "end_line": 25, "start_col": 0, "start_line": 23 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.Util open FStar.Tactics.Effect open FStar.List.Tot.Base (* Tac list functions, since there's no effect polymorphism *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.Util.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: 'a -> FStar.Tactics.Effect.Tac 'b) -> x: Prims.list 'a -> FStar.Tactics.Effect.Tac (Prims.list 'b)
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.list", "Prims.Nil", "Prims.Cons", "FStar.Tactics.Util.map" ]
[ "recursion" ]
false
true
false
false
false
let rec map f x =
match x with | [] -> [] | a :: tl -> f a :: map f tl
false
FStar.Tactics.Util.fst
FStar.Tactics.Util.iter
val iter : ('a -> Tac unit) -> list 'a -> Tac unit
val iter : ('a -> Tac unit) -> list 'a -> Tac unit
let rec iter f x = match x with | [] -> () | a::tl -> f a; iter f tl
{ "file_name": "ulib/FStar.Tactics.Util.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 27, "end_line": 38, "start_col": 0, "start_line": 36 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.Util open FStar.Tactics.Effect open FStar.List.Tot.Base (* Tac list functions, since there's no effect polymorphism *) val map: ('a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec map f x = match x with | [] -> [] | a::tl -> f a::map f tl val __mapi: nat -> (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec __mapi i f x = match x with | [] -> [] | a::tl -> f i a::__mapi (i+1) f tl val mapi: (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b) let mapi f l = __mapi 0 f l
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.Util.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: 'a -> FStar.Tactics.Effect.Tac Prims.unit) -> x: Prims.list 'a -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.unit", "Prims.list", "FStar.Tactics.Util.iter" ]
[ "recursion" ]
false
true
false
false
false
let rec iter f x =
match x with | [] -> () | a :: tl -> f a; iter f tl
false
FStar.Tactics.Util.fst
FStar.Tactics.Util.zip
val zip : (#a:Type) -> (#b:Type) -> list a -> list b -> Tac (list (a * b))
val zip : (#a:Type) -> (#b:Type) -> list a -> list b -> Tac (list (a * b))
let rec zip #a #b l1 l2 = match l1, l2 with | x::xs, y::ys -> (x,y) :: (zip xs ys) | _ -> []
{ "file_name": "ulib/FStar.Tactics.Util.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 13, "end_line": 62, "start_col": 0, "start_line": 60 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.Util open FStar.Tactics.Effect open FStar.List.Tot.Base (* Tac list functions, since there's no effect polymorphism *) val map: ('a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec map f x = match x with | [] -> [] | a::tl -> f a::map f tl val __mapi: nat -> (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec __mapi i f x = match x with | [] -> [] | a::tl -> f i a::__mapi (i+1) f tl val mapi: (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b) let mapi f l = __mapi 0 f l val iter : ('a -> Tac unit) -> list 'a -> Tac unit let rec iter f x = match x with | [] -> () | a::tl -> f a; iter f tl val iteri_aux: int -> (int -> 'a -> Tac unit) -> list 'a -> Tac unit let rec iteri_aux i f x = match x with | [] -> () | a::tl -> f i a; iteri_aux (i+1) f tl val iteri: (int -> 'a -> Tac unit) -> list 'a -> Tac unit let iteri f x = iteri_aux 0 f x val fold_left: ('a -> 'b -> Tac 'a) -> 'a -> l:list 'b -> Tac 'a let rec fold_left f x l = match l with | [] -> x | hd::tl -> fold_left f (f x hd) tl val fold_right: ('a -> 'b -> Tac 'b) -> list 'a -> 'b -> Tac 'b let rec fold_right f l x = match l with | [] -> x | hd::tl -> f hd (fold_right f tl x) (* There's no unconditionally total zip like this in Tot.Base, why? Anyway use this *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.Util.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
l1: Prims.list a -> l2: Prims.list b -> FStar.Tactics.Effect.Tac (Prims.list (a * b))
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.list", "FStar.Pervasives.Native.Mktuple2", "Prims.Cons", "FStar.Pervasives.Native.tuple2", "FStar.Tactics.Util.zip", "Prims.Nil" ]
[ "recursion" ]
false
true
false
false
false
let rec zip #a #b l1 l2 =
match l1, l2 with | x :: xs, y :: ys -> (x, y) :: (zip xs ys) | _ -> []
false
FStar.Tactics.Util.fst
FStar.Tactics.Util.filter_map
val filter_map (f: ('a -> Tac (option 'b))) (l: list 'a) : Tac (list 'b)
val filter_map (f: ('a -> Tac (option 'b))) (l: list 'a) : Tac (list 'b)
let filter_map (f:'a -> Tac (option 'b)) (l:list 'a) : Tac (list 'b) = filter_map_acc f [] l
{ "file_name": "ulib/FStar.Tactics.Util.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 23, "end_line": 82, "start_col": 0, "start_line": 81 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.Util open FStar.Tactics.Effect open FStar.List.Tot.Base (* Tac list functions, since there's no effect polymorphism *) val map: ('a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec map f x = match x with | [] -> [] | a::tl -> f a::map f tl val __mapi: nat -> (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec __mapi i f x = match x with | [] -> [] | a::tl -> f i a::__mapi (i+1) f tl val mapi: (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b) let mapi f l = __mapi 0 f l val iter : ('a -> Tac unit) -> list 'a -> Tac unit let rec iter f x = match x with | [] -> () | a::tl -> f a; iter f tl val iteri_aux: int -> (int -> 'a -> Tac unit) -> list 'a -> Tac unit let rec iteri_aux i f x = match x with | [] -> () | a::tl -> f i a; iteri_aux (i+1) f tl val iteri: (int -> 'a -> Tac unit) -> list 'a -> Tac unit let iteri f x = iteri_aux 0 f x val fold_left: ('a -> 'b -> Tac 'a) -> 'a -> l:list 'b -> Tac 'a let rec fold_left f x l = match l with | [] -> x | hd::tl -> fold_left f (f x hd) tl val fold_right: ('a -> 'b -> Tac 'b) -> list 'a -> 'b -> Tac 'b let rec fold_right f l x = match l with | [] -> x | hd::tl -> f hd (fold_right f tl x) (* There's no unconditionally total zip like this in Tot.Base, why? Anyway use this *) val zip : (#a:Type) -> (#b:Type) -> list a -> list b -> Tac (list (a * b)) let rec zip #a #b l1 l2 = match l1, l2 with | x::xs, y::ys -> (x,y) :: (zip xs ys) | _ -> [] val filter: ('a -> Tac bool) -> list 'a -> Tac (list 'a) let rec filter f = function | [] -> [] | hd::tl -> if f hd then hd::(filter f tl) else filter f tl private let rec filter_map_acc (f:'a -> Tac (option 'b)) (acc:list 'b) (l:list 'a) : Tac (list 'b) = match l with | [] -> rev acc | hd :: tl -> match f hd with | Some hd -> filter_map_acc f (hd :: acc) tl | None -> filter_map_acc f acc tl
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.Util.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: 'a -> FStar.Tactics.Effect.Tac (FStar.Pervasives.Native.option 'b)) -> l: Prims.list 'a -> FStar.Tactics.Effect.Tac (Prims.list 'b)
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Pervasives.Native.option", "Prims.list", "FStar.Tactics.Util.filter_map_acc", "Prims.Nil" ]
[]
false
true
false
false
false
let filter_map (f: ('a -> Tac (option 'b))) (l: list 'a) : Tac (list 'b) =
filter_map_acc f [] l
false
FStar.Tactics.Util.fst
FStar.Tactics.Util.__mapi
val __mapi: nat -> (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b)
val __mapi: nat -> (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b)
let rec __mapi i f x = match x with | [] -> [] | a::tl -> f i a::__mapi (i+1) f tl
{ "file_name": "ulib/FStar.Tactics.Util.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 37, "end_line": 30, "start_col": 0, "start_line": 28 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.Util open FStar.Tactics.Effect open FStar.List.Tot.Base (* Tac list functions, since there's no effect polymorphism *) val map: ('a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec map f x = match x with | [] -> [] | a::tl -> f a::map f tl
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.Util.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
i: Prims.nat -> f: (_: Prims.nat -> _: 'a -> FStar.Tactics.Effect.Tac 'b) -> x: Prims.list 'a -> FStar.Tactics.Effect.Tac (Prims.list 'b)
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.nat", "Prims.list", "Prims.Nil", "Prims.Cons", "FStar.Tactics.Util.__mapi", "Prims.op_Addition" ]
[ "recursion" ]
false
true
false
false
false
let rec __mapi i f x =
match x with | [] -> [] | a :: tl -> f i a :: __mapi (i + 1) f tl
false
FStar.Tactics.Util.fst
FStar.Tactics.Util.iteri_aux
val iteri_aux: int -> (int -> 'a -> Tac unit) -> list 'a -> Tac unit
val iteri_aux: int -> (int -> 'a -> Tac unit) -> list 'a -> Tac unit
let rec iteri_aux i f x = match x with | [] -> () | a::tl -> f i a; iteri_aux (i+1) f tl
{ "file_name": "ulib/FStar.Tactics.Util.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 40, "end_line": 43, "start_col": 0, "start_line": 41 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.Util open FStar.Tactics.Effect open FStar.List.Tot.Base (* Tac list functions, since there's no effect polymorphism *) val map: ('a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec map f x = match x with | [] -> [] | a::tl -> f a::map f tl val __mapi: nat -> (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec __mapi i f x = match x with | [] -> [] | a::tl -> f i a::__mapi (i+1) f tl val mapi: (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b) let mapi f l = __mapi 0 f l val iter : ('a -> Tac unit) -> list 'a -> Tac unit let rec iter f x = match x with | [] -> () | a::tl -> f a; iter f tl
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.Util.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
i: Prims.int -> f: (_: Prims.int -> _: 'a -> FStar.Tactics.Effect.Tac Prims.unit) -> x: Prims.list 'a -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.int", "Prims.unit", "Prims.list", "FStar.Tactics.Util.iteri_aux", "Prims.op_Addition" ]
[ "recursion" ]
false
true
false
false
false
let rec iteri_aux i f x =
match x with | [] -> () | a :: tl -> f i a; iteri_aux (i + 1) f tl
false
FStar.Tactics.Util.fst
FStar.Tactics.Util.fold_right
val fold_right: ('a -> 'b -> Tac 'b) -> list 'a -> 'b -> Tac 'b
val fold_right: ('a -> 'b -> Tac 'b) -> list 'a -> 'b -> Tac 'b
let rec fold_right f l x = match l with | [] -> x | hd::tl -> f hd (fold_right f tl x)
{ "file_name": "ulib/FStar.Tactics.Util.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 38, "end_line": 56, "start_col": 0, "start_line": 54 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.Util open FStar.Tactics.Effect open FStar.List.Tot.Base (* Tac list functions, since there's no effect polymorphism *) val map: ('a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec map f x = match x with | [] -> [] | a::tl -> f a::map f tl val __mapi: nat -> (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec __mapi i f x = match x with | [] -> [] | a::tl -> f i a::__mapi (i+1) f tl val mapi: (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b) let mapi f l = __mapi 0 f l val iter : ('a -> Tac unit) -> list 'a -> Tac unit let rec iter f x = match x with | [] -> () | a::tl -> f a; iter f tl val iteri_aux: int -> (int -> 'a -> Tac unit) -> list 'a -> Tac unit let rec iteri_aux i f x = match x with | [] -> () | a::tl -> f i a; iteri_aux (i+1) f tl val iteri: (int -> 'a -> Tac unit) -> list 'a -> Tac unit let iteri f x = iteri_aux 0 f x val fold_left: ('a -> 'b -> Tac 'a) -> 'a -> l:list 'b -> Tac 'a let rec fold_left f x l = match l with | [] -> x | hd::tl -> fold_left f (f x hd) tl
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.Util.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: 'a -> _: 'b -> FStar.Tactics.Effect.Tac 'b) -> l: Prims.list 'a -> x: 'b -> FStar.Tactics.Effect.Tac 'b
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.list", "FStar.Tactics.Util.fold_right" ]
[ "recursion" ]
false
true
false
false
false
let rec fold_right f l x =
match l with | [] -> x | hd :: tl -> f hd (fold_right f tl x)
false
FStar.Tactics.Util.fst
FStar.Tactics.Util.fold_left
val fold_left: ('a -> 'b -> Tac 'a) -> 'a -> l:list 'b -> Tac 'a
val fold_left: ('a -> 'b -> Tac 'a) -> 'a -> l:list 'b -> Tac 'a
let rec fold_left f x l = match l with | [] -> x | hd::tl -> fold_left f (f x hd) tl
{ "file_name": "ulib/FStar.Tactics.Util.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 37, "end_line": 51, "start_col": 0, "start_line": 49 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.Util open FStar.Tactics.Effect open FStar.List.Tot.Base (* Tac list functions, since there's no effect polymorphism *) val map: ('a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec map f x = match x with | [] -> [] | a::tl -> f a::map f tl val __mapi: nat -> (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec __mapi i f x = match x with | [] -> [] | a::tl -> f i a::__mapi (i+1) f tl val mapi: (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b) let mapi f l = __mapi 0 f l val iter : ('a -> Tac unit) -> list 'a -> Tac unit let rec iter f x = match x with | [] -> () | a::tl -> f a; iter f tl val iteri_aux: int -> (int -> 'a -> Tac unit) -> list 'a -> Tac unit let rec iteri_aux i f x = match x with | [] -> () | a::tl -> f i a; iteri_aux (i+1) f tl val iteri: (int -> 'a -> Tac unit) -> list 'a -> Tac unit let iteri f x = iteri_aux 0 f x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.Util.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: 'a -> _: 'b -> FStar.Tactics.Effect.Tac 'a) -> x: 'a -> l: Prims.list 'b -> FStar.Tactics.Effect.Tac 'a
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.list", "FStar.Tactics.Util.fold_left" ]
[ "recursion" ]
false
true
false
false
false
let rec fold_left f x l =
match l with | [] -> x | hd :: tl -> fold_left f (f x hd) tl
false
FStar.Tactics.Util.fst
FStar.Tactics.Util.filter_map_acc
val filter_map_acc (f: ('a -> Tac (option 'b))) (acc: list 'b) (l: list 'a) : Tac (list 'b)
val filter_map_acc (f: ('a -> Tac (option 'b))) (acc: list 'b) (l: list 'a) : Tac (list 'b)
let rec filter_map_acc (f:'a -> Tac (option 'b)) (acc:list 'b) (l:list 'a) : Tac (list 'b) = match l with | [] -> rev acc | hd :: tl -> match f hd with | Some hd -> filter_map_acc f (hd :: acc) tl | None -> filter_map_acc f acc tl
{ "file_name": "ulib/FStar.Tactics.Util.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 33, "end_line": 79, "start_col": 8, "start_line": 69 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.Util open FStar.Tactics.Effect open FStar.List.Tot.Base (* Tac list functions, since there's no effect polymorphism *) val map: ('a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec map f x = match x with | [] -> [] | a::tl -> f a::map f tl val __mapi: nat -> (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec __mapi i f x = match x with | [] -> [] | a::tl -> f i a::__mapi (i+1) f tl val mapi: (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b) let mapi f l = __mapi 0 f l val iter : ('a -> Tac unit) -> list 'a -> Tac unit let rec iter f x = match x with | [] -> () | a::tl -> f a; iter f tl val iteri_aux: int -> (int -> 'a -> Tac unit) -> list 'a -> Tac unit let rec iteri_aux i f x = match x with | [] -> () | a::tl -> f i a; iteri_aux (i+1) f tl val iteri: (int -> 'a -> Tac unit) -> list 'a -> Tac unit let iteri f x = iteri_aux 0 f x val fold_left: ('a -> 'b -> Tac 'a) -> 'a -> l:list 'b -> Tac 'a let rec fold_left f x l = match l with | [] -> x | hd::tl -> fold_left f (f x hd) tl val fold_right: ('a -> 'b -> Tac 'b) -> list 'a -> 'b -> Tac 'b let rec fold_right f l x = match l with | [] -> x | hd::tl -> f hd (fold_right f tl x) (* There's no unconditionally total zip like this in Tot.Base, why? Anyway use this *) val zip : (#a:Type) -> (#b:Type) -> list a -> list b -> Tac (list (a * b)) let rec zip #a #b l1 l2 = match l1, l2 with | x::xs, y::ys -> (x,y) :: (zip xs ys) | _ -> [] val filter: ('a -> Tac bool) -> list 'a -> Tac (list 'a) let rec filter f = function | [] -> [] | hd::tl -> if f hd then hd::(filter f tl) else filter f tl
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.Util.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: 'a -> FStar.Tactics.Effect.Tac (FStar.Pervasives.Native.option 'b)) -> acc: Prims.list 'b -> l: Prims.list 'a -> FStar.Tactics.Effect.Tac (Prims.list 'b)
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Pervasives.Native.option", "Prims.list", "FStar.List.Tot.Base.rev", "FStar.Tactics.Util.filter_map_acc", "Prims.Cons" ]
[ "recursion" ]
false
true
false
false
false
let rec filter_map_acc (f: ('a -> Tac (option 'b))) (acc: list 'b) (l: list 'a) : Tac (list 'b) =
match l with | [] -> rev acc | hd :: tl -> match f hd with | Some hd -> filter_map_acc f (hd :: acc) tl | None -> filter_map_acc f acc tl
false
FStar.Tactics.Util.fst
FStar.Tactics.Util.repeatn
val repeatn (#a: Type) (n: int) (t: (unit -> Tac a)) : Tac (l: list a {n < 0 \/ length l == n})
val repeatn (#a: Type) (n: int) (t: (unit -> Tac a)) : Tac (l: list a {n < 0 \/ length l == n})
let rec repeatn (#a:Type) (n : int) (t : unit -> Tac a) : Tac (l:list a{n < 0 \/ length l == n}) = if n <= 0 then [] else t () :: repeatn (n - 1) t
{ "file_name": "ulib/FStar.Tactics.Util.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 34, "end_line": 101, "start_col": 0, "start_line": 98 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.Util open FStar.Tactics.Effect open FStar.List.Tot.Base (* Tac list functions, since there's no effect polymorphism *) val map: ('a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec map f x = match x with | [] -> [] | a::tl -> f a::map f tl val __mapi: nat -> (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec __mapi i f x = match x with | [] -> [] | a::tl -> f i a::__mapi (i+1) f tl val mapi: (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b) let mapi f l = __mapi 0 f l val iter : ('a -> Tac unit) -> list 'a -> Tac unit let rec iter f x = match x with | [] -> () | a::tl -> f a; iter f tl val iteri_aux: int -> (int -> 'a -> Tac unit) -> list 'a -> Tac unit let rec iteri_aux i f x = match x with | [] -> () | a::tl -> f i a; iteri_aux (i+1) f tl val iteri: (int -> 'a -> Tac unit) -> list 'a -> Tac unit let iteri f x = iteri_aux 0 f x val fold_left: ('a -> 'b -> Tac 'a) -> 'a -> l:list 'b -> Tac 'a let rec fold_left f x l = match l with | [] -> x | hd::tl -> fold_left f (f x hd) tl val fold_right: ('a -> 'b -> Tac 'b) -> list 'a -> 'b -> Tac 'b let rec fold_right f l x = match l with | [] -> x | hd::tl -> f hd (fold_right f tl x) (* There's no unconditionally total zip like this in Tot.Base, why? Anyway use this *) val zip : (#a:Type) -> (#b:Type) -> list a -> list b -> Tac (list (a * b)) let rec zip #a #b l1 l2 = match l1, l2 with | x::xs, y::ys -> (x,y) :: (zip xs ys) | _ -> [] val filter: ('a -> Tac bool) -> list 'a -> Tac (list 'a) let rec filter f = function | [] -> [] | hd::tl -> if f hd then hd::(filter f tl) else filter f tl private let rec filter_map_acc (f:'a -> Tac (option 'b)) (acc:list 'b) (l:list 'a) : Tac (list 'b) = match l with | [] -> rev acc | hd :: tl -> match f hd with | Some hd -> filter_map_acc f (hd :: acc) tl | None -> filter_map_acc f acc tl let filter_map (f:'a -> Tac (option 'b)) (l:list 'a) : Tac (list 'b) = filter_map_acc f [] l val tryPick: ('a -> Tac (option 'b)) -> list 'a -> Tac (option 'b) let rec tryPick f l = match l with | [] -> None | hd::tl -> match f hd with | Some x -> Some x | None -> tryPick f tl let map_opt (f:'a -> Tac 'b) (x:option 'a) : Tac (option 'b) = match x with | None -> None | Some x -> Some (f x)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.Util.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.int -> t: (_: Prims.unit -> FStar.Tactics.Effect.Tac a) -> FStar.Tactics.Effect.Tac (l: Prims.list a {n < 0 \/ FStar.List.Tot.Base.length l == n})
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.int", "Prims.unit", "Prims.op_LessThanOrEqual", "Prims.Nil", "Prims.list", "Prims.l_or", "Prims.b2t", "Prims.op_LessThan", "Prims.eq2", "FStar.List.Tot.Base.length", "Prims.bool", "Prims.Cons", "FStar.Tactics.Util.repeatn", "Prims.op_Subtraction" ]
[ "recursion" ]
false
true
false
false
false
let rec repeatn (#a: Type) (n: int) (t: (unit -> Tac a)) : Tac (l: list a {n < 0 \/ length l == n}) =
if n <= 0 then [] else t () :: repeatn (n - 1) t
false
FStar.Tactics.Util.fst
FStar.Tactics.Util.map_opt
val map_opt (f: ('a -> Tac 'b)) (x: option 'a) : Tac (option 'b)
val map_opt (f: ('a -> Tac 'b)) (x: option 'a) : Tac (option 'b)
let map_opt (f:'a -> Tac 'b) (x:option 'a) : Tac (option 'b) = match x with | None -> None | Some x -> Some (f x)
{ "file_name": "ulib/FStar.Tactics.Util.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 24, "end_line": 95, "start_col": 0, "start_line": 92 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.Util open FStar.Tactics.Effect open FStar.List.Tot.Base (* Tac list functions, since there's no effect polymorphism *) val map: ('a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec map f x = match x with | [] -> [] | a::tl -> f a::map f tl val __mapi: nat -> (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec __mapi i f x = match x with | [] -> [] | a::tl -> f i a::__mapi (i+1) f tl val mapi: (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b) let mapi f l = __mapi 0 f l val iter : ('a -> Tac unit) -> list 'a -> Tac unit let rec iter f x = match x with | [] -> () | a::tl -> f a; iter f tl val iteri_aux: int -> (int -> 'a -> Tac unit) -> list 'a -> Tac unit let rec iteri_aux i f x = match x with | [] -> () | a::tl -> f i a; iteri_aux (i+1) f tl val iteri: (int -> 'a -> Tac unit) -> list 'a -> Tac unit let iteri f x = iteri_aux 0 f x val fold_left: ('a -> 'b -> Tac 'a) -> 'a -> l:list 'b -> Tac 'a let rec fold_left f x l = match l with | [] -> x | hd::tl -> fold_left f (f x hd) tl val fold_right: ('a -> 'b -> Tac 'b) -> list 'a -> 'b -> Tac 'b let rec fold_right f l x = match l with | [] -> x | hd::tl -> f hd (fold_right f tl x) (* There's no unconditionally total zip like this in Tot.Base, why? Anyway use this *) val zip : (#a:Type) -> (#b:Type) -> list a -> list b -> Tac (list (a * b)) let rec zip #a #b l1 l2 = match l1, l2 with | x::xs, y::ys -> (x,y) :: (zip xs ys) | _ -> [] val filter: ('a -> Tac bool) -> list 'a -> Tac (list 'a) let rec filter f = function | [] -> [] | hd::tl -> if f hd then hd::(filter f tl) else filter f tl private let rec filter_map_acc (f:'a -> Tac (option 'b)) (acc:list 'b) (l:list 'a) : Tac (list 'b) = match l with | [] -> rev acc | hd :: tl -> match f hd with | Some hd -> filter_map_acc f (hd :: acc) tl | None -> filter_map_acc f acc tl let filter_map (f:'a -> Tac (option 'b)) (l:list 'a) : Tac (list 'b) = filter_map_acc f [] l val tryPick: ('a -> Tac (option 'b)) -> list 'a -> Tac (option 'b) let rec tryPick f l = match l with | [] -> None | hd::tl -> match f hd with | Some x -> Some x | None -> tryPick f tl
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.Util.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: 'a -> FStar.Tactics.Effect.Tac 'b) -> x: FStar.Pervasives.Native.option 'a -> FStar.Tactics.Effect.Tac (FStar.Pervasives.Native.option 'b)
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.Some" ]
[]
false
true
false
false
false
let map_opt (f: ('a -> Tac 'b)) (x: option 'a) : Tac (option 'b) =
match x with | None -> None | Some x -> Some (f x)
false
FStar.Tactics.Util.fst
FStar.Tactics.Util.tryPick
val tryPick: ('a -> Tac (option 'b)) -> list 'a -> Tac (option 'b)
val tryPick: ('a -> Tac (option 'b)) -> list 'a -> Tac (option 'b)
let rec tryPick f l = match l with | [] -> None | hd::tl -> match f hd with | Some x -> Some x | None -> tryPick f tl
{ "file_name": "ulib/FStar.Tactics.Util.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 31, "end_line": 90, "start_col": 0, "start_line": 85 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.Util open FStar.Tactics.Effect open FStar.List.Tot.Base (* Tac list functions, since there's no effect polymorphism *) val map: ('a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec map f x = match x with | [] -> [] | a::tl -> f a::map f tl val __mapi: nat -> (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec __mapi i f x = match x with | [] -> [] | a::tl -> f i a::__mapi (i+1) f tl val mapi: (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b) let mapi f l = __mapi 0 f l val iter : ('a -> Tac unit) -> list 'a -> Tac unit let rec iter f x = match x with | [] -> () | a::tl -> f a; iter f tl val iteri_aux: int -> (int -> 'a -> Tac unit) -> list 'a -> Tac unit let rec iteri_aux i f x = match x with | [] -> () | a::tl -> f i a; iteri_aux (i+1) f tl val iteri: (int -> 'a -> Tac unit) -> list 'a -> Tac unit let iteri f x = iteri_aux 0 f x val fold_left: ('a -> 'b -> Tac 'a) -> 'a -> l:list 'b -> Tac 'a let rec fold_left f x l = match l with | [] -> x | hd::tl -> fold_left f (f x hd) tl val fold_right: ('a -> 'b -> Tac 'b) -> list 'a -> 'b -> Tac 'b let rec fold_right f l x = match l with | [] -> x | hd::tl -> f hd (fold_right f tl x) (* There's no unconditionally total zip like this in Tot.Base, why? Anyway use this *) val zip : (#a:Type) -> (#b:Type) -> list a -> list b -> Tac (list (a * b)) let rec zip #a #b l1 l2 = match l1, l2 with | x::xs, y::ys -> (x,y) :: (zip xs ys) | _ -> [] val filter: ('a -> Tac bool) -> list 'a -> Tac (list 'a) let rec filter f = function | [] -> [] | hd::tl -> if f hd then hd::(filter f tl) else filter f tl private let rec filter_map_acc (f:'a -> Tac (option 'b)) (acc:list 'b) (l:list 'a) : Tac (list 'b) = match l with | [] -> rev acc | hd :: tl -> match f hd with | Some hd -> filter_map_acc f (hd :: acc) tl | None -> filter_map_acc f acc tl let filter_map (f:'a -> Tac (option 'b)) (l:list 'a) : Tac (list 'b) = filter_map_acc f [] l
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.Util.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: 'a -> FStar.Tactics.Effect.Tac (FStar.Pervasives.Native.option 'b)) -> l: Prims.list 'a -> FStar.Tactics.Effect.Tac (FStar.Pervasives.Native.option 'b)
FStar.Tactics.Effect.Tac
[]
[]
[ "FStar.Pervasives.Native.option", "Prims.list", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.Some", "FStar.Tactics.Util.tryPick" ]
[ "recursion" ]
false
true
false
false
false
let rec tryPick f l =
match l with | [] -> None | hd :: tl -> match f hd with | Some x -> Some x | None -> tryPick f tl
false
FStar.Tactics.Util.fst
FStar.Tactics.Util.fold_left2
val fold_left2 (#a #b #c: Type) (f: (a -> b -> c -> Tac a)) (x: a) (l1: list b) (l2: list c) : TacH a (requires fun _ -> length l1 == length l2) (ensures fun _ _ -> True)
val fold_left2 (#a #b #c: Type) (f: (a -> b -> c -> Tac a)) (x: a) (l1: list b) (l2: list c) : TacH a (requires fun _ -> length l1 == length l2) (ensures fun _ _ -> True)
let rec fold_left2 (#a #b #c:Type) (f:a -> b -> c -> Tac a) (x:a) (l1:list b) (l2:list c) : TacH a (requires fun _ -> length l1 == length l2) (ensures fun _ _ -> True) = match l1, l2 with | [], [] -> x | hd1::tl1, hd2::tl2 -> fold_left2 f (f x hd1 hd2) tl1 tl2
{ "file_name": "ulib/FStar.Tactics.Util.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 38, "end_line": 117, "start_col": 0, "start_line": 110 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.Util open FStar.Tactics.Effect open FStar.List.Tot.Base (* Tac list functions, since there's no effect polymorphism *) val map: ('a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec map f x = match x with | [] -> [] | a::tl -> f a::map f tl val __mapi: nat -> (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec __mapi i f x = match x with | [] -> [] | a::tl -> f i a::__mapi (i+1) f tl val mapi: (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b) let mapi f l = __mapi 0 f l val iter : ('a -> Tac unit) -> list 'a -> Tac unit let rec iter f x = match x with | [] -> () | a::tl -> f a; iter f tl val iteri_aux: int -> (int -> 'a -> Tac unit) -> list 'a -> Tac unit let rec iteri_aux i f x = match x with | [] -> () | a::tl -> f i a; iteri_aux (i+1) f tl val iteri: (int -> 'a -> Tac unit) -> list 'a -> Tac unit let iteri f x = iteri_aux 0 f x val fold_left: ('a -> 'b -> Tac 'a) -> 'a -> l:list 'b -> Tac 'a let rec fold_left f x l = match l with | [] -> x | hd::tl -> fold_left f (f x hd) tl val fold_right: ('a -> 'b -> Tac 'b) -> list 'a -> 'b -> Tac 'b let rec fold_right f l x = match l with | [] -> x | hd::tl -> f hd (fold_right f tl x) (* There's no unconditionally total zip like this in Tot.Base, why? Anyway use this *) val zip : (#a:Type) -> (#b:Type) -> list a -> list b -> Tac (list (a * b)) let rec zip #a #b l1 l2 = match l1, l2 with | x::xs, y::ys -> (x,y) :: (zip xs ys) | _ -> [] val filter: ('a -> Tac bool) -> list 'a -> Tac (list 'a) let rec filter f = function | [] -> [] | hd::tl -> if f hd then hd::(filter f tl) else filter f tl private let rec filter_map_acc (f:'a -> Tac (option 'b)) (acc:list 'b) (l:list 'a) : Tac (list 'b) = match l with | [] -> rev acc | hd :: tl -> match f hd with | Some hd -> filter_map_acc f (hd :: acc) tl | None -> filter_map_acc f acc tl let filter_map (f:'a -> Tac (option 'b)) (l:list 'a) : Tac (list 'b) = filter_map_acc f [] l val tryPick: ('a -> Tac (option 'b)) -> list 'a -> Tac (option 'b) let rec tryPick f l = match l with | [] -> None | hd::tl -> match f hd with | Some x -> Some x | None -> tryPick f tl let map_opt (f:'a -> Tac 'b) (x:option 'a) : Tac (option 'b) = match x with | None -> None | Some x -> Some (f x) (** Apply a given tactic [t] repeatedly [n] times and return the results. *) let rec repeatn (#a:Type) (n : int) (t : unit -> Tac a) : Tac (l:list a{n < 0 \/ length l == n}) = if n <= 0 then [] else t () :: repeatn (n - 1) t let rec tryFind (#a:Type) (f:a -> Tac bool) (l:list a) : Tac bool = match l with | [] -> false | hd::tl -> if f hd then true else tryFind f tl
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.Util.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: a -> _: b -> _: c -> FStar.Tactics.Effect.Tac a) -> x: a -> l1: Prims.list b -> l2: Prims.list c -> FStar.Tactics.Effect.TacH a
FStar.Tactics.Effect.TacH
[]
[]
[ "Prims.list", "FStar.Pervasives.Native.Mktuple2", "FStar.Tactics.Util.fold_left2", "FStar.Stubs.Tactics.Types.proofstate", "Prims.eq2", "Prims.nat", "FStar.List.Tot.Base.length", "FStar.Stubs.Tactics.Result.__result", "Prims.l_True" ]
[ "recursion" ]
false
true
false
false
false
let rec fold_left2 (#a #b #c: Type) (f: (a -> b -> c -> Tac a)) (x: a) (l1: list b) (l2: list c) : TacH a (requires fun _ -> length l1 == length l2) (ensures fun _ _ -> True) =
match l1, l2 with | [], [] -> x | hd1 :: tl1, hd2 :: tl2 -> fold_left2 f (f x hd1 hd2) tl1 tl2
false
FStar.Tactics.Util.fst
FStar.Tactics.Util.string_of_list
val string_of_list (#a: _) (f: (a -> Tac string)) (l: list a) : Tac string
val string_of_list (#a: _) (f: (a -> Tac string)) (l: list a) : Tac string
let rec string_of_list #a (f : a -> Tac string) (l : list a) : Tac string = match l with | [] -> "" | x::xs -> f x ^ ";" ^ string_of_list f xs
{ "file_name": "ulib/FStar.Tactics.Util.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 44, "end_line": 122, "start_col": 0, "start_line": 119 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.Util open FStar.Tactics.Effect open FStar.List.Tot.Base (* Tac list functions, since there's no effect polymorphism *) val map: ('a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec map f x = match x with | [] -> [] | a::tl -> f a::map f tl val __mapi: nat -> (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec __mapi i f x = match x with | [] -> [] | a::tl -> f i a::__mapi (i+1) f tl val mapi: (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b) let mapi f l = __mapi 0 f l val iter : ('a -> Tac unit) -> list 'a -> Tac unit let rec iter f x = match x with | [] -> () | a::tl -> f a; iter f tl val iteri_aux: int -> (int -> 'a -> Tac unit) -> list 'a -> Tac unit let rec iteri_aux i f x = match x with | [] -> () | a::tl -> f i a; iteri_aux (i+1) f tl val iteri: (int -> 'a -> Tac unit) -> list 'a -> Tac unit let iteri f x = iteri_aux 0 f x val fold_left: ('a -> 'b -> Tac 'a) -> 'a -> l:list 'b -> Tac 'a let rec fold_left f x l = match l with | [] -> x | hd::tl -> fold_left f (f x hd) tl val fold_right: ('a -> 'b -> Tac 'b) -> list 'a -> 'b -> Tac 'b let rec fold_right f l x = match l with | [] -> x | hd::tl -> f hd (fold_right f tl x) (* There's no unconditionally total zip like this in Tot.Base, why? Anyway use this *) val zip : (#a:Type) -> (#b:Type) -> list a -> list b -> Tac (list (a * b)) let rec zip #a #b l1 l2 = match l1, l2 with | x::xs, y::ys -> (x,y) :: (zip xs ys) | _ -> [] val filter: ('a -> Tac bool) -> list 'a -> Tac (list 'a) let rec filter f = function | [] -> [] | hd::tl -> if f hd then hd::(filter f tl) else filter f tl private let rec filter_map_acc (f:'a -> Tac (option 'b)) (acc:list 'b) (l:list 'a) : Tac (list 'b) = match l with | [] -> rev acc | hd :: tl -> match f hd with | Some hd -> filter_map_acc f (hd :: acc) tl | None -> filter_map_acc f acc tl let filter_map (f:'a -> Tac (option 'b)) (l:list 'a) : Tac (list 'b) = filter_map_acc f [] l val tryPick: ('a -> Tac (option 'b)) -> list 'a -> Tac (option 'b) let rec tryPick f l = match l with | [] -> None | hd::tl -> match f hd with | Some x -> Some x | None -> tryPick f tl let map_opt (f:'a -> Tac 'b) (x:option 'a) : Tac (option 'b) = match x with | None -> None | Some x -> Some (f x) (** Apply a given tactic [t] repeatedly [n] times and return the results. *) let rec repeatn (#a:Type) (n : int) (t : unit -> Tac a) : Tac (l:list a{n < 0 \/ length l == n}) = if n <= 0 then [] else t () :: repeatn (n - 1) t let rec tryFind (#a:Type) (f:a -> Tac bool) (l:list a) : Tac bool = match l with | [] -> false | hd::tl -> if f hd then true else tryFind f tl let rec fold_left2 (#a #b #c:Type) (f:a -> b -> c -> Tac a) (x:a) (l1:list b) (l2:list c) : TacH a (requires fun _ -> length l1 == length l2) (ensures fun _ _ -> True) = match l1, l2 with | [], [] -> x | hd1::tl1, hd2::tl2 -> fold_left2 f (f x hd1 hd2) tl1 tl2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.Util.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: a -> FStar.Tactics.Effect.Tac Prims.string) -> l: Prims.list a -> FStar.Tactics.Effect.Tac Prims.string
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.string", "Prims.list", "Prims.op_Hat", "FStar.Tactics.Util.string_of_list" ]
[ "recursion" ]
false
true
false
false
false
let rec string_of_list #a (f: (a -> Tac string)) (l: list a) : Tac string =
match l with | [] -> "" | x :: xs -> f x ^ ";" ^ string_of_list f xs
false
FStar.Tactics.Util.fst
FStar.Tactics.Util.tryFind
val tryFind (#a: Type) (f: (a -> Tac bool)) (l: list a) : Tac bool
val tryFind (#a: Type) (f: (a -> Tac bool)) (l: list a) : Tac bool
let rec tryFind (#a:Type) (f:a -> Tac bool) (l:list a) : Tac bool = match l with | [] -> false | hd::tl -> if f hd then true else tryFind f tl
{ "file_name": "ulib/FStar.Tactics.Util.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 21, "end_line": 108, "start_col": 0, "start_line": 103 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.Util open FStar.Tactics.Effect open FStar.List.Tot.Base (* Tac list functions, since there's no effect polymorphism *) val map: ('a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec map f x = match x with | [] -> [] | a::tl -> f a::map f tl val __mapi: nat -> (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec __mapi i f x = match x with | [] -> [] | a::tl -> f i a::__mapi (i+1) f tl val mapi: (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b) let mapi f l = __mapi 0 f l val iter : ('a -> Tac unit) -> list 'a -> Tac unit let rec iter f x = match x with | [] -> () | a::tl -> f a; iter f tl val iteri_aux: int -> (int -> 'a -> Tac unit) -> list 'a -> Tac unit let rec iteri_aux i f x = match x with | [] -> () | a::tl -> f i a; iteri_aux (i+1) f tl val iteri: (int -> 'a -> Tac unit) -> list 'a -> Tac unit let iteri f x = iteri_aux 0 f x val fold_left: ('a -> 'b -> Tac 'a) -> 'a -> l:list 'b -> Tac 'a let rec fold_left f x l = match l with | [] -> x | hd::tl -> fold_left f (f x hd) tl val fold_right: ('a -> 'b -> Tac 'b) -> list 'a -> 'b -> Tac 'b let rec fold_right f l x = match l with | [] -> x | hd::tl -> f hd (fold_right f tl x) (* There's no unconditionally total zip like this in Tot.Base, why? Anyway use this *) val zip : (#a:Type) -> (#b:Type) -> list a -> list b -> Tac (list (a * b)) let rec zip #a #b l1 l2 = match l1, l2 with | x::xs, y::ys -> (x,y) :: (zip xs ys) | _ -> [] val filter: ('a -> Tac bool) -> list 'a -> Tac (list 'a) let rec filter f = function | [] -> [] | hd::tl -> if f hd then hd::(filter f tl) else filter f tl private let rec filter_map_acc (f:'a -> Tac (option 'b)) (acc:list 'b) (l:list 'a) : Tac (list 'b) = match l with | [] -> rev acc | hd :: tl -> match f hd with | Some hd -> filter_map_acc f (hd :: acc) tl | None -> filter_map_acc f acc tl let filter_map (f:'a -> Tac (option 'b)) (l:list 'a) : Tac (list 'b) = filter_map_acc f [] l val tryPick: ('a -> Tac (option 'b)) -> list 'a -> Tac (option 'b) let rec tryPick f l = match l with | [] -> None | hd::tl -> match f hd with | Some x -> Some x | None -> tryPick f tl let map_opt (f:'a -> Tac 'b) (x:option 'a) : Tac (option 'b) = match x with | None -> None | Some x -> Some (f x) (** Apply a given tactic [t] repeatedly [n] times and return the results. *) let rec repeatn (#a:Type) (n : int) (t : unit -> Tac a) : Tac (l:list a{n < 0 \/ length l == n}) = if n <= 0 then [] else t () :: repeatn (n - 1) t
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.Util.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: a -> FStar.Tactics.Effect.Tac Prims.bool) -> l: Prims.list a -> FStar.Tactics.Effect.Tac Prims.bool
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.bool", "Prims.list", "FStar.Tactics.Util.tryFind" ]
[ "recursion" ]
false
true
false
false
false
let rec tryFind (#a: Type) (f: (a -> Tac bool)) (l: list a) : Tac bool =
match l with | [] -> false | hd :: tl -> if f hd then true else tryFind f tl
false
FStar.Tactics.Util.fst
FStar.Tactics.Util.filter
val filter: ('a -> Tac bool) -> list 'a -> Tac (list 'a)
val filter: ('a -> Tac bool) -> list 'a -> Tac (list 'a)
let rec filter f = function | [] -> [] | hd::tl -> if f hd then hd::(filter f tl) else filter f tl
{ "file_name": "ulib/FStar.Tactics.Util.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 61, "end_line": 67, "start_col": 0, "start_line": 65 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Tactics.Util open FStar.Tactics.Effect open FStar.List.Tot.Base (* Tac list functions, since there's no effect polymorphism *) val map: ('a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec map f x = match x with | [] -> [] | a::tl -> f a::map f tl val __mapi: nat -> (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b) let rec __mapi i f x = match x with | [] -> [] | a::tl -> f i a::__mapi (i+1) f tl val mapi: (nat -> 'a -> Tac 'b) -> list 'a -> Tac (list 'b) let mapi f l = __mapi 0 f l val iter : ('a -> Tac unit) -> list 'a -> Tac unit let rec iter f x = match x with | [] -> () | a::tl -> f a; iter f tl val iteri_aux: int -> (int -> 'a -> Tac unit) -> list 'a -> Tac unit let rec iteri_aux i f x = match x with | [] -> () | a::tl -> f i a; iteri_aux (i+1) f tl val iteri: (int -> 'a -> Tac unit) -> list 'a -> Tac unit let iteri f x = iteri_aux 0 f x val fold_left: ('a -> 'b -> Tac 'a) -> 'a -> l:list 'b -> Tac 'a let rec fold_left f x l = match l with | [] -> x | hd::tl -> fold_left f (f x hd) tl val fold_right: ('a -> 'b -> Tac 'b) -> list 'a -> 'b -> Tac 'b let rec fold_right f l x = match l with | [] -> x | hd::tl -> f hd (fold_right f tl x) (* There's no unconditionally total zip like this in Tot.Base, why? Anyway use this *) val zip : (#a:Type) -> (#b:Type) -> list a -> list b -> Tac (list (a * b)) let rec zip #a #b l1 l2 = match l1, l2 with | x::xs, y::ys -> (x,y) :: (zip xs ys) | _ -> []
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.Tactics.Util.fst" }
[ { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Effect", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: 'a -> FStar.Tactics.Effect.Tac Prims.bool) -> _: Prims.list 'a -> FStar.Tactics.Effect.Tac (Prims.list 'a)
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.bool", "Prims.list", "Prims.Nil", "Prims.Cons", "FStar.Tactics.Util.filter" ]
[ "recursion" ]
false
true
false
false
false
let rec filter f =
function | [] -> [] | hd :: tl -> if f hd then hd :: (filter f tl) else filter f tl
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.bn_add
val bn_add:BN.bn_add_st U64
val bn_add:BN.bn_add_st U64
let bn_add : BN.bn_add_st U64 = BN.bn_add
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 41, "end_line": 31, "start_col": 0, "start_line": 31 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Bignum.bn_add_st Lib.IntTypes.U64
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.bn_add", "Lib.IntTypes.U64" ]
[]
false
false
false
true
false
let bn_add:BN.bn_add_st U64 =
BN.bn_add
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.add4
val add4:BN.bn_add_eq_len_st U64 qnlimb
val add4:BN.bn_add_eq_len_st U64 qnlimb
let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 25, "end_line": 37, "start_col": 0, "start_line": 36 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Bignum.bn_add_eq_len_st Lib.IntTypes.U64 Hacl.K256.Scalar.qnlimb
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.bn_add_eq_len", "Lib.IntTypes.U64", "Hacl.K256.Scalar.qnlimb" ]
[]
false
false
false
true
false
let add4:BN.bn_add_eq_len_st U64 qnlimb =
BN.bn_add_eq_len qnlimb
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.sub4
val sub4:BN.bn_sub_eq_len_st U64 qnlimb
val sub4:BN.bn_sub_eq_len_st U64 qnlimb
let sub4: BN.bn_sub_eq_len_st U64 qnlimb = BN.bn_sub_eq_len qnlimb
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 25, "end_line": 40, "start_col": 0, "start_line": 39 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Bignum.bn_sub_eq_len_st Lib.IntTypes.U64 Hacl.K256.Scalar.qnlimb
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.bn_sub_eq_len", "Lib.IntTypes.U64", "Hacl.K256.Scalar.qnlimb" ]
[]
false
false
false
true
false
let sub4:BN.bn_sub_eq_len_st U64 qnlimb =
BN.bn_sub_eq_len qnlimb
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.is_qelem_zero
val is_qelem_zero (f:qelem) : Stack uint64 (requires fun h -> live h f) (ensures fun h0 m h1 -> modifies0 h0 h1 /\ (v m = 0 \/ v m = ones_v U64) /\ v m == (if qas_nat h0 f = 0 then ones_v U64 else 0))
val is_qelem_zero (f:qelem) : Stack uint64 (requires fun h -> live h f) (ensures fun h0 m h1 -> modifies0 h0 h1 /\ (v m = 0 \/ v m = ones_v U64) /\ v m == (if qas_nat h0 f = 0 then ones_v U64 else 0))
let is_qelem_zero f = let h0 = ST.get () in SN.bn_is_zero_mask_lemma (as_seq h0 f); BN.bn_is_zero_mask qnlimb f
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 29, "end_line": 107, "start_col": 0, "start_line": 104 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb let sub4: BN.bn_sub_eq_len_st U64 qnlimb = BN.bn_sub_eq_len qnlimb let add_mod4: BN.bn_add_mod_n_st U64 qnlimb = BN.bn_add_mod_n qnlimb let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb = BN.bn_sub_mod_n qnlimb let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a = BN.bn_mul qnlimb qnlimb a let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a = BN.bn_sqr qnlimb a inline_for_extraction noextract instance kn: BN.bn U64 = { BN.len = qnlimb; BN.add = add4; BN.sub = sub4; BN.add_mod_n = add_mod4; BN.sub_mod_n = sub_mod4; BN.mul = mul4; BN.sqr = sqr4 } let make_u64_4 out (f0, f1, f2, f3) = out.(0ul) <- f0; out.(1ul) <- f1; out.(2ul) <- f2; out.(3ul) <- f3; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h out); assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3)) let make_order_k256 () = [@inline_let] let r = (u64 0xbfd25e8cd0364141, u64 0xbaaedce6af48a03b, u64 0xfffffffffffffffe, u64 0xffffffffffffffff) in assert_norm (qas_nat4 r = S.q); r let create_qelem () = SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb); create qnlimb (u64 0) let create_one () = [@inline_let] let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in assert_norm (FStar.List.Tot.length l = 4); Seq.elim_of_list l; LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l); KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)); createL l
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: Hacl.K256.Scalar.qelem -> FStar.HyperStack.ST.Stack Lib.IntTypes.uint64
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.K256.Scalar.qelem", "Hacl.Bignum.bn_is_zero_mask", "Lib.IntTypes.U64", "Hacl.K256.Scalar.qnlimb", "Hacl.Bignum.Definitions.limb", "Prims.unit", "Hacl.Spec.Bignum.bn_is_zero_mask_lemma", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get" ]
[]
false
true
false
false
false
let is_qelem_zero f =
let h0 = ST.get () in SN.bn_is_zero_mask_lemma (as_seq h0 f); BN.bn_is_zero_mask qnlimb f
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.add_mod4
val add_mod4:BN.bn_add_mod_n_st U64 qnlimb
val add_mod4:BN.bn_add_mod_n_st U64 qnlimb
let add_mod4: BN.bn_add_mod_n_st U64 qnlimb = BN.bn_add_mod_n qnlimb
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 24, "end_line": 43, "start_col": 0, "start_line": 42 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb let sub4: BN.bn_sub_eq_len_st U64 qnlimb = BN.bn_sub_eq_len qnlimb
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Bignum.bn_add_mod_n_st Lib.IntTypes.U64 Hacl.K256.Scalar.qnlimb
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.bn_add_mod_n", "Lib.IntTypes.U64", "Hacl.K256.Scalar.qnlimb" ]
[]
false
false
false
true
false
let add_mod4:BN.bn_add_mod_n_st U64 qnlimb =
BN.bn_add_mod_n qnlimb
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.make_order_k256
val make_order_k256: unit -> Pure qelem4 (requires True) (ensures fun r -> qas_nat4 r = S.q)
val make_order_k256: unit -> Pure qelem4 (requires True) (ensures fun r -> qas_nat4 r = S.q)
let make_order_k256 () = [@inline_let] let r = (u64 0xbfd25e8cd0364141, u64 0xbaaedce6af48a03b, u64 0xfffffffffffffffe, u64 0xffffffffffffffff) in assert_norm (qas_nat4 r = S.q); r
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 85, "start_col": 0, "start_line": 76 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb let sub4: BN.bn_sub_eq_len_st U64 qnlimb = BN.bn_sub_eq_len qnlimb let add_mod4: BN.bn_add_mod_n_st U64 qnlimb = BN.bn_add_mod_n qnlimb let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb = BN.bn_sub_mod_n qnlimb let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a = BN.bn_mul qnlimb qnlimb a let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a = BN.bn_sqr qnlimb a inline_for_extraction noextract instance kn: BN.bn U64 = { BN.len = qnlimb; BN.add = add4; BN.sub = sub4; BN.add_mod_n = add_mod4; BN.sub_mod_n = sub_mod4; BN.mul = mul4; BN.sqr = sqr4 } let make_u64_4 out (f0, f1, f2, f3) = out.(0ul) <- f0; out.(1ul) <- f1; out.(2ul) <- f2; out.(3ul) <- f3; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h out); assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3))
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> Prims.Pure Hacl.Spec.K256.Scalar.qelem4
Prims.Pure
[]
[]
[ "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Hacl.Spec.K256.Scalar.qas_nat4", "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" ]
[]
false
false
false
false
false
let make_order_k256 () =
[@@ inline_let ]let r = (u64 0xbfd25e8cd0364141, u64 0xbaaedce6af48a03b, u64 0xfffffffffffffffe, u64 0xffffffffffffffff) in assert_norm (qas_nat4 r = S.q); r
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.load_qelem
val load_qelem: f:qelem -> b:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h f /\ live h b /\ disjoint f b) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ qas_nat h1 f == BSeq.nat_from_bytes_be (as_seq h0 b))
val load_qelem: f:qelem -> b:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h f /\ live h b /\ disjoint f b) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ qas_nat h1 f == BSeq.nat_from_bytes_be (as_seq h0 b))
let load_qelem f b = let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b); Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 55, "end_line": 135, "start_col": 0, "start_line": 132 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb let sub4: BN.bn_sub_eq_len_st U64 qnlimb = BN.bn_sub_eq_len qnlimb let add_mod4: BN.bn_add_mod_n_st U64 qnlimb = BN.bn_add_mod_n qnlimb let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb = BN.bn_sub_mod_n qnlimb let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a = BN.bn_mul qnlimb qnlimb a let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a = BN.bn_sqr qnlimb a inline_for_extraction noextract instance kn: BN.bn U64 = { BN.len = qnlimb; BN.add = add4; BN.sub = sub4; BN.add_mod_n = add_mod4; BN.sub_mod_n = sub_mod4; BN.mul = mul4; BN.sqr = sqr4 } let make_u64_4 out (f0, f1, f2, f3) = out.(0ul) <- f0; out.(1ul) <- f1; out.(2ul) <- f2; out.(3ul) <- f3; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h out); assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3)) let make_order_k256 () = [@inline_let] let r = (u64 0xbfd25e8cd0364141, u64 0xbaaedce6af48a03b, u64 0xfffffffffffffffe, u64 0xffffffffffffffff) in assert_norm (qas_nat4 r = S.q); r let create_qelem () = SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb); create qnlimb (u64 0) let create_one () = [@inline_let] let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in assert_norm (FStar.List.Tot.length l = 4); Seq.elim_of_list l; LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l); KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)); createL l [@CInline] let is_qelem_zero f = let h0 = ST.get () in SN.bn_is_zero_mask_lemma (as_seq h0 f); BN.bn_is_zero_mask qnlimb f [@CInline] let is_qelem_zero_vartime f = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3); is_qelem_zero_vartime4 (f0,f1,f2,f3) [@CInline] let is_qelem_eq_vartime f1 f2 = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f1); KL.qas_nat4_is_qas_nat (as_seq h f2); let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3); is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3)
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: Hacl.K256.Scalar.qelem -> b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.K256.Scalar.qelem", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Hacl.Bignum.Convert.mk_bn_from_bytes_be", "Lib.IntTypes.U64", "Prims.unit", "Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get" ]
[]
false
true
false
false
false
let load_qelem f b =
let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b); Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.kn
[@@ FStar.Tactics.Typeclasses.tcinstance] val kn:BN.bn U64
[@@ FStar.Tactics.Typeclasses.tcinstance] val kn:BN.bn U64
instance kn: BN.bn U64 = { BN.len = qnlimb; BN.add = add4; BN.sub = sub4; BN.add_mod_n = add_mod4; BN.sub_mod_n = sub_mod4; BN.mul = mul4; BN.sqr = sqr4 }
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 1, "end_line": 63, "start_col": 0, "start_line": 55 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb let sub4: BN.bn_sub_eq_len_st U64 qnlimb = BN.bn_sub_eq_len qnlimb let add_mod4: BN.bn_add_mod_n_st U64 qnlimb = BN.bn_add_mod_n qnlimb let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb = BN.bn_sub_mod_n qnlimb let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a = BN.bn_mul qnlimb qnlimb a let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a = BN.bn_sqr qnlimb a
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Bignum.bn Lib.IntTypes.U64
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Mkbn", "Lib.IntTypes.U64", "Hacl.K256.Scalar.qnlimb", "Hacl.K256.Scalar.add4", "Hacl.K256.Scalar.sub4", "Hacl.K256.Scalar.add_mod4", "Hacl.K256.Scalar.sub_mod4", "Hacl.K256.Scalar.mul4", "Hacl.K256.Scalar.sqr4" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let kn:BN.bn U64 =
{ BN.len = qnlimb; BN.add = add4; BN.sub = sub4; BN.add_mod_n = add_mod4; BN.sub_mod_n = sub_mod4; BN.mul = mul4; BN.sqr = sqr4 }
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.is_qelem_zero_vartime
val is_qelem_zero_vartime (f:qelem) : Stack bool (requires fun h -> live h f) (ensures fun h0 m h1 -> modifies0 h0 h1 /\ m == (qas_nat h0 f = 0))
val is_qelem_zero_vartime (f:qelem) : Stack bool (requires fun h -> live h f) (ensures fun h0 m h1 -> modifies0 h0 h1 /\ m == (qas_nat h0 f = 0))
let is_qelem_zero_vartime f = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3); is_qelem_zero_vartime4 (f0,f1,f2,f3)
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 38, "end_line": 117, "start_col": 0, "start_line": 111 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb let sub4: BN.bn_sub_eq_len_st U64 qnlimb = BN.bn_sub_eq_len qnlimb let add_mod4: BN.bn_add_mod_n_st U64 qnlimb = BN.bn_add_mod_n qnlimb let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb = BN.bn_sub_mod_n qnlimb let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a = BN.bn_mul qnlimb qnlimb a let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a = BN.bn_sqr qnlimb a inline_for_extraction noextract instance kn: BN.bn U64 = { BN.len = qnlimb; BN.add = add4; BN.sub = sub4; BN.add_mod_n = add_mod4; BN.sub_mod_n = sub_mod4; BN.mul = mul4; BN.sqr = sqr4 } let make_u64_4 out (f0, f1, f2, f3) = out.(0ul) <- f0; out.(1ul) <- f1; out.(2ul) <- f2; out.(3ul) <- f3; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h out); assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3)) let make_order_k256 () = [@inline_let] let r = (u64 0xbfd25e8cd0364141, u64 0xbaaedce6af48a03b, u64 0xfffffffffffffffe, u64 0xffffffffffffffff) in assert_norm (qas_nat4 r = S.q); r let create_qelem () = SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb); create qnlimb (u64 0) let create_one () = [@inline_let] let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in assert_norm (FStar.List.Tot.length l = 4); Seq.elim_of_list l; LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l); KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)); createL l [@CInline] let is_qelem_zero f = let h0 = ST.get () in SN.bn_is_zero_mask_lemma (as_seq h0 f); BN.bn_is_zero_mask qnlimb f
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: Hacl.K256.Scalar.qelem -> FStar.HyperStack.ST.Stack Prims.bool
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.K256.Scalar.qelem", "Lib.IntTypes.uint64", "Hacl.Spec.K256.Scalar.is_qelem_zero_vartime4", "FStar.Pervasives.Native.Mktuple4", "Prims.unit", "Hacl.Spec.K256.Scalar.Lemmas.is_qelem_zero_vartime4_lemma", "Prims.bool", "FStar.Pervasives.Native.tuple4", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT", "Hacl.K256.Scalar.qnlimb", "FStar.UInt32.__uint_to_t", "Hacl.Spec.K256.Scalar.Lemmas.qas_nat4_is_qas_nat", "Lib.Buffer.as_seq", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get" ]
[]
false
true
false
false
false
let is_qelem_zero_vartime f =
let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let f0, f1, f2, f3 = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in KL.is_qelem_zero_vartime4_lemma (f0, f1, f2, f3); is_qelem_zero_vartime4 (f0, f1, f2, f3)
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.mul4
val mul4 (a: BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a
val mul4 (a: BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a
let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a = BN.bn_mul qnlimb qnlimb a
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 27, "end_line": 49, "start_col": 0, "start_line": 48 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb let sub4: BN.bn_sub_eq_len_st U64 qnlimb = BN.bn_sub_eq_len qnlimb let add_mod4: BN.bn_add_mod_n_st U64 qnlimb = BN.bn_add_mod_n qnlimb let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb = BN.bn_sub_mod_n qnlimb
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Hacl.Bignum.Definitions.lbignum Lib.IntTypes.U64 Hacl.K256.Scalar.qnlimb -> Hacl.Bignum.bn_karatsuba_mul_st Lib.IntTypes.U64 Hacl.K256.Scalar.qnlimb a
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.U64", "Hacl.K256.Scalar.qnlimb", "Hacl.Bignum.bn_mul", "Hacl.Bignum.bn_karatsuba_mul_st" ]
[]
false
false
false
false
false
let mul4 (a: BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a =
BN.bn_mul qnlimb qnlimb a
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.create_qelem
val create_qelem: unit -> StackInline qelem (requires fun h -> True) (ensures fun h0 f h1 -> stack_allocated f h0 h1 (LSeq.create (v qnlimb) (u64 0)) /\ qas_nat h1 f == 0)
val create_qelem: unit -> StackInline qelem (requires fun h -> True) (ensures fun h0 f h1 -> stack_allocated f h0 h1 (LSeq.create (v qnlimb) (u64 0)) /\ qas_nat h1 f == 0)
let create_qelem () = SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb); create qnlimb (u64 0)
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 23, "end_line": 90, "start_col": 0, "start_line": 88 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb let sub4: BN.bn_sub_eq_len_st U64 qnlimb = BN.bn_sub_eq_len qnlimb let add_mod4: BN.bn_add_mod_n_st U64 qnlimb = BN.bn_add_mod_n qnlimb let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb = BN.bn_sub_mod_n qnlimb let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a = BN.bn_mul qnlimb qnlimb a let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a = BN.bn_sqr qnlimb a inline_for_extraction noextract instance kn: BN.bn U64 = { BN.len = qnlimb; BN.add = add4; BN.sub = sub4; BN.add_mod_n = add_mod4; BN.sub_mod_n = sub_mod4; BN.mul = mul4; BN.sqr = sqr4 } let make_u64_4 out (f0, f1, f2, f3) = out.(0ul) <- f0; out.(1ul) <- f1; out.(2ul) <- f2; out.(3ul) <- f3; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h out); assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3)) let make_order_k256 () = [@inline_let] let r = (u64 0xbfd25e8cd0364141, u64 0xbaaedce6af48a03b, u64 0xfffffffffffffffe, u64 0xffffffffffffffff) in assert_norm (qas_nat4 r = S.q); r
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.HyperStack.ST.StackInline Hacl.K256.Scalar.qelem
FStar.HyperStack.ST.StackInline
[]
[]
[ "Prims.unit", "Lib.Buffer.create", "Lib.IntTypes.uint64", "Hacl.K256.Scalar.qnlimb", "Lib.IntTypes.u64", "Lib.Buffer.lbuffer", "Hacl.Spec.Bignum.Definitions.bn_eval_zeroes", "Lib.IntTypes.U64", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.K256.Scalar.qelem" ]
[]
false
true
false
false
false
let create_qelem () =
SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb); create qnlimb (u64 0)
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.sqr4
val sqr4 (a: BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a
val sqr4 (a: BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a
let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a = BN.bn_sqr qnlimb a
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 20, "end_line": 52, "start_col": 0, "start_line": 51 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb let sub4: BN.bn_sub_eq_len_st U64 qnlimb = BN.bn_sub_eq_len qnlimb let add_mod4: BN.bn_add_mod_n_st U64 qnlimb = BN.bn_add_mod_n qnlimb let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb = BN.bn_sub_mod_n qnlimb let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a = BN.bn_mul qnlimb qnlimb a
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Hacl.Bignum.Definitions.lbignum Lib.IntTypes.U64 Hacl.K256.Scalar.qnlimb -> Hacl.Bignum.bn_karatsuba_sqr_st Lib.IntTypes.U64 Hacl.K256.Scalar.qnlimb a
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.U64", "Hacl.K256.Scalar.qnlimb", "Hacl.Bignum.bn_sqr", "Hacl.Bignum.bn_karatsuba_sqr_st" ]
[]
false
false
false
false
false
let sqr4 (a: BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a =
BN.bn_sqr qnlimb a
false
Spec.Hash.Incremental.Definitions.fst
Spec.Hash.Incremental.Definitions.prev_length_t
val prev_length_t : a: Spec.Hash.Definitions.hash_alg -> Type0
let prev_length_t (a: hash_alg) = if is_keccak a then unit else n:nat { n % block_length a = 0 }
{ "file_name": "specs/lemmas/Spec.Hash.Incremental.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 36, "end_line": 24, "start_col": 0, "start_line": 20 }
module Spec.Hash.Incremental.Definitions module S = FStar.Seq module Blake2 = Spec.Blake2 open Spec.Agile.Hash open Spec.Hash.Definitions open Spec.Hash.MD open FStar.Mul open Lib.Sequence open Lib.ByteSequence open Lib.IntTypes module Loops = Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--fuel 0 --ifuel 0 --z3rlimit 50"
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.fst.checked", "Spec.Hash.MD.fst.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Blake2.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Spec.Hash.Incremental.Definitions.fst" }
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.MD", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Blake2" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "Spec.Hash.Incremental", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Incremental", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Hash.Definitions.hash_alg -> Type0
Prims.Tot
[ "total" ]
[]
[ "Spec.Hash.Definitions.hash_alg", "Spec.Hash.Definitions.is_keccak", "Prims.unit", "Prims.bool", "Prims.nat", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "Spec.Hash.Definitions.block_length" ]
[]
false
false
false
true
true
let prev_length_t (a: hash_alg) =
if is_keccak a then unit else n: nat{n % block_length a = 0}
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.is_qelem_eq_vartime
val is_qelem_eq_vartime (f1 f2:qelem) : Stack bool (requires fun h -> live h f1 /\ live h f2 /\ qe_lt_q h f1 /\ qe_lt_q h f2) (ensures fun h0 m h1 -> modifies0 h0 h1 /\ m == (qas_nat h0 f1 = qas_nat h0 f2))
val is_qelem_eq_vartime (f1 f2:qelem) : Stack bool (requires fun h -> live h f1 /\ live h f2 /\ qe_lt_q h f1 /\ qe_lt_q h f2) (ensures fun h0 m h1 -> modifies0 h0 h1 /\ m == (qas_nat h0 f1 = qas_nat h0 f2))
let is_qelem_eq_vartime f1 f2 = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f1); KL.qas_nat4_is_qas_nat (as_seq h f2); let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3); is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3)
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 50, "end_line": 129, "start_col": 0, "start_line": 121 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb let sub4: BN.bn_sub_eq_len_st U64 qnlimb = BN.bn_sub_eq_len qnlimb let add_mod4: BN.bn_add_mod_n_st U64 qnlimb = BN.bn_add_mod_n qnlimb let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb = BN.bn_sub_mod_n qnlimb let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a = BN.bn_mul qnlimb qnlimb a let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a = BN.bn_sqr qnlimb a inline_for_extraction noextract instance kn: BN.bn U64 = { BN.len = qnlimb; BN.add = add4; BN.sub = sub4; BN.add_mod_n = add_mod4; BN.sub_mod_n = sub_mod4; BN.mul = mul4; BN.sqr = sqr4 } let make_u64_4 out (f0, f1, f2, f3) = out.(0ul) <- f0; out.(1ul) <- f1; out.(2ul) <- f2; out.(3ul) <- f3; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h out); assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3)) let make_order_k256 () = [@inline_let] let r = (u64 0xbfd25e8cd0364141, u64 0xbaaedce6af48a03b, u64 0xfffffffffffffffe, u64 0xffffffffffffffff) in assert_norm (qas_nat4 r = S.q); r let create_qelem () = SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb); create qnlimb (u64 0) let create_one () = [@inline_let] let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in assert_norm (FStar.List.Tot.length l = 4); Seq.elim_of_list l; LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l); KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)); createL l [@CInline] let is_qelem_zero f = let h0 = ST.get () in SN.bn_is_zero_mask_lemma (as_seq h0 f); BN.bn_is_zero_mask qnlimb f [@CInline] let is_qelem_zero_vartime f = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3); is_qelem_zero_vartime4 (f0,f1,f2,f3)
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f1: Hacl.K256.Scalar.qelem -> f2: Hacl.K256.Scalar.qelem -> FStar.HyperStack.ST.Stack Prims.bool
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.K256.Scalar.qelem", "Lib.IntTypes.uint64", "Hacl.Spec.K256.Scalar.is_qelem_eq_vartime4", "FStar.Pervasives.Native.Mktuple4", "Prims.unit", "Hacl.Spec.K256.Scalar.Lemmas.is_qelem_eq_vartime4_lemma", "Prims.bool", "FStar.Pervasives.Native.tuple4", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT", "Hacl.K256.Scalar.qnlimb", "FStar.UInt32.__uint_to_t", "Hacl.Spec.K256.Scalar.Lemmas.qas_nat4_is_qas_nat", "Lib.Buffer.as_seq", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get" ]
[]
false
true
false
false
false
let is_qelem_eq_vartime f1 f2 =
let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f1); KL.qas_nat4_is_qas_nat (as_seq h f2); let a0, a1, a2, a3 = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in let b0, b1, b2, b3 = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in KL.is_qelem_eq_vartime4_lemma (a0, a1, a2, a3) (b0, b1, b2, b3); is_qelem_eq_vartime4 (a0, a1, a2, a3) (b0, b1, b2, b3)
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.is_qelem_lt_pow2_128_vartime
val is_qelem_lt_pow2_128_vartime: f:qelem -> Stack bool (requires fun h -> live h f) (ensures fun h0 b h1 -> modifies0 h0 h1 /\ b == (qas_nat h0 f < pow2 128))
val is_qelem_lt_pow2_128_vartime: f:qelem -> Stack bool (requires fun h -> live h f) (ensures fun h0 b h1 -> modifies0 h0 h1 /\ b == (qas_nat h0 f < pow2 128))
let is_qelem_lt_pow2_128_vartime f = let open Lib.RawIntTypes in let h0 = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h0 f); let f0 = Ghost.hide (LSeq.index (as_seq h0 f) 0) in let f1 = Ghost.hide (LSeq.index (as_seq h0 f) 1) in let f2 = f.(2ul) in let f3 = f.(3ul) in KL.is_qelem_lt_pow2_128_vartime4_lemma (Ghost.reveal f0, Ghost.reveal f1,f2,f3); u64_to_UInt64 f2 =. 0uL && u64_to_UInt64 f3 =. 0uL
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 52, "end_line": 379, "start_col": 0, "start_line": 370 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb let sub4: BN.bn_sub_eq_len_st U64 qnlimb = BN.bn_sub_eq_len qnlimb let add_mod4: BN.bn_add_mod_n_st U64 qnlimb = BN.bn_add_mod_n qnlimb let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb = BN.bn_sub_mod_n qnlimb let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a = BN.bn_mul qnlimb qnlimb a let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a = BN.bn_sqr qnlimb a inline_for_extraction noextract instance kn: BN.bn U64 = { BN.len = qnlimb; BN.add = add4; BN.sub = sub4; BN.add_mod_n = add_mod4; BN.sub_mod_n = sub_mod4; BN.mul = mul4; BN.sqr = sqr4 } let make_u64_4 out (f0, f1, f2, f3) = out.(0ul) <- f0; out.(1ul) <- f1; out.(2ul) <- f2; out.(3ul) <- f3; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h out); assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3)) let make_order_k256 () = [@inline_let] let r = (u64 0xbfd25e8cd0364141, u64 0xbaaedce6af48a03b, u64 0xfffffffffffffffe, u64 0xffffffffffffffff) in assert_norm (qas_nat4 r = S.q); r let create_qelem () = SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb); create qnlimb (u64 0) let create_one () = [@inline_let] let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in assert_norm (FStar.List.Tot.length l = 4); Seq.elim_of_list l; LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l); KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)); createL l [@CInline] let is_qelem_zero f = let h0 = ST.get () in SN.bn_is_zero_mask_lemma (as_seq h0 f); BN.bn_is_zero_mask qnlimb f [@CInline] let is_qelem_zero_vartime f = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3); is_qelem_zero_vartime4 (f0,f1,f2,f3) [@CInline] let is_qelem_eq_vartime f1 f2 = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f1); KL.qas_nat4_is_qas_nat (as_seq h f2); let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3); is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3) let load_qelem f b = let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b); Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f [@CInline] let load_qelem_check f b = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); load_qelem f b; let h0 = ST.get () in let is_zero = is_qelem_zero f in assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0)); let is_lt_q = BN.bn_lt_mask qnlimb f n in SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n); assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0)); let m = logand (lognot is_zero) is_lt_q in lognot_lemma is_zero; logand_lemma (lognot is_zero) is_lt_q; pop_frame (); m let load_qelem_conditional res b = push_frame (); let is_b_valid = load_qelem_check res b in let oneq = create_one () in let h0 = ST.get () in Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res; let h1 = ST.get () in assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res)); pop_frame (); is_b_valid [@CInline] let load_qelem_vartime f b = load_qelem f b; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let is_zero = is_qelem_zero_vartime f in let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in let is_lt_q_b = is_qelem_lt_q_vartime4 (a0,a1,a2,a3) in KL.is_qelem_lt_q_vartime4_lemma (a0,a1,a2,a3); not is_zero && is_lt_q_b val modq_short: out:qelem -> a:qelem -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == qas_nat h0 a % S.q) [@CInline] let modq_short out a = push_frame (); let tmp = create_qelem () in [@inline_let] let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in make_u64_4 tmp (t0,t1,t2,t3); let h0 = ST.get () in let c = kn.BN.add a tmp out in let mask = u64 0 -. c in map2T qnlimb out (BB.mask_select mask) out a; KL.mod_short_lseq_lemma (as_seq h0 a); pop_frame () [@CInline] let load_qelem_modq f b = push_frame (); let tmp = create_qelem () in load_qelem f b; copy tmp f; modq_short f tmp; pop_frame () [@CInline] let store_qelem b f = let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma #U64 32 (as_seq h0 f); Hacl.Bignum.Convert.mk_bn_to_bytes_be true 32ul f b [@CInline] let qadd out f1 f2 = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); let h0 = ST.get () in kn.BN.add_mod_n n f1 f2 out; SN.bn_add_mod_n_lemma (as_seq h0 n) (as_seq h0 f1) (as_seq h0 f2); pop_frame () val mul_pow2_256_minus_q_add: len:size_t -> resLen:size_t{2 + v len <= v resLen /\ 4 <= v resLen} -> t01:lbuffer uint64 2ul -> a:lbuffer uint64 len -> e:lbuffer uint64 4ul -> res:lbuffer uint64 resLen -> Stack (BB.carry U64) (requires fun h -> live h a /\ live h res /\ live h t01 /\ live h e /\ disjoint a res /\ disjoint a t01 /\ disjoint a e /\ disjoint res t01 /\ disjoint res e /\ disjoint t01 e /\ as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\ as_seq h res == LSeq.create (v resLen) (u64 0)) (ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\ (c, as_seq h1 res) == mul_pow2_256_minus_q_lseq_add (v len) (v resLen) (as_seq h0 a) (as_seq h0 e)) [@CInline] let mul_pow2_256_minus_q_add len resLen t01 a e res = push_frame (); let tmp = create (len +! 2ul) (u64 0) in BN.bn_mul len 2ul a t01 tmp; update_sub res 2ul len a; let _ = bn_add resLen res (len +! 2ul) tmp res in let c = bn_add resLen res 4ul e res in pop_frame (); c inline_for_extraction noextract val modq_before_final: t01:lbuffer uint64 2ul -> a:lbuffer uint64 (2ul *! qnlimb) -> out:qelem -> Stack (BB.carry U64) (requires fun h -> live h a /\ live h out /\ live h t01 /\ disjoint a out /\ disjoint a t01 /\ disjoint out t01 /\ as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\ as_seq h out == LSeq.create 4 (u64 0)) (ensures fun h0 c h1 -> modifies (loc out) h0 h1 /\ (c, as_seq h1 out) == mod_lseq_before_final (as_seq h0 a)) let modq_before_final t01 a out = push_frame (); let m = create 7ul (u64 0) in let p = create 5ul (u64 0) in let c0 = mul_pow2_256_minus_q_add 4ul 7ul t01 (sub a 4ul 4ul) (sub a 0ul 4ul) m in let c1 = mul_pow2_256_minus_q_add 3ul 5ul t01 (sub m 4ul 3ul) (sub m 0ul 4ul) p in let c2 = mul_pow2_256_minus_q_add 1ul 4ul t01 (sub p 4ul 1ul) (sub p 0ul 4ul) out in pop_frame (); c2 val modq: out:qelem -> a:lbuffer uint64 (2ul *! qnlimb) -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == BD.bn_v h0 a % S.q) [@CInline] let modq out a = push_frame (); let r = create_qelem () in let tmp = create_qelem () in [@inline_let] let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in make_u64_4 tmp (t0,t1,t2,t3); let t01 = sub tmp 0ul 2ul in let h0 = ST.get () in assert (Seq.equal (as_seq h0 t01) (LSeq.create2 t0 t1)); let c0 = modq_before_final t01 a r in let c1 = kn.BN.add r tmp out in let mask = u64 0 -. (c0 +. c1) in map2T qnlimb out (BB.mask_select mask) out r; let h1 = ST.get () in KL.mod_lseq_lemma (as_seq h0 a); pop_frame () [@CInline] let qmul out f1 f2 = push_frame (); let h0 = ST.get () in let tmp = create (2ul *! qnlimb) (u64 0) in kn.BN.mul f1 f2 tmp; SN.bn_mul_lemma (as_seq h0 f1) (as_seq h0 f2); modq out tmp; pop_frame () [@CInline] let qsqr out f = push_frame (); let h0 = ST.get () in let tmp = create (2ul *! qnlimb) (u64 0) in kn.BN.sqr f tmp; SN.bn_sqr_lemma (as_seq h0 f); modq out tmp; pop_frame () [@CInline] let qnegate_conditional_vartime f is_negate = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); let zero = create_qelem () in if is_negate then begin let h0 = ST.get () in kn.BN.sub_mod_n n zero f f; SN.bn_sub_mod_n_lemma (as_seq h0 n) (as_seq h0 zero) (as_seq h0 f); let h1 = ST.get () in assert (qas_nat h1 f = (0 - qas_nat h0 f) % S.q); Math.Lemmas.modulo_addition_lemma (- qas_nat h0 f) S.q 1; assert (qas_nat h1 f == (S.q - qas_nat h0 f) % S.q) end; pop_frame () [@CInline] let is_qelem_le_q_halved_vartime f = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in KL.is_qelem_le_q_halved_vartime4_lemma (a0,a1,a2,a3); is_qelem_le_q_halved_vartime4 (a0,a1,a2,a3)
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: Hacl.K256.Scalar.qelem -> FStar.HyperStack.ST.Stack Prims.bool
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.K256.Scalar.qelem", "Prims.op_AmpAmp", "Lib.IntTypes.op_Equals_Dot", "Lib.IntTypes.U64", "Lib.RawIntTypes.u64_to_UInt64", "FStar.UInt64.__uint_to_t", "Prims.unit", "Hacl.Spec.K256.Scalar.Lemmas.is_qelem_lt_pow2_128_vartime4_lemma", "FStar.Pervasives.Native.Mktuple4", "Lib.IntTypes.uint64", "FStar.Ghost.reveal", "Prims.bool", "Lib.IntTypes.int_t", "Lib.IntTypes.SEC", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT", "Hacl.K256.Scalar.qnlimb", "FStar.UInt32.__uint_to_t", "FStar.Ghost.erased", "FStar.Ghost.hide", "Lib.Sequence.index", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.as_seq", "Hacl.Spec.K256.Scalar.Lemmas.qas_nat4_is_qas_nat", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get" ]
[]
false
true
false
false
false
let is_qelem_lt_pow2_128_vartime f =
let open Lib.RawIntTypes in let h0 = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h0 f); let f0 = Ghost.hide (LSeq.index (as_seq h0 f) 0) in let f1 = Ghost.hide (LSeq.index (as_seq h0 f) 1) in let f2 = f.(2ul) in let f3 = f.(3ul) in KL.is_qelem_lt_pow2_128_vartime4_lemma (Ghost.reveal f0, Ghost.reveal f1, f2, f3); u64_to_UInt64 f2 =. 0uL && u64_to_UInt64 f3 =. 0uL
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.sub_mod4
val sub_mod4:BN.bn_sub_mod_n_st U64 qnlimb
val sub_mod4:BN.bn_sub_mod_n_st U64 qnlimb
let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb = BN.bn_sub_mod_n qnlimb
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 24, "end_line": 46, "start_col": 0, "start_line": 45 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb let sub4: BN.bn_sub_eq_len_st U64 qnlimb = BN.bn_sub_eq_len qnlimb let add_mod4: BN.bn_add_mod_n_st U64 qnlimb = BN.bn_add_mod_n qnlimb
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Bignum.bn_sub_mod_n_st Lib.IntTypes.U64 Hacl.K256.Scalar.qnlimb
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.bn_sub_mod_n", "Lib.IntTypes.U64", "Hacl.K256.Scalar.qnlimb" ]
[]
false
false
false
true
false
let sub_mod4:BN.bn_sub_mod_n_st U64 qnlimb =
BN.bn_sub_mod_n qnlimb
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.store_qelem
val store_qelem: b:lbuffer uint8 32ul -> f:qelem -> Stack unit (requires fun h -> live h b /\ live h f /\ disjoint f b /\ qe_lt_q h f) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == BSeq.nat_to_bytes_be 32 (qas_nat h0 f))
val store_qelem: b:lbuffer uint8 32ul -> f:qelem -> Stack unit (requires fun h -> live h b /\ live h f /\ disjoint f b /\ qe_lt_q h f) (ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\ as_seq h1 b == BSeq.nat_to_bytes_be 32 (qas_nat h0 f))
let store_qelem b f = let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma #U64 32 (as_seq h0 f); Hacl.Bignum.Convert.mk_bn_to_bytes_be true 32ul f b
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 53, "end_line": 219, "start_col": 0, "start_line": 216 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb let sub4: BN.bn_sub_eq_len_st U64 qnlimb = BN.bn_sub_eq_len qnlimb let add_mod4: BN.bn_add_mod_n_st U64 qnlimb = BN.bn_add_mod_n qnlimb let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb = BN.bn_sub_mod_n qnlimb let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a = BN.bn_mul qnlimb qnlimb a let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a = BN.bn_sqr qnlimb a inline_for_extraction noextract instance kn: BN.bn U64 = { BN.len = qnlimb; BN.add = add4; BN.sub = sub4; BN.add_mod_n = add_mod4; BN.sub_mod_n = sub_mod4; BN.mul = mul4; BN.sqr = sqr4 } let make_u64_4 out (f0, f1, f2, f3) = out.(0ul) <- f0; out.(1ul) <- f1; out.(2ul) <- f2; out.(3ul) <- f3; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h out); assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3)) let make_order_k256 () = [@inline_let] let r = (u64 0xbfd25e8cd0364141, u64 0xbaaedce6af48a03b, u64 0xfffffffffffffffe, u64 0xffffffffffffffff) in assert_norm (qas_nat4 r = S.q); r let create_qelem () = SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb); create qnlimb (u64 0) let create_one () = [@inline_let] let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in assert_norm (FStar.List.Tot.length l = 4); Seq.elim_of_list l; LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l); KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)); createL l [@CInline] let is_qelem_zero f = let h0 = ST.get () in SN.bn_is_zero_mask_lemma (as_seq h0 f); BN.bn_is_zero_mask qnlimb f [@CInline] let is_qelem_zero_vartime f = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3); is_qelem_zero_vartime4 (f0,f1,f2,f3) [@CInline] let is_qelem_eq_vartime f1 f2 = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f1); KL.qas_nat4_is_qas_nat (as_seq h f2); let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3); is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3) let load_qelem f b = let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b); Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f [@CInline] let load_qelem_check f b = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); load_qelem f b; let h0 = ST.get () in let is_zero = is_qelem_zero f in assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0)); let is_lt_q = BN.bn_lt_mask qnlimb f n in SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n); assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0)); let m = logand (lognot is_zero) is_lt_q in lognot_lemma is_zero; logand_lemma (lognot is_zero) is_lt_q; pop_frame (); m let load_qelem_conditional res b = push_frame (); let is_b_valid = load_qelem_check res b in let oneq = create_one () in let h0 = ST.get () in Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res; let h1 = ST.get () in assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res)); pop_frame (); is_b_valid [@CInline] let load_qelem_vartime f b = load_qelem f b; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let is_zero = is_qelem_zero_vartime f in let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in let is_lt_q_b = is_qelem_lt_q_vartime4 (a0,a1,a2,a3) in KL.is_qelem_lt_q_vartime4_lemma (a0,a1,a2,a3); not is_zero && is_lt_q_b val modq_short: out:qelem -> a:qelem -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == qas_nat h0 a % S.q) [@CInline] let modq_short out a = push_frame (); let tmp = create_qelem () in [@inline_let] let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in make_u64_4 tmp (t0,t1,t2,t3); let h0 = ST.get () in let c = kn.BN.add a tmp out in let mask = u64 0 -. c in map2T qnlimb out (BB.mask_select mask) out a; KL.mod_short_lseq_lemma (as_seq h0 a); pop_frame () [@CInline] let load_qelem_modq f b = push_frame (); let tmp = create_qelem () in load_qelem f b; copy tmp f; modq_short f tmp; pop_frame ()
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> f: Hacl.K256.Scalar.qelem -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Hacl.K256.Scalar.qelem", "Hacl.Bignum.Convert.mk_bn_to_bytes_be", "Lib.IntTypes.U64", "Prims.unit", "Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "Hacl.K256.Scalar.qnlimb", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get" ]
[]
false
true
false
false
false
let store_qelem b f =
let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma #U64 32 (as_seq h0 f); Hacl.Bignum.Convert.mk_bn_to_bytes_be true 32ul f b
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.create_one
val create_one: unit -> StackInline qelem (requires fun h -> True) (ensures fun h0 f h1 -> stack_allocated f h0 h1 (LSeq.create4 (u64 1) (u64 0) (u64 0) (u64 0)) /\ qas_nat h1 f = 1)
val create_one: unit -> StackInline qelem (requires fun h -> True) (ensures fun h0 f h1 -> stack_allocated f h0 h1 (LSeq.create4 (u64 1) (u64 0) (u64 0) (u64 0)) /\ qas_nat h1 f = 1)
let create_one () = [@inline_let] let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in assert_norm (FStar.List.Tot.length l = 4); Seq.elim_of_list l; LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l); KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)); createL l
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 11, "end_line": 100, "start_col": 0, "start_line": 93 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb let sub4: BN.bn_sub_eq_len_st U64 qnlimb = BN.bn_sub_eq_len qnlimb let add_mod4: BN.bn_add_mod_n_st U64 qnlimb = BN.bn_add_mod_n qnlimb let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb = BN.bn_sub_mod_n qnlimb let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a = BN.bn_mul qnlimb qnlimb a let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a = BN.bn_sqr qnlimb a inline_for_extraction noextract instance kn: BN.bn U64 = { BN.len = qnlimb; BN.add = add4; BN.sub = sub4; BN.add_mod_n = add_mod4; BN.sub_mod_n = sub_mod4; BN.mul = mul4; BN.sqr = sqr4 } let make_u64_4 out (f0, f1, f2, f3) = out.(0ul) <- f0; out.(1ul) <- f1; out.(2ul) <- f2; out.(3ul) <- f3; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h out); assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3)) let make_order_k256 () = [@inline_let] let r = (u64 0xbfd25e8cd0364141, u64 0xbaaedce6af48a03b, u64 0xfffffffffffffffe, u64 0xffffffffffffffff) in assert_norm (qas_nat4 r = S.q); r let create_qelem () = SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb); create qnlimb (u64 0)
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.HyperStack.ST.StackInline Hacl.K256.Scalar.qelem
FStar.HyperStack.ST.StackInline
[]
[]
[ "Prims.unit", "Lib.Buffer.createL", "Lib.IntTypes.uint64", "Lib.Buffer.lbuffer", "Lib.IntTypes.size", "FStar.Pervasives.normalize_term", "Lib.IntTypes.size_nat", "FStar.List.Tot.Base.length", "Hacl.Spec.K256.Scalar.Lemmas.qas_nat4_is_qas_nat", "Lib.Sequence.create4", "Lib.IntTypes.u64", "Hacl.K256.Scalar.qelem", "Lib.Sequence.eq_intro", "FStar.Seq.Base.seq_of_list", "FStar.Seq.Properties.elim_of_list", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.list", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.Cons", "Prims.Nil" ]
[]
false
true
false
false
false
let create_one () =
[@@ inline_let ]let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in assert_norm (FStar.List.Tot.length l = 4); Seq.elim_of_list l; LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l); KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)); createL l
false
Hacl.Streaming.Poly1305.fst
Hacl.Streaming.Poly1305.poly1305
val poly1305 (fs: field_spec) : I.block unit
val poly1305 (fs: field_spec) : I.block unit
let poly1305 (fs : field_spec) : I.block unit = I.Block I.Runtime (stateful_poly1305_ctx fs) (* state *) poly1305_key (* key *) unit (fun () -> 0xffffffffUL) (* max_input_len *) (fun () () -> 16) (* output_len *) (fun () -> 16ul) (* block_len *) (* blocks_state_len *) (fun () -> match fs with | M32 -> 16ul // block_length | M128 -> 32ul // 2 * block_length | M256 -> 64ul) // 4 * block_length (fun () -> 0ul) (* init_input_len *) (fun () _k -> S.empty) (* init_input_s *) (fun () -> Spec.Poly1305.poly1305_init) (* init_s *) (fun () acc prevlen data -> update_multi acc data) (* update_multi_s *) (fun () x _ y -> update_last x y) (* update_last_s *) (fun () k s () -> finish_ k s) (* finish_s *) (fun () k s () -> spec k s) (* spec_s *) (* update_multi_zero *) (fun () acc prevlen -> Lib.UpdateMulti.update_multi_zero Spec.Poly1305.size_block update_ acc) (* update_multi_associative *) (fun () acc prevlen1 prevlen2 input1 input2 -> Lib.UpdateMulti.update_multi_associative Spec.Poly1305.size_block update_ acc input1 input2) (* spec_is_incremental *) (fun () key input () -> let input1 = S.append S.empty input in assert (S.equal input1 input); poly_is_incremental_lazy key input) (* index_of_state *) (fun _ _ -> ()) (* init *) (fun _ k _ s -> match fs with | M32 -> Hacl.Poly1305_32.poly1305_init s k | M128 -> Hacl.Poly1305_128.poly1305_init s k | M256 -> Hacl.Poly1305_256.poly1305_init s k) (* update_multi *) (fun _ s prevlen blocks len -> let h0 = ST.get () in begin let acc, r = P.as_get_acc h0 (as_lib s), P.as_get_r h0 (as_lib s) in update_multi_is_update (B.as_seq h0 blocks) acc r end; match fs with | M32 -> Hacl.Poly1305_32.poly1305_update s len blocks | M128 -> Hacl.Poly1305_128.poly1305_update s len blocks | M256 -> Hacl.Poly1305_256.poly1305_update s len blocks) (* update_last *) (fun _ s prev_len last last_len -> let h0 = ST.get () in begin let acc, r = P.as_get_acc h0 (as_lib s), P.as_get_r h0 (as_lib s) in update_last_is_update (B.as_seq h0 last) acc r end; match fs with | M32 -> Hacl.Poly1305_32.poly1305_update s last_len last | M128 -> Hacl.Poly1305_128.poly1305_update s last_len last | M256 -> Hacl.Poly1305_256.poly1305_update s last_len last) (* finish *) (fun _ k s dst _ -> let h0 = ST.get () in ST.push_frame (); let h1 = ST.get () in [@inline_let] let nl = num_lanes fs in let tmp = B.alloca (F32xN.zero nl) 25ul in let h2 = ST.get () in B.modifies_only_not_unused_in B.loc_none h1 h2; B.blit s 0ul tmp 0ul 25ul; let h3 = ST.get () in B.modifies_only_not_unused_in B.loc_none h1 h3; P.reveal_ctx_inv' (as_lib s) (as_lib tmp) h0 h3; begin match fs with | M32 -> Hacl.Poly1305_32.poly1305_finish dst k tmp | M128 -> Hacl.Poly1305_128.poly1305_finish dst k tmp | M256 -> Hacl.Poly1305_256.poly1305_finish dst k tmp end; let h4 = ST.get () in ST.pop_frame (); let h5 = ST.get () in B.modifies_only_not_unused_in B.(loc_buffer dst) h1 h4; B.modifies_fresh_frame_popped h0 h1 B.(loc_buffer dst) h4 h5; assert B.(loc_disjoint (loc_buffer s) (loc_buffer dst)); P.reveal_ctx_inv (as_lib s) h0 h5 )
{ "file_name": "code/streaming/Hacl.Streaming.Poly1305.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 505, "start_col": 0, "start_line": 404 }
module Hacl.Streaming.Poly1305 module HS = FStar.HyperStack module B = LowStar.Buffer module G = FStar.Ghost module S = FStar.Seq module U32 = FStar.UInt32 module U64 = FStar.UInt64 module F = Hacl.Streaming.Functor module I = Hacl.Streaming.Interface module P = Hacl.Impl.Poly1305 module F32xN = Hacl.Spec.Poly1305.Field32xN module ST = FStar.HyperStack.ST open LowStar.BufferOps open FStar.Mul /// Opening a bunch of modules for Poly1305 /// ======================================= inline_for_extraction noextract let uint8 = Lib.IntTypes.uint8 inline_for_extraction noextract let uint32 = Lib.IntTypes.uint32 open Hacl.Impl.Poly1305.Fields /// An instance of the stateful type class for poly1305 state /// ========================================================= /// /// We use a custom view that separates r and acc, to respect abstraction boundaries established by Poly1305. #set-options "--fuel 0 --ifuel 1 --z3rlimit 100" inline_for_extraction noextract let t (fs : field_spec) = b:B.buffer (limb fs) { B.length b == 25 } inline_for_extraction noextract let as_raw (#fs : field_spec) (x: t fs): B.buffer (limb fs) = x inline_for_extraction noextract let as_lib (#fs : field_spec) (x: t fs): P.poly1305_ctx fs = assert (Lib.IntTypes.(v (add #U32 (nlimb fs) (precomplen fs))) == 25); x inline_for_extraction noextract let poly1305_key = I.stateful_buffer uint8 32ul (Lib.IntTypes.u8 0) unit inline_for_extraction noextract let as_lib_k (x: B.buffer uint8 { B.length x = 32 }): Lib.Buffer.lbuffer uint8 32ul = x inline_for_extraction noextract let num_lanes (fs : field_spec) : F32xN.lanes = match fs with | M32 -> 1 | M128 -> 2 | M256 -> 4 inline_for_extraction noextract let stateful_poly1305_ctx (fs : field_spec) : I.stateful unit = I.Stateful (fun () -> t fs) (fun #_ _ s -> B.loc_addr_of_buffer (as_raw s)) (fun #_ _ s -> B.freeable (as_raw s)) (fun #_ h s -> B.live h (as_raw s) /\ P.state_inv_t h (as_lib s)) (fun () -> Spec.Poly1305.felem & Spec.Poly1305.felem) (fun () h s -> P.as_get_acc h (as_lib s), P.as_get_r h (as_lib s)) (fun #_ _ _ -> ()) (fun #_ l s h0 h1 -> P.reveal_ctx_inv (as_lib s) h0 h1; B.modifies_buffer_elim (as_raw s) l h0 h1) (fun #_ _ _ _ _ -> ()) (fun () -> [@inline_let] let n = num_lanes fs in let r = B.alloca (F32xN.zero n) 25ul in let h1 = ST.get () in P.ctx_inv_zeros #fs r h1; r) (fun () r -> [@inline_let] let n = num_lanes fs in let r = B.malloc r (F32xN.zero n) 25ul in let h1 = ST.get () in P.ctx_inv_zeros #fs r h1; r) (fun _ s -> B.free s) (fun _ src dst -> let h0 = ST.get () in B.blit src 0ul dst 0ul 25ul; let h1 = ST.get () in P.reveal_ctx_inv' (as_lib src) (as_lib dst) h0 h1) /// Interlude for spec equivalence proofs /// ===================================== /// /// A quick explanation about this proof of equivalence. At the spec level, /// ``poly1305_update`` needs both ``r`` and the accumulator ``acc``. This thus /// makes poly1305 update a function of two arguments. However, the streaming /// facility is constructed over specifications that take one single argument. /// Not a problem! We carry the pair ``(r, acc)`` as our "streaming functor /// accumulator", and we now have to show that a specification in terms of /// ``update (update (r, acc) init)`` is the same as poly1305. For that, we need /// to do a little proof of equivalence to show first that this is the same as /// ``(update r) ((update r) acc)`` (note that the update function now becomes a /// partial application), then use the update-multi-repeat conversion lemma to /// get the original specification of poly1305. inline_for_extraction noextract let block = (block: S.seq uint8 { S.length block = Spec.Poly1305.size_block }) inline_for_extraction noextract let update_ (acc, r) (block: block) = Spec.Poly1305.poly1305_update1 r Spec.Poly1305.size_block block acc, r /// Same as [update_], but with the input not necessarily a full block (can be smaller) inline_for_extraction noextract let update__ (acc, r) (input: S.seq uint8{S.length input <= Spec.Poly1305.size_block}) = Spec.Poly1305.poly1305_update1 r (S.length input) input acc, r inline_for_extraction noextract let update' r acc (block: block) = Spec.Poly1305.poly1305_update1 r Spec.Poly1305.size_block block acc inline_for_extraction noextract let update_multi = Lib.UpdateMulti.mk_update_multi Spec.Poly1305.size_block update_ inline_for_extraction noextract let update_multi' r = Lib.UpdateMulti.mk_update_multi Spec.Poly1305.size_block (update' r) #push-options "--fuel 1" inline_for_extraction noextract let rec with_or_without_r (acc r: Spec.Poly1305.felem) (blocks: S.seq uint8): Lemma (requires S.length blocks % Spec.Poly1305.size_block = 0) (ensures update_multi (acc, r) blocks == (update_multi' r acc blocks, r)) (decreases (S.length blocks)) = if S.length blocks = 0 then () else let block, rem = Lib.UpdateMulti.split_block Spec.Poly1305.size_block blocks 1 in let acc = update' r acc block in with_or_without_r acc r rem #pop-options inline_for_extraction noextract let update_last (acc, r) (input: S.seq uint8 { S.length input <= Spec.Poly1305.size_block }) = if S.length input = 0 then acc, r else Spec.Poly1305.poly1305_update1 r (S.length input) input acc, r inline_for_extraction noextract let update_last' r acc (input: S.seq uint8 { S.length input <= Spec.Poly1305.size_block }) = if S.length input = 0 then acc else Spec.Poly1305.poly1305_update1 r (S.length input) input acc inline_for_extraction noextract let finish_ k (acc, r) = Spec.Poly1305.poly1305_finish k acc inline_for_extraction noextract let spec k input = Spec.Poly1305.poly1305_mac input k val update_last_not_block_is_update (input: S.seq uint8) (acc: Spec.Poly1305.felem) (r: Spec.Poly1305.felem): Lemma (requires (S.length input < Spec.Poly1305.size_block)) (ensures (update_last (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r))) let update_last_not_block_is_update input acc r = let open Lib.UpdateMulti.Lemmas in let block_length = Spec.Poly1305.size_block in assert_norm (block_length < pow2 32); calc (==) { update_last (acc, r) input; (==) { } update_last' r acc input, r; (==) { Lib.UpdateMulti.update_multi_zero Spec.Poly1305.size_block (update' r) acc } update_last' r (update_multi' r acc S.empty) input, r; (==) { update_full_is_repeat_blocks block_length (update' r) (update_last' r) acc input input } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input (repeat_f block_length (update' r)) (repeat_l block_length (update_last' r) input) acc, r; (==) { Lib.Sequence.Lemmas.repeat_blocks_extensionality block_length input (repeat_f block_length (update' r)) Spec.Poly1305.(poly1305_update1 r size_block) (repeat_l block_length (update_last' r) input) Spec.Poly1305.(poly1305_update_last r) acc } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input Spec.Poly1305.(poly1305_update1 r size_block) Spec.Poly1305.(poly1305_update_last r) acc, r; } val update_last_block_is_update (input: S.seq uint8) (acc: Spec.Poly1305.felem) (r: Spec.Poly1305.felem): Lemma (requires (S.length input = Spec.Poly1305.size_block)) (ensures (update_last (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r))) open FStar.Tactics #push-options "--fuel 1 --print_implicits" let update_last_block_is_update input acc r = let open Lib.UpdateMulti.Lemmas in let block_length = Spec.Poly1305.size_block in assert_norm (block_length < pow2 32); assert(input `S.equal` S.append input S.empty); let acc1 = update' r acc input in let acc1' = update_multi' r acc input in // SH: fun fact: this lemma call and the following assert should be the // last part of the below calc. However, if put below/inside the calc, // the proof loops. Lib.Sequence.Lemmas.repeat_blocks_extensionality block_length input (repeat_f block_length (update' r)) Spec.Poly1305.(poly1305_update1 r size_block) (repeat_l block_length (update_last' r) input) Spec.Poly1305.(poly1305_update_last r) acc; assert( Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input (repeat_f block_length (update' r)) (repeat_l block_length (update_last' r) input) acc == Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input Spec.Poly1305.(poly1305_update1 r size_block) Spec.Poly1305.(poly1305_update_last r) acc); assert( let block, rem = Lib.UpdateMulti.split_block block_length input 1 in block `S.equal` input /\ rem `S.equal` S.empty); assert( Lib.UpdateMulti.mk_update_multi block_length (update' r) acc1 S.empty == acc1'); assert(acc1 == acc1'); calc (==) { update_last (acc, r) input; (==) { } update_last' r acc input, r; (==) { } update_last' r (update' r acc input) S.empty, r; (==) { } update_last' r (update_multi' r acc input) S.empty, r; (==) { update_full_is_repeat_blocks block_length (update' r) (update_last' r) acc input input } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input (repeat_f block_length (update' r)) (repeat_l block_length (update_last' r) input) acc, r; } #pop-options val update_last_is_update (input: S.seq uint8) (acc: Spec.Poly1305.felem) (r: Spec.Poly1305.felem): Lemma (requires (S.length input <= Spec.Poly1305.size_block)) (ensures (update_last (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r))) let update_last_is_update input acc r = if S.length input = Spec.Poly1305.size_block then update_last_block_is_update input acc r else update_last_not_block_is_update input acc r val update_multi_is_update (input: S.seq uint8) (acc: Spec.Poly1305.felem) (r: Spec.Poly1305.felem): Lemma (requires (S.length input % Spec.Poly1305.size_block = 0)) (ensures (update_multi (acc, r) input == (Spec.Poly1305.poly1305_update input acc r, r))) let update_multi_is_update input acc r = let open Lib.UpdateMulti.Lemmas in let block_length = Spec.Poly1305.size_block in assert_norm (block_length < pow2 32); calc (==) { update_multi (acc, r) input; (==) { with_or_without_r acc r input } update_multi' r acc input, r; (==) { } update_last' r (update_multi' r acc input) S.empty, r; (==) { update_full_is_repeat_blocks block_length (update' r) (update_last' r) acc input input } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input (repeat_f block_length (update' r)) (repeat_l block_length (update_last' r) input) acc, r; (==) { Lib.Sequence.Lemmas.repeat_blocks_extensionality block_length input (repeat_f block_length (update' r)) Spec.Poly1305.(poly1305_update1 r size_block) (repeat_l block_length (update_last' r) input) Spec.Poly1305.(poly1305_update_last r) acc } Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input Spec.Poly1305.(poly1305_update1 r size_block) Spec.Poly1305.(poly1305_update_last r) acc, r; } val poly_is_incremental: key: S.seq uint8 { S.length key = 32 } -> input:S.seq uint8 { S.length input <= pow2 32 - 1 } -> Lemma (ensures ( let hash = Lib.UpdateMulti.update_full Spec.Poly1305.size_block update_ update_last (Spec.Poly1305.poly1305_init key) input in finish_ key hash `S.equal` spec key input)) let poly_is_incremental key input = let open Lib.UpdateMulti.Lemmas in let block_length = Spec.Poly1305.size_block in assert_norm (block_length < pow2 32); let n = S.length input / block_length in let bs, l = S.split input (n * block_length) in FStar.Math.Lemmas.multiple_modulo_lemma n block_length; let acc, r = Spec.Poly1305.poly1305_init key in calc (S.equal) { finish_ key (update_last (update_multi (acc, r) bs) l); (S.equal) { with_or_without_r acc r bs } Spec.Poly1305.poly1305_finish key (update_last' r (update_multi' r acc bs) l); (S.equal) { update_full_is_repeat_blocks block_length (update' r) (update_last' r) acc input input } Spec.Poly1305.poly1305_finish key (Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input (repeat_f block_length (update' r)) (repeat_l block_length (update_last' r) input) acc); (S.equal) { Lib.Sequence.Lemmas.repeat_blocks_extensionality block_length input (repeat_f block_length (update' r)) Spec.Poly1305.(poly1305_update1 r size_block) (repeat_l block_length (update_last' r) input) Spec.Poly1305.(poly1305_update_last r) acc } Spec.Poly1305.poly1305_finish key (Lib.Sequence.repeat_blocks #uint8 #Spec.Poly1305.felem block_length input Spec.Poly1305.(poly1305_update1 r size_block) Spec.Poly1305.(poly1305_update_last r) acc); } /// Same lemma as above, but we take into account the fact that the hash stream /// processes the buffer lazily. val poly_is_incremental_lazy: key: S.seq uint8 { S.length key = 32 } -> input:S.seq uint8 { S.length input <= pow2 32 - 1 } -> Lemma (ensures ( let hash = Lib.UpdateMulti.update_full_lazy Spec.Poly1305.size_block update_ update_last (Spec.Poly1305.poly1305_init key) input in finish_ key hash `S.equal` spec key input)) #push-options "--fuel 1" let poly_is_incremental_lazy key input = let open Lib.UpdateMulti.Lemmas in let block_length = Spec.Poly1305.size_block in assert_norm (block_length < pow2 32); let n = S.length input / block_length in let rem = S.length input % block_length in let n', rem' = if rem = 0 && n > 0 then n - 1, block_length else n, rem in (**) let bs, l = S.split input (n' * block_length) in let acc, r = Spec.Poly1305.poly1305_init key in let acc1 = update_multi (acc, r) bs in let acc_f = update_last acc1 l in if rem = 0 && n > 0 then begin assert(acc_f == update__ acc1 l); assert( let block, rem = Lib.UpdateMulti.split_block Spec.Poly1305.size_block l 1 in block `S.equal` l /\ rem `S.equal` S.empty); let acc2 = update__ acc1 l in assert_norm(Lib.UpdateMulti.mk_update_multi Spec.Poly1305.size_block update_ acc2 S.empty == acc2); assert(acc_f == update_multi acc1 l); Lib.UpdateMulti.update_multi_associative Spec.Poly1305.size_block update_ (acc, r) bs l; assert(input `S.equal` S.append bs l); assert(acc_f = update_multi (acc, r) input); assert(update_last acc_f S.empty == acc_f); assert(input `S.equal` S.append input S.empty); poly_is_incremental key input end else poly_is_incremental key input #pop-options /// The block instance for poly1305! /// ================================ #push-options "--z3rlimit 300"
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.UpdateMulti.Lemmas.fsti.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.Interface.fsti.checked", "Hacl.Streaming.Functor.fsti.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "Hacl.Poly1305_32.fsti.checked", "Hacl.Poly1305_256.fsti.checked", "Hacl.Poly1305_128.fsti.checked", "Hacl.Impl.Poly1305.Fields.fst.checked", "Hacl.Impl.Poly1305.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Streaming.Poly1305.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Poly1305.Fields", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": "F32xN" }, { "abbrev": true, "full_module": "Hacl.Impl.Poly1305", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Streaming.Interface", "short_module": "I" }, { "abbrev": true, "full_module": "Hacl.Streaming.Functor", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Streaming", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 300, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
fs: Hacl.Impl.Poly1305.Fields.field_spec -> Hacl.Streaming.Interface.block Prims.unit
Prims.Tot
[ "total" ]
[]
[ "Hacl.Impl.Poly1305.Fields.field_spec", "Hacl.Streaming.Interface.Block", "Prims.unit", "Hacl.Streaming.Interface.Runtime", "Hacl.Streaming.Poly1305.stateful_poly1305_ctx", "Hacl.Streaming.Poly1305.poly1305_key", "FStar.UInt64.__uint_to_t", "FStar.UInt64.t", "Prims.b2t", "FStar.Integers.op_Greater", "FStar.Integers.Signed", "FStar.Integers.Winfinite", "FStar.UInt64.v", "Lib.IntTypes.size_nat", "FStar.UInt32.__uint_to_t", "FStar.UInt32.t", "FStar.UInt32.v", "Prims.l_and", "FStar.Integers.op_Greater_Equals", "Prims.op_Equality", "Prims.int", "FStar.Integers.op_Percent", "FStar.Integers.op_Less_Equals", "Hacl.Streaming.Interface.__proj__Stateful__item__t", "FStar.Seq.Base.empty", "Hacl.Streaming.Interface.uint8", "FStar.Seq.Base.seq", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.UInt.size", "FStar.UInt32.n", "FStar.Seq.Base.length", "Spec.Poly1305.poly1305_init", "FStar.Integers.nat", "FStar.Integers.op_Plus", "Hacl.Streaming.Poly1305.update_multi", "Hacl.Streaming.Poly1305.update_last", "Hacl.Streaming.Poly1305.finish_", "Spec.Poly1305.felem", "Prims.nat", "Hacl.Streaming.Poly1305.spec", "Prims.eq2", "Lib.UpdateMulti.update_multi_zero", "FStar.Pervasives.Native.tuple2", "Spec.Poly1305.size_block", "Hacl.Streaming.Poly1305.update_", "Lib.UpdateMulti.update_multi_associative", "Hacl.Streaming.Poly1305.poly_is_incremental_lazy", "Prims._assert", "FStar.Seq.Base.equal", "FStar.Seq.Base.append", "FStar.Ghost.erased", "Hacl.Streaming.Interface.__proj__Stateful__item__s", "FStar.Ghost.reveal", "LowStar.Buffer.buffer", "LowStar.Monotonic.Buffer.length", "LowStar.Buffer.trivial_preorder", "Hacl.Poly1305_32.poly1305_init", "Hacl.Poly1305_128.poly1305_init", "Hacl.Poly1305_256.poly1305_init", "Hacl.Poly1305_32.poly1305_update", "Hacl.Poly1305_128.poly1305_update", "Hacl.Poly1305_256.poly1305_update", "Hacl.Streaming.Poly1305.update_multi_is_update", "LowStar.Monotonic.Buffer.as_seq", "FStar.Pervasives.Native.Mktuple2", "Hacl.Impl.Poly1305.as_get_acc", "Hacl.Streaming.Poly1305.as_lib", "Hacl.Impl.Poly1305.as_get_r", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowStar.Monotonic.Buffer.len", "Hacl.Streaming.Poly1305.update_last_is_update", "Hacl.Streaming.Interface.optional_key", "Hacl.Impl.Poly1305.reveal_ctx_inv", "LowStar.Monotonic.Buffer.loc_disjoint", "LowStar.Monotonic.Buffer.loc_buffer", "Hacl.Impl.Poly1305.Fields.limb", "LowStar.Monotonic.Buffer.modifies_fresh_frame_popped", "LowStar.Monotonic.Buffer.modifies_only_not_unused_in", "FStar.HyperStack.ST.pop_frame", "Hacl.Poly1305_32.poly1305_finish", "Hacl.Poly1305_128.poly1305_finish", "Hacl.Poly1305_256.poly1305_finish", "Hacl.Impl.Poly1305.reveal_ctx_inv'", "LowStar.Monotonic.Buffer.loc_none", "LowStar.Monotonic.Buffer.blit", "LowStar.Monotonic.Buffer.mbuffer", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "FStar.UInt32.uint_to_t", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "LowStar.Buffer.alloca", "Hacl.Spec.Poly1305.Field32xN.zero", "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Streaming.Poly1305.num_lanes", "FStar.HyperStack.ST.push_frame", "Hacl.Streaming.Interface.block" ]
[]
false
false
false
true
false
let poly1305 (fs: field_spec) : I.block unit =
I.Block I.Runtime (stateful_poly1305_ctx fs) poly1305_key unit (fun () -> 0xffffffffuL) (fun () () -> 16) (fun () -> 16ul) (fun () -> match fs with | M32 -> 16ul | M128 -> 32ul | M256 -> 64ul) (fun () -> 0ul) (fun () _k -> S.empty) (fun () -> Spec.Poly1305.poly1305_init) (fun () acc prevlen data -> update_multi acc data) (fun () x _ y -> update_last x y) (fun () k s () -> finish_ k s) (fun () k s () -> spec k s) (fun () acc prevlen -> Lib.UpdateMulti.update_multi_zero Spec.Poly1305.size_block update_ acc) (fun () acc prevlen1 prevlen2 input1 input2 -> Lib.UpdateMulti.update_multi_associative Spec.Poly1305.size_block update_ acc input1 input2) (fun () key input () -> let input1 = S.append S.empty input in assert (S.equal input1 input); poly_is_incremental_lazy key input) (fun _ _ -> ()) (fun _ k _ s -> match fs with | M32 -> Hacl.Poly1305_32.poly1305_init s k | M128 -> Hacl.Poly1305_128.poly1305_init s k | M256 -> Hacl.Poly1305_256.poly1305_init s k) (fun _ s prevlen blocks len -> let h0 = ST.get () in (let acc, r = P.as_get_acc h0 (as_lib s), P.as_get_r h0 (as_lib s) in update_multi_is_update (B.as_seq h0 blocks) acc r); match fs with | M32 -> Hacl.Poly1305_32.poly1305_update s len blocks | M128 -> Hacl.Poly1305_128.poly1305_update s len blocks | M256 -> Hacl.Poly1305_256.poly1305_update s len blocks) (fun _ s prev_len last last_len -> let h0 = ST.get () in (let acc, r = P.as_get_acc h0 (as_lib s), P.as_get_r h0 (as_lib s) in update_last_is_update (B.as_seq h0 last) acc r); match fs with | M32 -> Hacl.Poly1305_32.poly1305_update s last_len last | M128 -> Hacl.Poly1305_128.poly1305_update s last_len last | M256 -> Hacl.Poly1305_256.poly1305_update s last_len last) (fun _ k s dst _ -> let h0 = ST.get () in ST.push_frame (); let h1 = ST.get () in [@@ inline_let ]let nl = num_lanes fs in let tmp = B.alloca (F32xN.zero nl) 25ul in let h2 = ST.get () in B.modifies_only_not_unused_in B.loc_none h1 h2; B.blit s 0ul tmp 0ul 25ul; let h3 = ST.get () in B.modifies_only_not_unused_in B.loc_none h1 h3; P.reveal_ctx_inv' (as_lib s) (as_lib tmp) h0 h3; (match fs with | M32 -> Hacl.Poly1305_32.poly1305_finish dst k tmp | M128 -> Hacl.Poly1305_128.poly1305_finish dst k tmp | M256 -> Hacl.Poly1305_256.poly1305_finish dst k tmp); let h4 = ST.get () in ST.pop_frame (); let h5 = ST.get () in B.modifies_only_not_unused_in B.(loc_buffer dst) h1 h4; B.modifies_fresh_frame_popped h0 h1 B.(loc_buffer dst) h4 h5; assert B.(loc_disjoint (loc_buffer s) (loc_buffer dst)); P.reveal_ctx_inv (as_lib s) h0 h5)
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.qsqr
val qsqr (out f: qelem) : Stack unit (requires fun h -> live h out /\ live h f /\ eq_or_disjoint out f /\ qe_lt_q h f) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == S.qmul (qas_nat h0 f) (qas_nat h0 f) /\ qe_lt_q h1 out)
val qsqr (out f: qelem) : Stack unit (requires fun h -> live h out /\ live h f /\ eq_or_disjoint out f /\ qe_lt_q h f) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == S.qmul (qas_nat h0 f) (qas_nat h0 f) /\ qe_lt_q h1 out)
let qsqr out f = push_frame (); let h0 = ST.get () in let tmp = create (2ul *! qnlimb) (u64 0) in kn.BN.sqr f tmp; SN.bn_sqr_lemma (as_seq h0 f); modq out tmp; pop_frame ()
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 14, "end_line": 339, "start_col": 0, "start_line": 331 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb let sub4: BN.bn_sub_eq_len_st U64 qnlimb = BN.bn_sub_eq_len qnlimb let add_mod4: BN.bn_add_mod_n_st U64 qnlimb = BN.bn_add_mod_n qnlimb let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb = BN.bn_sub_mod_n qnlimb let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a = BN.bn_mul qnlimb qnlimb a let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a = BN.bn_sqr qnlimb a inline_for_extraction noextract instance kn: BN.bn U64 = { BN.len = qnlimb; BN.add = add4; BN.sub = sub4; BN.add_mod_n = add_mod4; BN.sub_mod_n = sub_mod4; BN.mul = mul4; BN.sqr = sqr4 } let make_u64_4 out (f0, f1, f2, f3) = out.(0ul) <- f0; out.(1ul) <- f1; out.(2ul) <- f2; out.(3ul) <- f3; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h out); assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3)) let make_order_k256 () = [@inline_let] let r = (u64 0xbfd25e8cd0364141, u64 0xbaaedce6af48a03b, u64 0xfffffffffffffffe, u64 0xffffffffffffffff) in assert_norm (qas_nat4 r = S.q); r let create_qelem () = SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb); create qnlimb (u64 0) let create_one () = [@inline_let] let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in assert_norm (FStar.List.Tot.length l = 4); Seq.elim_of_list l; LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l); KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)); createL l [@CInline] let is_qelem_zero f = let h0 = ST.get () in SN.bn_is_zero_mask_lemma (as_seq h0 f); BN.bn_is_zero_mask qnlimb f [@CInline] let is_qelem_zero_vartime f = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3); is_qelem_zero_vartime4 (f0,f1,f2,f3) [@CInline] let is_qelem_eq_vartime f1 f2 = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f1); KL.qas_nat4_is_qas_nat (as_seq h f2); let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3); is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3) let load_qelem f b = let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b); Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f [@CInline] let load_qelem_check f b = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); load_qelem f b; let h0 = ST.get () in let is_zero = is_qelem_zero f in assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0)); let is_lt_q = BN.bn_lt_mask qnlimb f n in SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n); assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0)); let m = logand (lognot is_zero) is_lt_q in lognot_lemma is_zero; logand_lemma (lognot is_zero) is_lt_q; pop_frame (); m let load_qelem_conditional res b = push_frame (); let is_b_valid = load_qelem_check res b in let oneq = create_one () in let h0 = ST.get () in Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res; let h1 = ST.get () in assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res)); pop_frame (); is_b_valid [@CInline] let load_qelem_vartime f b = load_qelem f b; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let is_zero = is_qelem_zero_vartime f in let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in let is_lt_q_b = is_qelem_lt_q_vartime4 (a0,a1,a2,a3) in KL.is_qelem_lt_q_vartime4_lemma (a0,a1,a2,a3); not is_zero && is_lt_q_b val modq_short: out:qelem -> a:qelem -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == qas_nat h0 a % S.q) [@CInline] let modq_short out a = push_frame (); let tmp = create_qelem () in [@inline_let] let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in make_u64_4 tmp (t0,t1,t2,t3); let h0 = ST.get () in let c = kn.BN.add a tmp out in let mask = u64 0 -. c in map2T qnlimb out (BB.mask_select mask) out a; KL.mod_short_lseq_lemma (as_seq h0 a); pop_frame () [@CInline] let load_qelem_modq f b = push_frame (); let tmp = create_qelem () in load_qelem f b; copy tmp f; modq_short f tmp; pop_frame () [@CInline] let store_qelem b f = let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma #U64 32 (as_seq h0 f); Hacl.Bignum.Convert.mk_bn_to_bytes_be true 32ul f b [@CInline] let qadd out f1 f2 = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); let h0 = ST.get () in kn.BN.add_mod_n n f1 f2 out; SN.bn_add_mod_n_lemma (as_seq h0 n) (as_seq h0 f1) (as_seq h0 f2); pop_frame () val mul_pow2_256_minus_q_add: len:size_t -> resLen:size_t{2 + v len <= v resLen /\ 4 <= v resLen} -> t01:lbuffer uint64 2ul -> a:lbuffer uint64 len -> e:lbuffer uint64 4ul -> res:lbuffer uint64 resLen -> Stack (BB.carry U64) (requires fun h -> live h a /\ live h res /\ live h t01 /\ live h e /\ disjoint a res /\ disjoint a t01 /\ disjoint a e /\ disjoint res t01 /\ disjoint res e /\ disjoint t01 e /\ as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\ as_seq h res == LSeq.create (v resLen) (u64 0)) (ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\ (c, as_seq h1 res) == mul_pow2_256_minus_q_lseq_add (v len) (v resLen) (as_seq h0 a) (as_seq h0 e)) [@CInline] let mul_pow2_256_minus_q_add len resLen t01 a e res = push_frame (); let tmp = create (len +! 2ul) (u64 0) in BN.bn_mul len 2ul a t01 tmp; update_sub res 2ul len a; let _ = bn_add resLen res (len +! 2ul) tmp res in let c = bn_add resLen res 4ul e res in pop_frame (); c inline_for_extraction noextract val modq_before_final: t01:lbuffer uint64 2ul -> a:lbuffer uint64 (2ul *! qnlimb) -> out:qelem -> Stack (BB.carry U64) (requires fun h -> live h a /\ live h out /\ live h t01 /\ disjoint a out /\ disjoint a t01 /\ disjoint out t01 /\ as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\ as_seq h out == LSeq.create 4 (u64 0)) (ensures fun h0 c h1 -> modifies (loc out) h0 h1 /\ (c, as_seq h1 out) == mod_lseq_before_final (as_seq h0 a)) let modq_before_final t01 a out = push_frame (); let m = create 7ul (u64 0) in let p = create 5ul (u64 0) in let c0 = mul_pow2_256_minus_q_add 4ul 7ul t01 (sub a 4ul 4ul) (sub a 0ul 4ul) m in let c1 = mul_pow2_256_minus_q_add 3ul 5ul t01 (sub m 4ul 3ul) (sub m 0ul 4ul) p in let c2 = mul_pow2_256_minus_q_add 1ul 4ul t01 (sub p 4ul 1ul) (sub p 0ul 4ul) out in pop_frame (); c2 val modq: out:qelem -> a:lbuffer uint64 (2ul *! qnlimb) -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == BD.bn_v h0 a % S.q) [@CInline] let modq out a = push_frame (); let r = create_qelem () in let tmp = create_qelem () in [@inline_let] let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in make_u64_4 tmp (t0,t1,t2,t3); let t01 = sub tmp 0ul 2ul in let h0 = ST.get () in assert (Seq.equal (as_seq h0 t01) (LSeq.create2 t0 t1)); let c0 = modq_before_final t01 a r in let c1 = kn.BN.add r tmp out in let mask = u64 0 -. (c0 +. c1) in map2T qnlimb out (BB.mask_select mask) out r; let h1 = ST.get () in KL.mod_lseq_lemma (as_seq h0 a); pop_frame () [@CInline] let qmul out f1 f2 = push_frame (); let h0 = ST.get () in let tmp = create (2ul *! qnlimb) (u64 0) in kn.BN.mul f1 f2 tmp; SN.bn_mul_lemma (as_seq h0 f1) (as_seq h0 f2); modq out tmp; pop_frame ()
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
out: Hacl.K256.Scalar.qelem -> f: Hacl.K256.Scalar.qelem -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.K256.Scalar.qelem", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.K256.Scalar.modq", "Hacl.Spec.Bignum.bn_sqr_lemma", "Lib.IntTypes.U64", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.K256.Scalar.qnlimb", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "Hacl.Bignum.__proj__Mkbn__item__sqr", "Hacl.K256.Scalar.kn", "Lib.Buffer.lbuffer_t", "Hacl.Bignum.Definitions.limb", "Lib.IntTypes.mul", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.create", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.u64", "Lib.Buffer.lbuffer", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let qsqr out f =
push_frame (); let h0 = ST.get () in let tmp = create (2ul *! qnlimb) (u64 0) in kn.BN.sqr f tmp; SN.bn_sqr_lemma (as_seq h0 f); modq out tmp; pop_frame ()
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.load_qelem_vartime
val load_qelem_vartime: f:qelem -> b:lbuffer uint8 32ul -> Stack bool (requires fun h -> live h f /\ live h b /\ disjoint f b) (ensures fun h0 m h1 -> modifies (loc f) h0 h1 /\ (let b_nat = BSeq.nat_from_bytes_be (as_seq h0 b) in qas_nat h1 f == b_nat /\ m = (0 < b_nat && b_nat < S.q)))
val load_qelem_vartime: f:qelem -> b:lbuffer uint8 32ul -> Stack bool (requires fun h -> live h f /\ live h b /\ disjoint f b) (ensures fun h0 m h1 -> modifies (loc f) h0 h1 /\ (let b_nat = BSeq.nat_from_bytes_be (as_seq h0 b) in qas_nat h1 f == b_nat /\ m = (0 < b_nat && b_nat < S.q)))
let load_qelem_vartime f b = load_qelem f b; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let is_zero = is_qelem_zero_vartime f in let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in let is_lt_q_b = is_qelem_lt_q_vartime4 (a0,a1,a2,a3) in KL.is_qelem_lt_q_vartime4_lemma (a0,a1,a2,a3); not is_zero && is_lt_q_b
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 26, "end_line": 180, "start_col": 0, "start_line": 171 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb let sub4: BN.bn_sub_eq_len_st U64 qnlimb = BN.bn_sub_eq_len qnlimb let add_mod4: BN.bn_add_mod_n_st U64 qnlimb = BN.bn_add_mod_n qnlimb let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb = BN.bn_sub_mod_n qnlimb let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a = BN.bn_mul qnlimb qnlimb a let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a = BN.bn_sqr qnlimb a inline_for_extraction noextract instance kn: BN.bn U64 = { BN.len = qnlimb; BN.add = add4; BN.sub = sub4; BN.add_mod_n = add_mod4; BN.sub_mod_n = sub_mod4; BN.mul = mul4; BN.sqr = sqr4 } let make_u64_4 out (f0, f1, f2, f3) = out.(0ul) <- f0; out.(1ul) <- f1; out.(2ul) <- f2; out.(3ul) <- f3; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h out); assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3)) let make_order_k256 () = [@inline_let] let r = (u64 0xbfd25e8cd0364141, u64 0xbaaedce6af48a03b, u64 0xfffffffffffffffe, u64 0xffffffffffffffff) in assert_norm (qas_nat4 r = S.q); r let create_qelem () = SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb); create qnlimb (u64 0) let create_one () = [@inline_let] let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in assert_norm (FStar.List.Tot.length l = 4); Seq.elim_of_list l; LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l); KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)); createL l [@CInline] let is_qelem_zero f = let h0 = ST.get () in SN.bn_is_zero_mask_lemma (as_seq h0 f); BN.bn_is_zero_mask qnlimb f [@CInline] let is_qelem_zero_vartime f = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3); is_qelem_zero_vartime4 (f0,f1,f2,f3) [@CInline] let is_qelem_eq_vartime f1 f2 = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f1); KL.qas_nat4_is_qas_nat (as_seq h f2); let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3); is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3) let load_qelem f b = let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b); Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f [@CInline] let load_qelem_check f b = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); load_qelem f b; let h0 = ST.get () in let is_zero = is_qelem_zero f in assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0)); let is_lt_q = BN.bn_lt_mask qnlimb f n in SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n); assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0)); let m = logand (lognot is_zero) is_lt_q in lognot_lemma is_zero; logand_lemma (lognot is_zero) is_lt_q; pop_frame (); m let load_qelem_conditional res b = push_frame (); let is_b_valid = load_qelem_check res b in let oneq = create_one () in let h0 = ST.get () in Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res; let h1 = ST.get () in assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res)); pop_frame (); is_b_valid
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: Hacl.K256.Scalar.qelem -> b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> FStar.HyperStack.ST.Stack Prims.bool
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.K256.Scalar.qelem", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.uint64", "Prims.op_AmpAmp", "Prims.op_Negation", "Prims.unit", "Hacl.Spec.K256.Scalar.Lemmas.is_qelem_lt_q_vartime4_lemma", "FStar.Pervasives.Native.Mktuple4", "Prims.bool", "Hacl.Spec.K256.Scalar.is_qelem_lt_q_vartime4", "FStar.Pervasives.Native.tuple4", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT", "Hacl.K256.Scalar.qnlimb", "Hacl.K256.Scalar.is_qelem_zero_vartime", "Hacl.Spec.K256.Scalar.Lemmas.qas_nat4_is_qas_nat", "Lib.Buffer.as_seq", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.K256.Scalar.load_qelem" ]
[]
false
true
false
false
false
let load_qelem_vartime f b =
load_qelem f b; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let is_zero = is_qelem_zero_vartime f in let a0, a1, a2, a3 = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in let is_lt_q_b = is_qelem_lt_q_vartime4 (a0, a1, a2, a3) in KL.is_qelem_lt_q_vartime4_lemma (a0, a1, a2, a3); not is_zero && is_lt_q_b
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.qmul
val qmul (out f1 f2: qelem) : Stack unit (requires fun h -> live h out /\ live h f1 /\ live h f2 /\ eq_or_disjoint out f1 /\ eq_or_disjoint out f2 /\ eq_or_disjoint f1 f2 /\ qe_lt_q h f1 /\ qe_lt_q h f2) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == S.qmul (qas_nat h0 f1) (qas_nat h0 f2) /\ qe_lt_q h1 out)
val qmul (out f1 f2: qelem) : Stack unit (requires fun h -> live h out /\ live h f1 /\ live h f2 /\ eq_or_disjoint out f1 /\ eq_or_disjoint out f2 /\ eq_or_disjoint f1 f2 /\ qe_lt_q h f1 /\ qe_lt_q h f2) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == S.qmul (qas_nat h0 f1) (qas_nat h0 f2) /\ qe_lt_q h1 out)
let qmul out f1 f2 = push_frame (); let h0 = ST.get () in let tmp = create (2ul *! qnlimb) (u64 0) in kn.BN.mul f1 f2 tmp; SN.bn_mul_lemma (as_seq h0 f1) (as_seq h0 f2); modq out tmp; pop_frame ()
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 14, "end_line": 327, "start_col": 0, "start_line": 319 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb let sub4: BN.bn_sub_eq_len_st U64 qnlimb = BN.bn_sub_eq_len qnlimb let add_mod4: BN.bn_add_mod_n_st U64 qnlimb = BN.bn_add_mod_n qnlimb let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb = BN.bn_sub_mod_n qnlimb let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a = BN.bn_mul qnlimb qnlimb a let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a = BN.bn_sqr qnlimb a inline_for_extraction noextract instance kn: BN.bn U64 = { BN.len = qnlimb; BN.add = add4; BN.sub = sub4; BN.add_mod_n = add_mod4; BN.sub_mod_n = sub_mod4; BN.mul = mul4; BN.sqr = sqr4 } let make_u64_4 out (f0, f1, f2, f3) = out.(0ul) <- f0; out.(1ul) <- f1; out.(2ul) <- f2; out.(3ul) <- f3; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h out); assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3)) let make_order_k256 () = [@inline_let] let r = (u64 0xbfd25e8cd0364141, u64 0xbaaedce6af48a03b, u64 0xfffffffffffffffe, u64 0xffffffffffffffff) in assert_norm (qas_nat4 r = S.q); r let create_qelem () = SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb); create qnlimb (u64 0) let create_one () = [@inline_let] let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in assert_norm (FStar.List.Tot.length l = 4); Seq.elim_of_list l; LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l); KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)); createL l [@CInline] let is_qelem_zero f = let h0 = ST.get () in SN.bn_is_zero_mask_lemma (as_seq h0 f); BN.bn_is_zero_mask qnlimb f [@CInline] let is_qelem_zero_vartime f = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3); is_qelem_zero_vartime4 (f0,f1,f2,f3) [@CInline] let is_qelem_eq_vartime f1 f2 = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f1); KL.qas_nat4_is_qas_nat (as_seq h f2); let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3); is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3) let load_qelem f b = let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b); Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f [@CInline] let load_qelem_check f b = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); load_qelem f b; let h0 = ST.get () in let is_zero = is_qelem_zero f in assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0)); let is_lt_q = BN.bn_lt_mask qnlimb f n in SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n); assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0)); let m = logand (lognot is_zero) is_lt_q in lognot_lemma is_zero; logand_lemma (lognot is_zero) is_lt_q; pop_frame (); m let load_qelem_conditional res b = push_frame (); let is_b_valid = load_qelem_check res b in let oneq = create_one () in let h0 = ST.get () in Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res; let h1 = ST.get () in assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res)); pop_frame (); is_b_valid [@CInline] let load_qelem_vartime f b = load_qelem f b; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let is_zero = is_qelem_zero_vartime f in let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in let is_lt_q_b = is_qelem_lt_q_vartime4 (a0,a1,a2,a3) in KL.is_qelem_lt_q_vartime4_lemma (a0,a1,a2,a3); not is_zero && is_lt_q_b val modq_short: out:qelem -> a:qelem -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == qas_nat h0 a % S.q) [@CInline] let modq_short out a = push_frame (); let tmp = create_qelem () in [@inline_let] let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in make_u64_4 tmp (t0,t1,t2,t3); let h0 = ST.get () in let c = kn.BN.add a tmp out in let mask = u64 0 -. c in map2T qnlimb out (BB.mask_select mask) out a; KL.mod_short_lseq_lemma (as_seq h0 a); pop_frame () [@CInline] let load_qelem_modq f b = push_frame (); let tmp = create_qelem () in load_qelem f b; copy tmp f; modq_short f tmp; pop_frame () [@CInline] let store_qelem b f = let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma #U64 32 (as_seq h0 f); Hacl.Bignum.Convert.mk_bn_to_bytes_be true 32ul f b [@CInline] let qadd out f1 f2 = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); let h0 = ST.get () in kn.BN.add_mod_n n f1 f2 out; SN.bn_add_mod_n_lemma (as_seq h0 n) (as_seq h0 f1) (as_seq h0 f2); pop_frame () val mul_pow2_256_minus_q_add: len:size_t -> resLen:size_t{2 + v len <= v resLen /\ 4 <= v resLen} -> t01:lbuffer uint64 2ul -> a:lbuffer uint64 len -> e:lbuffer uint64 4ul -> res:lbuffer uint64 resLen -> Stack (BB.carry U64) (requires fun h -> live h a /\ live h res /\ live h t01 /\ live h e /\ disjoint a res /\ disjoint a t01 /\ disjoint a e /\ disjoint res t01 /\ disjoint res e /\ disjoint t01 e /\ as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\ as_seq h res == LSeq.create (v resLen) (u64 0)) (ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\ (c, as_seq h1 res) == mul_pow2_256_minus_q_lseq_add (v len) (v resLen) (as_seq h0 a) (as_seq h0 e)) [@CInline] let mul_pow2_256_minus_q_add len resLen t01 a e res = push_frame (); let tmp = create (len +! 2ul) (u64 0) in BN.bn_mul len 2ul a t01 tmp; update_sub res 2ul len a; let _ = bn_add resLen res (len +! 2ul) tmp res in let c = bn_add resLen res 4ul e res in pop_frame (); c inline_for_extraction noextract val modq_before_final: t01:lbuffer uint64 2ul -> a:lbuffer uint64 (2ul *! qnlimb) -> out:qelem -> Stack (BB.carry U64) (requires fun h -> live h a /\ live h out /\ live h t01 /\ disjoint a out /\ disjoint a t01 /\ disjoint out t01 /\ as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\ as_seq h out == LSeq.create 4 (u64 0)) (ensures fun h0 c h1 -> modifies (loc out) h0 h1 /\ (c, as_seq h1 out) == mod_lseq_before_final (as_seq h0 a)) let modq_before_final t01 a out = push_frame (); let m = create 7ul (u64 0) in let p = create 5ul (u64 0) in let c0 = mul_pow2_256_minus_q_add 4ul 7ul t01 (sub a 4ul 4ul) (sub a 0ul 4ul) m in let c1 = mul_pow2_256_minus_q_add 3ul 5ul t01 (sub m 4ul 3ul) (sub m 0ul 4ul) p in let c2 = mul_pow2_256_minus_q_add 1ul 4ul t01 (sub p 4ul 1ul) (sub p 0ul 4ul) out in pop_frame (); c2 val modq: out:qelem -> a:lbuffer uint64 (2ul *! qnlimb) -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == BD.bn_v h0 a % S.q) [@CInline] let modq out a = push_frame (); let r = create_qelem () in let tmp = create_qelem () in [@inline_let] let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in make_u64_4 tmp (t0,t1,t2,t3); let t01 = sub tmp 0ul 2ul in let h0 = ST.get () in assert (Seq.equal (as_seq h0 t01) (LSeq.create2 t0 t1)); let c0 = modq_before_final t01 a r in let c1 = kn.BN.add r tmp out in let mask = u64 0 -. (c0 +. c1) in map2T qnlimb out (BB.mask_select mask) out r; let h1 = ST.get () in KL.mod_lseq_lemma (as_seq h0 a); pop_frame ()
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
out: Hacl.K256.Scalar.qelem -> f1: Hacl.K256.Scalar.qelem -> f2: Hacl.K256.Scalar.qelem -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.K256.Scalar.qelem", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.K256.Scalar.modq", "Hacl.Spec.Bignum.bn_mul_lemma", "Lib.IntTypes.U64", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.K256.Scalar.qnlimb", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "Hacl.Bignum.__proj__Mkbn__item__mul", "Hacl.K256.Scalar.kn", "Lib.Buffer.lbuffer_t", "Hacl.Bignum.Definitions.limb", "Lib.IntTypes.mul", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.create", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.u64", "Lib.Buffer.lbuffer", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let qmul out f1 f2 =
push_frame (); let h0 = ST.get () in let tmp = create (2ul *! qnlimb) (u64 0) in kn.BN.mul f1 f2 tmp; SN.bn_mul_lemma (as_seq h0 f1) (as_seq h0 f2); modq out tmp; pop_frame ()
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.make_u64_4
val make_u64_4 (out:qelem) (f:qelem4) : Stack unit (requires fun h -> live h out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == qas_nat4 f /\ (let (f0,f1,f2,f3) = f in as_seq h1 out == LSeq.create4 f0 f1 f2 f3))
val make_u64_4 (out:qelem) (f:qelem4) : Stack unit (requires fun h -> live h out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == qas_nat4 f /\ (let (f0,f1,f2,f3) = f in as_seq h1 out == LSeq.create4 f0 f1 f2 f3))
let make_u64_4 out (f0, f1, f2, f3) = out.(0ul) <- f0; out.(1ul) <- f1; out.(2ul) <- f2; out.(3ul) <- f3; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h out); assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3))
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 62, "end_line": 73, "start_col": 0, "start_line": 66 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb let sub4: BN.bn_sub_eq_len_st U64 qnlimb = BN.bn_sub_eq_len qnlimb let add_mod4: BN.bn_add_mod_n_st U64 qnlimb = BN.bn_add_mod_n qnlimb let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb = BN.bn_sub_mod_n qnlimb let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a = BN.bn_mul qnlimb qnlimb a let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a = BN.bn_sqr qnlimb a inline_for_extraction noextract instance kn: BN.bn U64 = { BN.len = qnlimb; BN.add = add4; BN.sub = sub4; BN.add_mod_n = add_mod4; BN.sub_mod_n = sub_mod4; BN.mul = mul4; BN.sqr = sqr4 }
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
out: Hacl.K256.Scalar.qelem -> f: Hacl.Spec.K256.Scalar.qelem4 -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.K256.Scalar.qelem", "Hacl.Spec.K256.Scalar.qelem4", "Lib.IntTypes.uint64", "Prims._assert", "FStar.Seq.Base.equal", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Hacl.K256.Scalar.qnlimb", "Lib.Sequence.create4", "Prims.unit", "Hacl.Spec.K256.Scalar.Lemmas.qas_nat4_is_qas_nat", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.Buffer.op_Array_Assignment", "FStar.UInt32.__uint_to_t" ]
[]
false
true
false
false
false
let make_u64_4 out (f0, f1, f2, f3) =
out.(0ul) <- f0; out.(1ul) <- f1; out.(2ul) <- f2; out.(3ul) <- f3; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h out); assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3))
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.load_qelem_conditional
val load_qelem_conditional: res:qelem -> b:lbuffer uint8 32ul -> Stack uint64 (requires fun h -> live h res /\ live h b /\ disjoint res b) (ensures fun h0 m h1 -> modifies (loc res) h0 h1 /\ (let b_nat = BSeq.nat_from_bytes_be (as_seq h0 b) in let is_b_valid = 0 < b_nat && b_nat < S.q in (v m = ones_v U64 \/ v m = 0) /\ (v m = ones_v U64) = is_b_valid /\ qas_nat h1 res == (if is_b_valid then b_nat else 1)))
val load_qelem_conditional: res:qelem -> b:lbuffer uint8 32ul -> Stack uint64 (requires fun h -> live h res /\ live h b /\ disjoint res b) (ensures fun h0 m h1 -> modifies (loc res) h0 h1 /\ (let b_nat = BSeq.nat_from_bytes_be (as_seq h0 b) in let is_b_valid = 0 < b_nat && b_nat < S.q in (v m = ones_v U64 \/ v m = 0) /\ (v m = ones_v U64) = is_b_valid /\ qas_nat h1 res == (if is_b_valid then b_nat else 1)))
let load_qelem_conditional res b = push_frame (); let is_b_valid = load_qelem_check res b in let oneq = create_one () in let h0 = ST.get () in Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res; let h1 = ST.get () in assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res)); pop_frame (); is_b_valid
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 12, "end_line": 167, "start_col": 0, "start_line": 158 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb let sub4: BN.bn_sub_eq_len_st U64 qnlimb = BN.bn_sub_eq_len qnlimb let add_mod4: BN.bn_add_mod_n_st U64 qnlimb = BN.bn_add_mod_n qnlimb let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb = BN.bn_sub_mod_n qnlimb let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a = BN.bn_mul qnlimb qnlimb a let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a = BN.bn_sqr qnlimb a inline_for_extraction noextract instance kn: BN.bn U64 = { BN.len = qnlimb; BN.add = add4; BN.sub = sub4; BN.add_mod_n = add_mod4; BN.sub_mod_n = sub_mod4; BN.mul = mul4; BN.sqr = sqr4 } let make_u64_4 out (f0, f1, f2, f3) = out.(0ul) <- f0; out.(1ul) <- f1; out.(2ul) <- f2; out.(3ul) <- f3; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h out); assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3)) let make_order_k256 () = [@inline_let] let r = (u64 0xbfd25e8cd0364141, u64 0xbaaedce6af48a03b, u64 0xfffffffffffffffe, u64 0xffffffffffffffff) in assert_norm (qas_nat4 r = S.q); r let create_qelem () = SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb); create qnlimb (u64 0) let create_one () = [@inline_let] let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in assert_norm (FStar.List.Tot.length l = 4); Seq.elim_of_list l; LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l); KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)); createL l [@CInline] let is_qelem_zero f = let h0 = ST.get () in SN.bn_is_zero_mask_lemma (as_seq h0 f); BN.bn_is_zero_mask qnlimb f [@CInline] let is_qelem_zero_vartime f = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3); is_qelem_zero_vartime4 (f0,f1,f2,f3) [@CInline] let is_qelem_eq_vartime f1 f2 = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f1); KL.qas_nat4_is_qas_nat (as_seq h f2); let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3); is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3) let load_qelem f b = let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b); Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f [@CInline] let load_qelem_check f b = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); load_qelem f b; let h0 = ST.get () in let is_zero = is_qelem_zero f in assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0)); let is_lt_q = BN.bn_lt_mask qnlimb f n in SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n); assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0)); let m = logand (lognot is_zero) is_lt_q in lognot_lemma is_zero; logand_lemma (lognot is_zero) is_lt_q; pop_frame (); m
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
res: Hacl.K256.Scalar.qelem -> b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> FStar.HyperStack.ST.Stack Lib.IntTypes.uint64
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.K256.Scalar.qelem", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.uint64", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Prims._assert", "Prims.eq2", "Lib.Sequence.lseq", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.K256.Scalar.qnlimb", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Prims.op_Equality", "Prims.int", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.bool", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.ByteBuffer.buf_mask_select", "Hacl.K256.Scalar.create_one", "Lib.IntTypes.int_t", "Hacl.K256.Scalar.load_qelem_check", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let load_qelem_conditional res b =
push_frame (); let is_b_valid = load_qelem_check res b in let oneq = create_one () in let h0 = ST.get () in Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res; let h1 = ST.get () in assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res)); pop_frame (); is_b_valid
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.is_qelem_le_q_halved_vartime
val is_qelem_le_q_halved_vartime: f:qelem -> Stack bool (requires fun h -> live h f) (ensures fun h0 b h1 -> modifies0 h0 h1 /\ b == (qas_nat h0 f <= S.q / 2))
val is_qelem_le_q_halved_vartime: f:qelem -> Stack bool (requires fun h -> live h f) (ensures fun h0 b h1 -> modifies0 h0 h1 /\ b == (qas_nat h0 f <= S.q / 2))
let is_qelem_le_q_halved_vartime f = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in KL.is_qelem_le_q_halved_vartime4_lemma (a0,a1,a2,a3); is_qelem_le_q_halved_vartime4 (a0,a1,a2,a3)
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 45, "end_line": 367, "start_col": 0, "start_line": 361 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb let sub4: BN.bn_sub_eq_len_st U64 qnlimb = BN.bn_sub_eq_len qnlimb let add_mod4: BN.bn_add_mod_n_st U64 qnlimb = BN.bn_add_mod_n qnlimb let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb = BN.bn_sub_mod_n qnlimb let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a = BN.bn_mul qnlimb qnlimb a let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a = BN.bn_sqr qnlimb a inline_for_extraction noextract instance kn: BN.bn U64 = { BN.len = qnlimb; BN.add = add4; BN.sub = sub4; BN.add_mod_n = add_mod4; BN.sub_mod_n = sub_mod4; BN.mul = mul4; BN.sqr = sqr4 } let make_u64_4 out (f0, f1, f2, f3) = out.(0ul) <- f0; out.(1ul) <- f1; out.(2ul) <- f2; out.(3ul) <- f3; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h out); assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3)) let make_order_k256 () = [@inline_let] let r = (u64 0xbfd25e8cd0364141, u64 0xbaaedce6af48a03b, u64 0xfffffffffffffffe, u64 0xffffffffffffffff) in assert_norm (qas_nat4 r = S.q); r let create_qelem () = SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb); create qnlimb (u64 0) let create_one () = [@inline_let] let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in assert_norm (FStar.List.Tot.length l = 4); Seq.elim_of_list l; LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l); KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)); createL l [@CInline] let is_qelem_zero f = let h0 = ST.get () in SN.bn_is_zero_mask_lemma (as_seq h0 f); BN.bn_is_zero_mask qnlimb f [@CInline] let is_qelem_zero_vartime f = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3); is_qelem_zero_vartime4 (f0,f1,f2,f3) [@CInline] let is_qelem_eq_vartime f1 f2 = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f1); KL.qas_nat4_is_qas_nat (as_seq h f2); let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3); is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3) let load_qelem f b = let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b); Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f [@CInline] let load_qelem_check f b = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); load_qelem f b; let h0 = ST.get () in let is_zero = is_qelem_zero f in assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0)); let is_lt_q = BN.bn_lt_mask qnlimb f n in SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n); assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0)); let m = logand (lognot is_zero) is_lt_q in lognot_lemma is_zero; logand_lemma (lognot is_zero) is_lt_q; pop_frame (); m let load_qelem_conditional res b = push_frame (); let is_b_valid = load_qelem_check res b in let oneq = create_one () in let h0 = ST.get () in Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res; let h1 = ST.get () in assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res)); pop_frame (); is_b_valid [@CInline] let load_qelem_vartime f b = load_qelem f b; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let is_zero = is_qelem_zero_vartime f in let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in let is_lt_q_b = is_qelem_lt_q_vartime4 (a0,a1,a2,a3) in KL.is_qelem_lt_q_vartime4_lemma (a0,a1,a2,a3); not is_zero && is_lt_q_b val modq_short: out:qelem -> a:qelem -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == qas_nat h0 a % S.q) [@CInline] let modq_short out a = push_frame (); let tmp = create_qelem () in [@inline_let] let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in make_u64_4 tmp (t0,t1,t2,t3); let h0 = ST.get () in let c = kn.BN.add a tmp out in let mask = u64 0 -. c in map2T qnlimb out (BB.mask_select mask) out a; KL.mod_short_lseq_lemma (as_seq h0 a); pop_frame () [@CInline] let load_qelem_modq f b = push_frame (); let tmp = create_qelem () in load_qelem f b; copy tmp f; modq_short f tmp; pop_frame () [@CInline] let store_qelem b f = let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma #U64 32 (as_seq h0 f); Hacl.Bignum.Convert.mk_bn_to_bytes_be true 32ul f b [@CInline] let qadd out f1 f2 = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); let h0 = ST.get () in kn.BN.add_mod_n n f1 f2 out; SN.bn_add_mod_n_lemma (as_seq h0 n) (as_seq h0 f1) (as_seq h0 f2); pop_frame () val mul_pow2_256_minus_q_add: len:size_t -> resLen:size_t{2 + v len <= v resLen /\ 4 <= v resLen} -> t01:lbuffer uint64 2ul -> a:lbuffer uint64 len -> e:lbuffer uint64 4ul -> res:lbuffer uint64 resLen -> Stack (BB.carry U64) (requires fun h -> live h a /\ live h res /\ live h t01 /\ live h e /\ disjoint a res /\ disjoint a t01 /\ disjoint a e /\ disjoint res t01 /\ disjoint res e /\ disjoint t01 e /\ as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\ as_seq h res == LSeq.create (v resLen) (u64 0)) (ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\ (c, as_seq h1 res) == mul_pow2_256_minus_q_lseq_add (v len) (v resLen) (as_seq h0 a) (as_seq h0 e)) [@CInline] let mul_pow2_256_minus_q_add len resLen t01 a e res = push_frame (); let tmp = create (len +! 2ul) (u64 0) in BN.bn_mul len 2ul a t01 tmp; update_sub res 2ul len a; let _ = bn_add resLen res (len +! 2ul) tmp res in let c = bn_add resLen res 4ul e res in pop_frame (); c inline_for_extraction noextract val modq_before_final: t01:lbuffer uint64 2ul -> a:lbuffer uint64 (2ul *! qnlimb) -> out:qelem -> Stack (BB.carry U64) (requires fun h -> live h a /\ live h out /\ live h t01 /\ disjoint a out /\ disjoint a t01 /\ disjoint out t01 /\ as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\ as_seq h out == LSeq.create 4 (u64 0)) (ensures fun h0 c h1 -> modifies (loc out) h0 h1 /\ (c, as_seq h1 out) == mod_lseq_before_final (as_seq h0 a)) let modq_before_final t01 a out = push_frame (); let m = create 7ul (u64 0) in let p = create 5ul (u64 0) in let c0 = mul_pow2_256_minus_q_add 4ul 7ul t01 (sub a 4ul 4ul) (sub a 0ul 4ul) m in let c1 = mul_pow2_256_minus_q_add 3ul 5ul t01 (sub m 4ul 3ul) (sub m 0ul 4ul) p in let c2 = mul_pow2_256_minus_q_add 1ul 4ul t01 (sub p 4ul 1ul) (sub p 0ul 4ul) out in pop_frame (); c2 val modq: out:qelem -> a:lbuffer uint64 (2ul *! qnlimb) -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == BD.bn_v h0 a % S.q) [@CInline] let modq out a = push_frame (); let r = create_qelem () in let tmp = create_qelem () in [@inline_let] let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in make_u64_4 tmp (t0,t1,t2,t3); let t01 = sub tmp 0ul 2ul in let h0 = ST.get () in assert (Seq.equal (as_seq h0 t01) (LSeq.create2 t0 t1)); let c0 = modq_before_final t01 a r in let c1 = kn.BN.add r tmp out in let mask = u64 0 -. (c0 +. c1) in map2T qnlimb out (BB.mask_select mask) out r; let h1 = ST.get () in KL.mod_lseq_lemma (as_seq h0 a); pop_frame () [@CInline] let qmul out f1 f2 = push_frame (); let h0 = ST.get () in let tmp = create (2ul *! qnlimb) (u64 0) in kn.BN.mul f1 f2 tmp; SN.bn_mul_lemma (as_seq h0 f1) (as_seq h0 f2); modq out tmp; pop_frame () [@CInline] let qsqr out f = push_frame (); let h0 = ST.get () in let tmp = create (2ul *! qnlimb) (u64 0) in kn.BN.sqr f tmp; SN.bn_sqr_lemma (as_seq h0 f); modq out tmp; pop_frame () [@CInline] let qnegate_conditional_vartime f is_negate = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); let zero = create_qelem () in if is_negate then begin let h0 = ST.get () in kn.BN.sub_mod_n n zero f f; SN.bn_sub_mod_n_lemma (as_seq h0 n) (as_seq h0 zero) (as_seq h0 f); let h1 = ST.get () in assert (qas_nat h1 f = (0 - qas_nat h0 f) % S.q); Math.Lemmas.modulo_addition_lemma (- qas_nat h0 f) S.q 1; assert (qas_nat h1 f == (S.q - qas_nat h0 f) % S.q) end; pop_frame ()
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: Hacl.K256.Scalar.qelem -> FStar.HyperStack.ST.Stack Prims.bool
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.K256.Scalar.qelem", "Lib.IntTypes.uint64", "Hacl.Spec.K256.Scalar.is_qelem_le_q_halved_vartime4", "FStar.Pervasives.Native.Mktuple4", "Prims.unit", "Hacl.Spec.K256.Scalar.Lemmas.is_qelem_le_q_halved_vartime4_lemma", "Prims.bool", "FStar.Pervasives.Native.tuple4", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT", "Hacl.K256.Scalar.qnlimb", "FStar.UInt32.__uint_to_t", "Hacl.Spec.K256.Scalar.Lemmas.qas_nat4_is_qas_nat", "Lib.Buffer.as_seq", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get" ]
[]
false
true
false
false
false
let is_qelem_le_q_halved_vartime f =
let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let a0, a1, a2, a3 = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in KL.is_qelem_le_q_halved_vartime4_lemma (a0, a1, a2, a3); is_qelem_le_q_halved_vartime4 (a0, a1, a2, a3)
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.modq_short
val modq_short: out:qelem -> a:qelem -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == qas_nat h0 a % S.q)
val modq_short: out:qelem -> a:qelem -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == qas_nat h0 a % S.q)
let modq_short out a = push_frame (); let tmp = create_qelem () in [@inline_let] let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in make_u64_4 tmp (t0,t1,t2,t3); let h0 = ST.get () in let c = kn.BN.add a tmp out in let mask = u64 0 -. c in map2T qnlimb out (BB.mask_select mask) out a; KL.mod_short_lseq_lemma (as_seq h0 a); pop_frame ()
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 14, "end_line": 202, "start_col": 0, "start_line": 190 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb let sub4: BN.bn_sub_eq_len_st U64 qnlimb = BN.bn_sub_eq_len qnlimb let add_mod4: BN.bn_add_mod_n_st U64 qnlimb = BN.bn_add_mod_n qnlimb let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb = BN.bn_sub_mod_n qnlimb let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a = BN.bn_mul qnlimb qnlimb a let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a = BN.bn_sqr qnlimb a inline_for_extraction noextract instance kn: BN.bn U64 = { BN.len = qnlimb; BN.add = add4; BN.sub = sub4; BN.add_mod_n = add_mod4; BN.sub_mod_n = sub_mod4; BN.mul = mul4; BN.sqr = sqr4 } let make_u64_4 out (f0, f1, f2, f3) = out.(0ul) <- f0; out.(1ul) <- f1; out.(2ul) <- f2; out.(3ul) <- f3; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h out); assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3)) let make_order_k256 () = [@inline_let] let r = (u64 0xbfd25e8cd0364141, u64 0xbaaedce6af48a03b, u64 0xfffffffffffffffe, u64 0xffffffffffffffff) in assert_norm (qas_nat4 r = S.q); r let create_qelem () = SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb); create qnlimb (u64 0) let create_one () = [@inline_let] let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in assert_norm (FStar.List.Tot.length l = 4); Seq.elim_of_list l; LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l); KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)); createL l [@CInline] let is_qelem_zero f = let h0 = ST.get () in SN.bn_is_zero_mask_lemma (as_seq h0 f); BN.bn_is_zero_mask qnlimb f [@CInline] let is_qelem_zero_vartime f = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3); is_qelem_zero_vartime4 (f0,f1,f2,f3) [@CInline] let is_qelem_eq_vartime f1 f2 = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f1); KL.qas_nat4_is_qas_nat (as_seq h f2); let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3); is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3) let load_qelem f b = let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b); Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f [@CInline] let load_qelem_check f b = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); load_qelem f b; let h0 = ST.get () in let is_zero = is_qelem_zero f in assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0)); let is_lt_q = BN.bn_lt_mask qnlimb f n in SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n); assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0)); let m = logand (lognot is_zero) is_lt_q in lognot_lemma is_zero; logand_lemma (lognot is_zero) is_lt_q; pop_frame (); m let load_qelem_conditional res b = push_frame (); let is_b_valid = load_qelem_check res b in let oneq = create_one () in let h0 = ST.get () in Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res; let h1 = ST.get () in assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res)); pop_frame (); is_b_valid [@CInline] let load_qelem_vartime f b = load_qelem f b; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let is_zero = is_qelem_zero_vartime f in let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in let is_lt_q_b = is_qelem_lt_q_vartime4 (a0,a1,a2,a3) in KL.is_qelem_lt_q_vartime4_lemma (a0,a1,a2,a3); not is_zero && is_lt_q_b val modq_short: out:qelem -> a:qelem -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == qas_nat h0 a % S.q)
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
out: Hacl.K256.Scalar.qelem -> a: Hacl.K256.Scalar.qelem -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.K256.Scalar.qelem", "Lib.IntTypes.uint64", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Spec.K256.Scalar.Lemmas.mod_short_lseq_lemma", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Hacl.K256.Scalar.qnlimb", "Lib.Buffer.map2T", "Hacl.Spec.Bignum.Base.mask_select", "Lib.IntTypes.U64", "Lib.IntTypes.int_t", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Subtraction_Dot", "Lib.IntTypes.u64", "Hacl.Spec.Bignum.Base.carry", "Hacl.Bignum.__proj__Mkbn__item__add", "Hacl.K256.Scalar.kn", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.K256.Scalar.make_u64_4", "FStar.Pervasives.Native.Mktuple4", "Hacl.Spec.K256.Scalar.qelem4", "Hacl.Spec.K256.Scalar.make_pow2_256_minus_order_k256", "Hacl.K256.Scalar.create_qelem", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let modq_short out a =
push_frame (); let tmp = create_qelem () in [@@ inline_let ]let t0, t1, t2, t3 = make_pow2_256_minus_order_k256 () in make_u64_4 tmp (t0, t1, t2, t3); let h0 = ST.get () in let c = kn.BN.add a tmp out in let mask = u64 0 -. c in map2T qnlimb out (BB.mask_select mask) out a; KL.mod_short_lseq_lemma (as_seq h0 a); pop_frame ()
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.load_qelem_modq
val load_qelem_modq: f:qelem -> b:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h f /\ live h b /\ disjoint f b) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ qas_nat h1 f == BSeq.nat_from_bytes_be (as_seq h0 b) % S.q /\ qe_lt_q h1 f)
val load_qelem_modq: f:qelem -> b:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h f /\ live h b /\ disjoint f b) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ qas_nat h1 f == BSeq.nat_from_bytes_be (as_seq h0 b) % S.q /\ qe_lt_q h1 f)
let load_qelem_modq f b = push_frame (); let tmp = create_qelem () in load_qelem f b; copy tmp f; modq_short f tmp; pop_frame ()
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 14, "end_line": 212, "start_col": 0, "start_line": 206 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb let sub4: BN.bn_sub_eq_len_st U64 qnlimb = BN.bn_sub_eq_len qnlimb let add_mod4: BN.bn_add_mod_n_st U64 qnlimb = BN.bn_add_mod_n qnlimb let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb = BN.bn_sub_mod_n qnlimb let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a = BN.bn_mul qnlimb qnlimb a let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a = BN.bn_sqr qnlimb a inline_for_extraction noextract instance kn: BN.bn U64 = { BN.len = qnlimb; BN.add = add4; BN.sub = sub4; BN.add_mod_n = add_mod4; BN.sub_mod_n = sub_mod4; BN.mul = mul4; BN.sqr = sqr4 } let make_u64_4 out (f0, f1, f2, f3) = out.(0ul) <- f0; out.(1ul) <- f1; out.(2ul) <- f2; out.(3ul) <- f3; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h out); assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3)) let make_order_k256 () = [@inline_let] let r = (u64 0xbfd25e8cd0364141, u64 0xbaaedce6af48a03b, u64 0xfffffffffffffffe, u64 0xffffffffffffffff) in assert_norm (qas_nat4 r = S.q); r let create_qelem () = SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb); create qnlimb (u64 0) let create_one () = [@inline_let] let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in assert_norm (FStar.List.Tot.length l = 4); Seq.elim_of_list l; LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l); KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)); createL l [@CInline] let is_qelem_zero f = let h0 = ST.get () in SN.bn_is_zero_mask_lemma (as_seq h0 f); BN.bn_is_zero_mask qnlimb f [@CInline] let is_qelem_zero_vartime f = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3); is_qelem_zero_vartime4 (f0,f1,f2,f3) [@CInline] let is_qelem_eq_vartime f1 f2 = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f1); KL.qas_nat4_is_qas_nat (as_seq h f2); let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3); is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3) let load_qelem f b = let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b); Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f [@CInline] let load_qelem_check f b = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); load_qelem f b; let h0 = ST.get () in let is_zero = is_qelem_zero f in assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0)); let is_lt_q = BN.bn_lt_mask qnlimb f n in SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n); assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0)); let m = logand (lognot is_zero) is_lt_q in lognot_lemma is_zero; logand_lemma (lognot is_zero) is_lt_q; pop_frame (); m let load_qelem_conditional res b = push_frame (); let is_b_valid = load_qelem_check res b in let oneq = create_one () in let h0 = ST.get () in Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res; let h1 = ST.get () in assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res)); pop_frame (); is_b_valid [@CInline] let load_qelem_vartime f b = load_qelem f b; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let is_zero = is_qelem_zero_vartime f in let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in let is_lt_q_b = is_qelem_lt_q_vartime4 (a0,a1,a2,a3) in KL.is_qelem_lt_q_vartime4_lemma (a0,a1,a2,a3); not is_zero && is_lt_q_b val modq_short: out:qelem -> a:qelem -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == qas_nat h0 a % S.q) [@CInline] let modq_short out a = push_frame (); let tmp = create_qelem () in [@inline_let] let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in make_u64_4 tmp (t0,t1,t2,t3); let h0 = ST.get () in let c = kn.BN.add a tmp out in let mask = u64 0 -. c in map2T qnlimb out (BB.mask_select mask) out a; KL.mod_short_lseq_lemma (as_seq h0 a); pop_frame ()
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: Hacl.K256.Scalar.qelem -> b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.K256.Scalar.qelem", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.K256.Scalar.modq_short", "Lib.Buffer.copy", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "Hacl.K256.Scalar.qnlimb", "Hacl.K256.Scalar.load_qelem", "Hacl.K256.Scalar.create_qelem", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let load_qelem_modq f b =
push_frame (); let tmp = create_qelem () in load_qelem f b; copy tmp f; modq_short f tmp; pop_frame ()
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.qnegate_conditional_vartime
val qnegate_conditional_vartime (f:qelem) (is_negate:bool) : Stack unit (requires fun h -> live h f /\ qe_lt_q h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ qe_lt_q h1 f /\ qas_nat h1 f == (if is_negate then (S.q - qas_nat h0 f) % S.q else qas_nat h0 f))
val qnegate_conditional_vartime (f:qelem) (is_negate:bool) : Stack unit (requires fun h -> live h f /\ qe_lt_q h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ qe_lt_q h1 f /\ qas_nat h1 f == (if is_negate then (S.q - qas_nat h0 f) % S.q else qas_nat h0 f))
let qnegate_conditional_vartime f is_negate = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); let zero = create_qelem () in if is_negate then begin let h0 = ST.get () in kn.BN.sub_mod_n n zero f f; SN.bn_sub_mod_n_lemma (as_seq h0 n) (as_seq h0 zero) (as_seq h0 f); let h1 = ST.get () in assert (qas_nat h1 f = (0 - qas_nat h0 f) % S.q); Math.Lemmas.modulo_addition_lemma (- qas_nat h0 f) S.q 1; assert (qas_nat h1 f == (S.q - qas_nat h0 f) % S.q) end; pop_frame ()
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 14, "end_line": 357, "start_col": 0, "start_line": 343 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb let sub4: BN.bn_sub_eq_len_st U64 qnlimb = BN.bn_sub_eq_len qnlimb let add_mod4: BN.bn_add_mod_n_st U64 qnlimb = BN.bn_add_mod_n qnlimb let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb = BN.bn_sub_mod_n qnlimb let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a = BN.bn_mul qnlimb qnlimb a let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a = BN.bn_sqr qnlimb a inline_for_extraction noextract instance kn: BN.bn U64 = { BN.len = qnlimb; BN.add = add4; BN.sub = sub4; BN.add_mod_n = add_mod4; BN.sub_mod_n = sub_mod4; BN.mul = mul4; BN.sqr = sqr4 } let make_u64_4 out (f0, f1, f2, f3) = out.(0ul) <- f0; out.(1ul) <- f1; out.(2ul) <- f2; out.(3ul) <- f3; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h out); assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3)) let make_order_k256 () = [@inline_let] let r = (u64 0xbfd25e8cd0364141, u64 0xbaaedce6af48a03b, u64 0xfffffffffffffffe, u64 0xffffffffffffffff) in assert_norm (qas_nat4 r = S.q); r let create_qelem () = SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb); create qnlimb (u64 0) let create_one () = [@inline_let] let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in assert_norm (FStar.List.Tot.length l = 4); Seq.elim_of_list l; LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l); KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)); createL l [@CInline] let is_qelem_zero f = let h0 = ST.get () in SN.bn_is_zero_mask_lemma (as_seq h0 f); BN.bn_is_zero_mask qnlimb f [@CInline] let is_qelem_zero_vartime f = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3); is_qelem_zero_vartime4 (f0,f1,f2,f3) [@CInline] let is_qelem_eq_vartime f1 f2 = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f1); KL.qas_nat4_is_qas_nat (as_seq h f2); let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3); is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3) let load_qelem f b = let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b); Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f [@CInline] let load_qelem_check f b = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); load_qelem f b; let h0 = ST.get () in let is_zero = is_qelem_zero f in assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0)); let is_lt_q = BN.bn_lt_mask qnlimb f n in SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n); assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0)); let m = logand (lognot is_zero) is_lt_q in lognot_lemma is_zero; logand_lemma (lognot is_zero) is_lt_q; pop_frame (); m let load_qelem_conditional res b = push_frame (); let is_b_valid = load_qelem_check res b in let oneq = create_one () in let h0 = ST.get () in Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res; let h1 = ST.get () in assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res)); pop_frame (); is_b_valid [@CInline] let load_qelem_vartime f b = load_qelem f b; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let is_zero = is_qelem_zero_vartime f in let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in let is_lt_q_b = is_qelem_lt_q_vartime4 (a0,a1,a2,a3) in KL.is_qelem_lt_q_vartime4_lemma (a0,a1,a2,a3); not is_zero && is_lt_q_b val modq_short: out:qelem -> a:qelem -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == qas_nat h0 a % S.q) [@CInline] let modq_short out a = push_frame (); let tmp = create_qelem () in [@inline_let] let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in make_u64_4 tmp (t0,t1,t2,t3); let h0 = ST.get () in let c = kn.BN.add a tmp out in let mask = u64 0 -. c in map2T qnlimb out (BB.mask_select mask) out a; KL.mod_short_lseq_lemma (as_seq h0 a); pop_frame () [@CInline] let load_qelem_modq f b = push_frame (); let tmp = create_qelem () in load_qelem f b; copy tmp f; modq_short f tmp; pop_frame () [@CInline] let store_qelem b f = let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma #U64 32 (as_seq h0 f); Hacl.Bignum.Convert.mk_bn_to_bytes_be true 32ul f b [@CInline] let qadd out f1 f2 = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); let h0 = ST.get () in kn.BN.add_mod_n n f1 f2 out; SN.bn_add_mod_n_lemma (as_seq h0 n) (as_seq h0 f1) (as_seq h0 f2); pop_frame () val mul_pow2_256_minus_q_add: len:size_t -> resLen:size_t{2 + v len <= v resLen /\ 4 <= v resLen} -> t01:lbuffer uint64 2ul -> a:lbuffer uint64 len -> e:lbuffer uint64 4ul -> res:lbuffer uint64 resLen -> Stack (BB.carry U64) (requires fun h -> live h a /\ live h res /\ live h t01 /\ live h e /\ disjoint a res /\ disjoint a t01 /\ disjoint a e /\ disjoint res t01 /\ disjoint res e /\ disjoint t01 e /\ as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\ as_seq h res == LSeq.create (v resLen) (u64 0)) (ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\ (c, as_seq h1 res) == mul_pow2_256_minus_q_lseq_add (v len) (v resLen) (as_seq h0 a) (as_seq h0 e)) [@CInline] let mul_pow2_256_minus_q_add len resLen t01 a e res = push_frame (); let tmp = create (len +! 2ul) (u64 0) in BN.bn_mul len 2ul a t01 tmp; update_sub res 2ul len a; let _ = bn_add resLen res (len +! 2ul) tmp res in let c = bn_add resLen res 4ul e res in pop_frame (); c inline_for_extraction noextract val modq_before_final: t01:lbuffer uint64 2ul -> a:lbuffer uint64 (2ul *! qnlimb) -> out:qelem -> Stack (BB.carry U64) (requires fun h -> live h a /\ live h out /\ live h t01 /\ disjoint a out /\ disjoint a t01 /\ disjoint out t01 /\ as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\ as_seq h out == LSeq.create 4 (u64 0)) (ensures fun h0 c h1 -> modifies (loc out) h0 h1 /\ (c, as_seq h1 out) == mod_lseq_before_final (as_seq h0 a)) let modq_before_final t01 a out = push_frame (); let m = create 7ul (u64 0) in let p = create 5ul (u64 0) in let c0 = mul_pow2_256_minus_q_add 4ul 7ul t01 (sub a 4ul 4ul) (sub a 0ul 4ul) m in let c1 = mul_pow2_256_minus_q_add 3ul 5ul t01 (sub m 4ul 3ul) (sub m 0ul 4ul) p in let c2 = mul_pow2_256_minus_q_add 1ul 4ul t01 (sub p 4ul 1ul) (sub p 0ul 4ul) out in pop_frame (); c2 val modq: out:qelem -> a:lbuffer uint64 (2ul *! qnlimb) -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == BD.bn_v h0 a % S.q) [@CInline] let modq out a = push_frame (); let r = create_qelem () in let tmp = create_qelem () in [@inline_let] let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in make_u64_4 tmp (t0,t1,t2,t3); let t01 = sub tmp 0ul 2ul in let h0 = ST.get () in assert (Seq.equal (as_seq h0 t01) (LSeq.create2 t0 t1)); let c0 = modq_before_final t01 a r in let c1 = kn.BN.add r tmp out in let mask = u64 0 -. (c0 +. c1) in map2T qnlimb out (BB.mask_select mask) out r; let h1 = ST.get () in KL.mod_lseq_lemma (as_seq h0 a); pop_frame () [@CInline] let qmul out f1 f2 = push_frame (); let h0 = ST.get () in let tmp = create (2ul *! qnlimb) (u64 0) in kn.BN.mul f1 f2 tmp; SN.bn_mul_lemma (as_seq h0 f1) (as_seq h0 f2); modq out tmp; pop_frame () [@CInline] let qsqr out f = push_frame (); let h0 = ST.get () in let tmp = create (2ul *! qnlimb) (u64 0) in kn.BN.sqr f tmp; SN.bn_sqr_lemma (as_seq h0 f); modq out tmp; pop_frame ()
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: Hacl.K256.Scalar.qelem -> is_negate: Prims.bool -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.K256.Scalar.qelem", "Prims.bool", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Prims._assert", "Prims.eq2", "Prims.int", "Hacl.K256.Scalar.qas_nat", "Prims.op_Modulus", "Prims.op_Subtraction", "Spec.K256.PointOps.q", "FStar.Math.Lemmas.modulo_addition_lemma", "Prims.op_Minus", "Prims.b2t", "Prims.op_Equality", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Spec.Bignum.bn_sub_mod_n_lemma", "Lib.IntTypes.U64", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.K256.Scalar.qnlimb", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "Hacl.Bignum.__proj__Mkbn__item__sub_mod_n", "Hacl.K256.Scalar.kn", "Hacl.K256.Scalar.create_qelem", "Hacl.K256.Scalar.make_u64_4", "Hacl.K256.Scalar.make_order_k256", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let qnegate_conditional_vartime f is_negate =
push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); let zero = create_qelem () in if is_negate then (let h0 = ST.get () in kn.BN.sub_mod_n n zero f f; SN.bn_sub_mod_n_lemma (as_seq h0 n) (as_seq h0 zero) (as_seq h0 f); let h1 = ST.get () in assert (qas_nat h1 f = (0 - qas_nat h0 f) % S.q); Math.Lemmas.modulo_addition_lemma (- qas_nat h0 f) S.q 1; assert (qas_nat h1 f == (S.q - qas_nat h0 f) % S.q)); pop_frame ()
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.load_qelem_check
val load_qelem_check: f:qelem -> b:lbuffer uint8 32ul -> Stack uint64 (requires fun h -> live h f /\ live h b /\ disjoint f b) (ensures fun h0 m h1 -> modifies (loc f) h0 h1 /\ (let b_nat = BSeq.nat_from_bytes_be (as_seq h0 b) in qas_nat h1 f == b_nat /\ (v m = ones_v U64 \/ v m = 0) /\ (v m = ones_v U64) = (0 < b_nat && b_nat < S.q)))
val load_qelem_check: f:qelem -> b:lbuffer uint8 32ul -> Stack uint64 (requires fun h -> live h f /\ live h b /\ disjoint f b) (ensures fun h0 m h1 -> modifies (loc f) h0 h1 /\ (let b_nat = BSeq.nat_from_bytes_be (as_seq h0 b) in qas_nat h1 f == b_nat /\ (v m = ones_v U64 \/ v m = 0) /\ (v m = ones_v U64) = (0 < b_nat && b_nat < S.q)))
let load_qelem_check f b = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); load_qelem f b; let h0 = ST.get () in let is_zero = is_qelem_zero f in assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0)); let is_lt_q = BN.bn_lt_mask qnlimb f n in SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n); assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0)); let m = logand (lognot is_zero) is_lt_q in lognot_lemma is_zero; logand_lemma (lognot is_zero) is_lt_q; pop_frame (); m
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 155, "start_col": 0, "start_line": 139 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb let sub4: BN.bn_sub_eq_len_st U64 qnlimb = BN.bn_sub_eq_len qnlimb let add_mod4: BN.bn_add_mod_n_st U64 qnlimb = BN.bn_add_mod_n qnlimb let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb = BN.bn_sub_mod_n qnlimb let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a = BN.bn_mul qnlimb qnlimb a let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a = BN.bn_sqr qnlimb a inline_for_extraction noextract instance kn: BN.bn U64 = { BN.len = qnlimb; BN.add = add4; BN.sub = sub4; BN.add_mod_n = add_mod4; BN.sub_mod_n = sub_mod4; BN.mul = mul4; BN.sqr = sqr4 } let make_u64_4 out (f0, f1, f2, f3) = out.(0ul) <- f0; out.(1ul) <- f1; out.(2ul) <- f2; out.(3ul) <- f3; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h out); assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3)) let make_order_k256 () = [@inline_let] let r = (u64 0xbfd25e8cd0364141, u64 0xbaaedce6af48a03b, u64 0xfffffffffffffffe, u64 0xffffffffffffffff) in assert_norm (qas_nat4 r = S.q); r let create_qelem () = SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb); create qnlimb (u64 0) let create_one () = [@inline_let] let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in assert_norm (FStar.List.Tot.length l = 4); Seq.elim_of_list l; LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l); KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)); createL l [@CInline] let is_qelem_zero f = let h0 = ST.get () in SN.bn_is_zero_mask_lemma (as_seq h0 f); BN.bn_is_zero_mask qnlimb f [@CInline] let is_qelem_zero_vartime f = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3); is_qelem_zero_vartime4 (f0,f1,f2,f3) [@CInline] let is_qelem_eq_vartime f1 f2 = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f1); KL.qas_nat4_is_qas_nat (as_seq h f2); let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3); is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3) let load_qelem f b = let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b); Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: Hacl.K256.Scalar.qelem -> b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> FStar.HyperStack.ST.Stack Lib.IntTypes.uint64
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.K256.Scalar.qelem", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.uint64", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Lib.IntTypes.logand_lemma", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.IntTypes.lognot", "Lib.IntTypes.lognot_lemma", "Lib.IntTypes.int_t", "Lib.IntTypes.logand", "Prims._assert", "Prims.eq2", "Prims.int", "Lib.IntTypes.v", "Prims.op_LessThan", "Hacl.K256.Scalar.qas_nat", "Spec.K256.PointOps.q", "Lib.IntTypes.ones_v", "Prims.bool", "Hacl.Spec.Bignum.bn_lt_mask_lemma", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.K256.Scalar.qnlimb", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Hacl.Bignum.bn_lt_mask", "Prims.op_Equality", "Hacl.K256.Scalar.is_qelem_zero", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.K256.Scalar.load_qelem", "Hacl.K256.Scalar.make_u64_4", "Hacl.K256.Scalar.make_order_k256", "Hacl.K256.Scalar.create_qelem", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let load_qelem_check f b =
push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); load_qelem f b; let h0 = ST.get () in let is_zero = is_qelem_zero f in assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0)); let is_lt_q = BN.bn_lt_mask qnlimb f n in SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n); assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0)); let m = logand (lognot is_zero) is_lt_q in lognot_lemma is_zero; logand_lemma (lognot is_zero) is_lt_q; pop_frame (); m
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.rshift_update_sub
val rshift_update_sub: res:qelem -> l:lbuffer uint64 8ul -> Stack unit (requires fun h -> live h res /\ live h l /\ disjoint res l /\ as_seq h res == LSeq.create 4 (u64 0)) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ (let res_b = SN.bn_rshift (as_seq h0 l) 6 in let res_b_padded = LSeq.create 4 (u64 0) in let res_b_padded = LSeq.update_sub res_b_padded 0 2 res_b in as_seq h1 res == res_b_padded))
val rshift_update_sub: res:qelem -> l:lbuffer uint64 8ul -> Stack unit (requires fun h -> live h res /\ live h l /\ disjoint res l /\ as_seq h res == LSeq.create 4 (u64 0)) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ (let res_b = SN.bn_rshift (as_seq h0 l) 6 in let res_b_padded = LSeq.create 4 (u64 0) in let res_b_padded = LSeq.update_sub res_b_padded 0 2 res_b in as_seq h1 res == res_b_padded))
let rshift_update_sub res l = let h1 = ST.get () in update_sub_f h1 res 0ul 2ul (fun h -> SN.bn_rshift (as_seq h1 l) 6) (fun _ -> BN.bn_rshift 8ul l 6ul (sub res 0ul 2ul))
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 55, "end_line": 396, "start_col": 0, "start_line": 392 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb let sub4: BN.bn_sub_eq_len_st U64 qnlimb = BN.bn_sub_eq_len qnlimb let add_mod4: BN.bn_add_mod_n_st U64 qnlimb = BN.bn_add_mod_n qnlimb let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb = BN.bn_sub_mod_n qnlimb let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a = BN.bn_mul qnlimb qnlimb a let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a = BN.bn_sqr qnlimb a inline_for_extraction noextract instance kn: BN.bn U64 = { BN.len = qnlimb; BN.add = add4; BN.sub = sub4; BN.add_mod_n = add_mod4; BN.sub_mod_n = sub_mod4; BN.mul = mul4; BN.sqr = sqr4 } let make_u64_4 out (f0, f1, f2, f3) = out.(0ul) <- f0; out.(1ul) <- f1; out.(2ul) <- f2; out.(3ul) <- f3; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h out); assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3)) let make_order_k256 () = [@inline_let] let r = (u64 0xbfd25e8cd0364141, u64 0xbaaedce6af48a03b, u64 0xfffffffffffffffe, u64 0xffffffffffffffff) in assert_norm (qas_nat4 r = S.q); r let create_qelem () = SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb); create qnlimb (u64 0) let create_one () = [@inline_let] let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in assert_norm (FStar.List.Tot.length l = 4); Seq.elim_of_list l; LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l); KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)); createL l [@CInline] let is_qelem_zero f = let h0 = ST.get () in SN.bn_is_zero_mask_lemma (as_seq h0 f); BN.bn_is_zero_mask qnlimb f [@CInline] let is_qelem_zero_vartime f = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3); is_qelem_zero_vartime4 (f0,f1,f2,f3) [@CInline] let is_qelem_eq_vartime f1 f2 = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f1); KL.qas_nat4_is_qas_nat (as_seq h f2); let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3); is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3) let load_qelem f b = let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b); Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f [@CInline] let load_qelem_check f b = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); load_qelem f b; let h0 = ST.get () in let is_zero = is_qelem_zero f in assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0)); let is_lt_q = BN.bn_lt_mask qnlimb f n in SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n); assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0)); let m = logand (lognot is_zero) is_lt_q in lognot_lemma is_zero; logand_lemma (lognot is_zero) is_lt_q; pop_frame (); m let load_qelem_conditional res b = push_frame (); let is_b_valid = load_qelem_check res b in let oneq = create_one () in let h0 = ST.get () in Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res; let h1 = ST.get () in assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res)); pop_frame (); is_b_valid [@CInline] let load_qelem_vartime f b = load_qelem f b; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let is_zero = is_qelem_zero_vartime f in let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in let is_lt_q_b = is_qelem_lt_q_vartime4 (a0,a1,a2,a3) in KL.is_qelem_lt_q_vartime4_lemma (a0,a1,a2,a3); not is_zero && is_lt_q_b val modq_short: out:qelem -> a:qelem -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == qas_nat h0 a % S.q) [@CInline] let modq_short out a = push_frame (); let tmp = create_qelem () in [@inline_let] let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in make_u64_4 tmp (t0,t1,t2,t3); let h0 = ST.get () in let c = kn.BN.add a tmp out in let mask = u64 0 -. c in map2T qnlimb out (BB.mask_select mask) out a; KL.mod_short_lseq_lemma (as_seq h0 a); pop_frame () [@CInline] let load_qelem_modq f b = push_frame (); let tmp = create_qelem () in load_qelem f b; copy tmp f; modq_short f tmp; pop_frame () [@CInline] let store_qelem b f = let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma #U64 32 (as_seq h0 f); Hacl.Bignum.Convert.mk_bn_to_bytes_be true 32ul f b [@CInline] let qadd out f1 f2 = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); let h0 = ST.get () in kn.BN.add_mod_n n f1 f2 out; SN.bn_add_mod_n_lemma (as_seq h0 n) (as_seq h0 f1) (as_seq h0 f2); pop_frame () val mul_pow2_256_minus_q_add: len:size_t -> resLen:size_t{2 + v len <= v resLen /\ 4 <= v resLen} -> t01:lbuffer uint64 2ul -> a:lbuffer uint64 len -> e:lbuffer uint64 4ul -> res:lbuffer uint64 resLen -> Stack (BB.carry U64) (requires fun h -> live h a /\ live h res /\ live h t01 /\ live h e /\ disjoint a res /\ disjoint a t01 /\ disjoint a e /\ disjoint res t01 /\ disjoint res e /\ disjoint t01 e /\ as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\ as_seq h res == LSeq.create (v resLen) (u64 0)) (ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\ (c, as_seq h1 res) == mul_pow2_256_minus_q_lseq_add (v len) (v resLen) (as_seq h0 a) (as_seq h0 e)) [@CInline] let mul_pow2_256_minus_q_add len resLen t01 a e res = push_frame (); let tmp = create (len +! 2ul) (u64 0) in BN.bn_mul len 2ul a t01 tmp; update_sub res 2ul len a; let _ = bn_add resLen res (len +! 2ul) tmp res in let c = bn_add resLen res 4ul e res in pop_frame (); c inline_for_extraction noextract val modq_before_final: t01:lbuffer uint64 2ul -> a:lbuffer uint64 (2ul *! qnlimb) -> out:qelem -> Stack (BB.carry U64) (requires fun h -> live h a /\ live h out /\ live h t01 /\ disjoint a out /\ disjoint a t01 /\ disjoint out t01 /\ as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\ as_seq h out == LSeq.create 4 (u64 0)) (ensures fun h0 c h1 -> modifies (loc out) h0 h1 /\ (c, as_seq h1 out) == mod_lseq_before_final (as_seq h0 a)) let modq_before_final t01 a out = push_frame (); let m = create 7ul (u64 0) in let p = create 5ul (u64 0) in let c0 = mul_pow2_256_minus_q_add 4ul 7ul t01 (sub a 4ul 4ul) (sub a 0ul 4ul) m in let c1 = mul_pow2_256_minus_q_add 3ul 5ul t01 (sub m 4ul 3ul) (sub m 0ul 4ul) p in let c2 = mul_pow2_256_minus_q_add 1ul 4ul t01 (sub p 4ul 1ul) (sub p 0ul 4ul) out in pop_frame (); c2 val modq: out:qelem -> a:lbuffer uint64 (2ul *! qnlimb) -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == BD.bn_v h0 a % S.q) [@CInline] let modq out a = push_frame (); let r = create_qelem () in let tmp = create_qelem () in [@inline_let] let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in make_u64_4 tmp (t0,t1,t2,t3); let t01 = sub tmp 0ul 2ul in let h0 = ST.get () in assert (Seq.equal (as_seq h0 t01) (LSeq.create2 t0 t1)); let c0 = modq_before_final t01 a r in let c1 = kn.BN.add r tmp out in let mask = u64 0 -. (c0 +. c1) in map2T qnlimb out (BB.mask_select mask) out r; let h1 = ST.get () in KL.mod_lseq_lemma (as_seq h0 a); pop_frame () [@CInline] let qmul out f1 f2 = push_frame (); let h0 = ST.get () in let tmp = create (2ul *! qnlimb) (u64 0) in kn.BN.mul f1 f2 tmp; SN.bn_mul_lemma (as_seq h0 f1) (as_seq h0 f2); modq out tmp; pop_frame () [@CInline] let qsqr out f = push_frame (); let h0 = ST.get () in let tmp = create (2ul *! qnlimb) (u64 0) in kn.BN.sqr f tmp; SN.bn_sqr_lemma (as_seq h0 f); modq out tmp; pop_frame () [@CInline] let qnegate_conditional_vartime f is_negate = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); let zero = create_qelem () in if is_negate then begin let h0 = ST.get () in kn.BN.sub_mod_n n zero f f; SN.bn_sub_mod_n_lemma (as_seq h0 n) (as_seq h0 zero) (as_seq h0 f); let h1 = ST.get () in assert (qas_nat h1 f = (0 - qas_nat h0 f) % S.q); Math.Lemmas.modulo_addition_lemma (- qas_nat h0 f) S.q 1; assert (qas_nat h1 f == (S.q - qas_nat h0 f) % S.q) end; pop_frame () [@CInline] let is_qelem_le_q_halved_vartime f = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in KL.is_qelem_le_q_halved_vartime4_lemma (a0,a1,a2,a3); is_qelem_le_q_halved_vartime4 (a0,a1,a2,a3) let is_qelem_lt_pow2_128_vartime f = let open Lib.RawIntTypes in let h0 = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h0 f); let f0 = Ghost.hide (LSeq.index (as_seq h0 f) 0) in let f1 = Ghost.hide (LSeq.index (as_seq h0 f) 1) in let f2 = f.(2ul) in let f3 = f.(3ul) in KL.is_qelem_lt_pow2_128_vartime4_lemma (Ghost.reveal f0, Ghost.reveal f1,f2,f3); u64_to_UInt64 f2 =. 0uL && u64_to_UInt64 f3 =. 0uL inline_for_extraction noextract val rshift_update_sub: res:qelem -> l:lbuffer uint64 8ul -> Stack unit (requires fun h -> live h res /\ live h l /\ disjoint res l /\ as_seq h res == LSeq.create 4 (u64 0)) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ (let res_b = SN.bn_rshift (as_seq h0 l) 6 in let res_b_padded = LSeq.create 4 (u64 0) in let res_b_padded = LSeq.update_sub res_b_padded 0 2 res_b in as_seq h1 res == res_b_padded))
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
res: Hacl.K256.Scalar.qelem -> l: Lib.Buffer.lbuffer Lib.IntTypes.uint64 8ul -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.K256.Scalar.qelem", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Lib.Buffer.update_sub_f", "Hacl.K256.Scalar.qnlimb", "FStar.Monotonic.HyperStack.mem", "Hacl.Spec.Bignum.bn_rshift", "Lib.IntTypes.U64", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Lib.Sequence.lseq", "Prims.unit", "Hacl.Bignum.bn_rshift", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.sub", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.sub", "Lib.Buffer.lbuffer_t", "FStar.HyperStack.ST.get" ]
[]
false
true
false
false
false
let rshift_update_sub res l =
let h1 = ST.get () in update_sub_f h1 res 0ul 2ul (fun h -> SN.bn_rshift (as_seq h1 l) 6) (fun _ -> BN.bn_rshift 8ul l 6ul (sub res 0ul 2ul))
false
Lib.UpdateMulti.Lemmas.fst
Lib.UpdateMulti.Lemmas.split_at_last_lazy_spec
val split_at_last_lazy_spec (l : pos) (b blocks rest: S.seq uint8) : Lemma (requires ( S.length blocks % l = 0 /\ S.length rest <= l /\ (S.length rest = 0 ==> S.length b = 0) /\ b `Seq.equal` Seq.append blocks rest)) (ensures ( (blocks, rest) == split_at_last_lazy l b))
val split_at_last_lazy_spec (l : pos) (b blocks rest: S.seq uint8) : Lemma (requires ( S.length blocks % l = 0 /\ S.length rest <= l /\ (S.length rest = 0 ==> S.length b = 0) /\ b `Seq.equal` Seq.append blocks rest)) (ensures ( (blocks, rest) == split_at_last_lazy l b))
let split_at_last_lazy_spec (l : pos) (b blocks rest: S.seq uint8): Lemma (requires ( S.length blocks % l = 0 /\ S.length rest <= l /\ (S.length rest = 0 ==> S.length b = 0) /\ b `Seq.equal` Seq.append blocks rest)) (ensures ( (blocks, rest) == split_at_last_lazy l b)) = (* We need to introduce the variables with which to call [split_at_last_lazy_nb_rem_spec] *) let b_l = Seq.length b in let blocks_l = Seq.length blocks in let rest_l = Seq.length rest in let blocks', rest' = split_at_last_lazy l b in let n' = Seq.length blocks' / l in let n = blocks_l / l in Math.Lemmas.nat_over_pos_is_nat blocks_l l; assert(n >= 0); Math.Lemmas.euclidean_division_definition (S.length blocks) l; split_at_last_lazy_nb_rem_spec l b_l n rest_l; assert(((n <: nat), rest_l) = split_at_last_lazy_nb_rem l b_l); assert(n = n'); (* comes from the spec of [split_at_last_lazy] *) assert(rest_l = Seq.length rest'); (* We have the equalities between the sequence lengths, so the rest follows * naturally *) assert(blocks `Seq.equal` blocks'); assert(rest `Seq.equal` rest')
{ "file_name": "lib/Lib.UpdateMulti.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 32, "end_line": 112, "start_col": 0, "start_line": 85 }
module Lib.UpdateMulti.Lemmas /// This first auxiliary lemma only manipulates the lengths of the sequences. #push-options "--z3cliopt smt.arith.nl=false" let split_at_last_lazy_nb_rem_spec (l : pos) (d n rest: nat) : Lemma (requires ( rest <= l /\ (rest = 0 ==> d = 0) /\ d = n * l + rest)) (ensures ((n, rest) = split_at_last_lazy_nb_rem l d)) = (* We call ``split_at_last_lazy_nb_rem`` at the beginning to have its * postcondition in the context (the return values are only used in the second * branch *) let n', rest' = split_at_last_lazy_nb_rem l d in if d = 0 then begin Math.Lemmas.nat_times_nat_is_nat n l; Math.Lemmas.int_times_int_equal_zero_lemma n l; assert(n = 0) end else begin assert(d > 0); (* In order to prove the equality between all the lengths, we use the unicity * of the modulo to prove that the rests are equal, then that the numbers * of blocks are equal. *) let blocks = n * l in let rest = d - blocks in let blocks' = n' * l in Math.Lemmas.cancel_mul_mod n l; assert(blocks % l = 0); assert(blocks' % l = 0); (* comes from the spec of [split_at_last_lazy_nb_rem] *) Math.Lemmas.euclidean_division_definition blocks l; (* First, prove that the lengths of the rests are equal modulo the size of * a block *) assert(rest' % l = d % l); (* comes from the spec of [split_at_last] *) assert(rest + n * l = d); Math.Lemmas.lemma_mod_plus rest n l; (* doesn't work inside a calc: typing problem with squash *) assert(d % l = rest % l); assert(rest % l = rest' % l); (* If both rests are stricly smaller than a block, we can directly apply * the modulo injectivity and the rest follows immediately *) if rest < l && rest' < l then begin Math.Lemmas.lemma_mod_injective l rest rest'; assert(rest = rest'); assert(n * l + rest = n' * l + rest'); assert(n * l = n' * l); Math.Lemmas.lemma_cancel_mul n n' l; assert(n = n') end (* Otherwise, case one: both rests are equal to block length (even easier) *) else if rest = l && rest' = l then Math.Lemmas.lemma_cancel_mul n n' l (* Last two cases: one of the rests is smaller than a block, and the other is * of the size of a block. Because of modulo properties, the smaller rest * must be equal to 0, which gives us that the data is actually of length 0: * contradiction. *) else begin assert((rest = l && rest' < l) \/ (rest < l && rest' = l)); let rest, rest' = if rest = l then rest, rest' else rest', rest in assert(rest = l && rest' < l); (* [rest % l = 0] *) assert(rest = 1 * l); Math.Lemmas.cancel_mul_mod 1 l; assert(rest % l = 0); (* [rest' = 0 ] *) Math.Lemmas.modulo_lemma rest' l; assert(rest' = 0); (* By the current hypotheses, if rest' = 0 then d = 0 (contradiction) *) assert(False) end end #pop-options /// This second lemma characterizes the sequences themselves. /// The proof strategy is to first prove that the blocks and rest sequences have /// the expected lengths, and the equality between the sequences is then trivial /// to get.
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.UpdateMulti.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.UpdateMulti", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.UpdateMulti", "short_module": null }, { "abbrev": false, "full_module": "Lib.UpdateMulti", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
l: Prims.pos -> b: FStar.Seq.Base.seq Lib.UpdateMulti.Lemmas.uint8 -> blocks: FStar.Seq.Base.seq Lib.UpdateMulti.Lemmas.uint8 -> rest: FStar.Seq.Base.seq Lib.UpdateMulti.Lemmas.uint8 -> FStar.Pervasives.Lemma (requires FStar.Seq.Base.length blocks % l = 0 /\ FStar.Seq.Base.length rest <= l /\ (FStar.Seq.Base.length rest = 0 ==> FStar.Seq.Base.length b = 0) /\ FStar.Seq.Base.equal b (FStar.Seq.Base.append blocks rest)) (ensures (blocks, rest) == Lib.UpdateMulti.split_at_last_lazy l b)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.pos", "FStar.Seq.Base.seq", "Lib.UpdateMulti.Lemmas.uint8", "Lib.UpdateMulti.uint8", "Prims._assert", "FStar.Seq.Base.equal", "Prims.unit", "Prims.b2t", "Prims.op_Equality", "Prims.nat", "FStar.Seq.Base.length", "Prims.int", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "Lib.UpdateMulti.split_at_last_lazy_nb_rem", "Lib.UpdateMulti.Lemmas.split_at_last_lazy_nb_rem_spec", "FStar.Math.Lemmas.euclidean_division_definition", "Prims.op_GreaterThanOrEqual", "FStar.Math.Lemmas.nat_over_pos_is_nat", "Prims.op_Division", "Lib.UpdateMulti.split_at_last_lazy", "Prims.l_and", "Prims.op_Modulus", "Prims.op_LessThanOrEqual", "Prims.l_imp", "FStar.Seq.Base.append", "Prims.squash", "Prims.eq2", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let split_at_last_lazy_spec (l: pos) (b blocks rest: S.seq uint8) : Lemma (requires (S.length blocks % l = 0 /\ S.length rest <= l /\ (S.length rest = 0 ==> S.length b = 0) /\ b `Seq.equal` (Seq.append blocks rest))) (ensures ((blocks, rest) == split_at_last_lazy l b)) =
let b_l = Seq.length b in let blocks_l = Seq.length blocks in let rest_l = Seq.length rest in let blocks', rest' = split_at_last_lazy l b in let n' = Seq.length blocks' / l in let n = blocks_l / l in Math.Lemmas.nat_over_pos_is_nat blocks_l l; assert (n >= 0); Math.Lemmas.euclidean_division_definition (S.length blocks) l; split_at_last_lazy_nb_rem_spec l b_l n rest_l; assert (((n <: nat), rest_l) = split_at_last_lazy_nb_rem l b_l); assert (n = n'); assert (rest_l = Seq.length rest'); assert (blocks `Seq.equal` blocks'); assert (rest `Seq.equal` rest')
false
Lib.UpdateMulti.Lemmas.fst
Lib.UpdateMulti.Lemmas.split_at_last_lazy_nb_rem_spec
val split_at_last_lazy_nb_rem_spec (l : pos) (d n rest: nat) : Lemma (requires ( rest <= l /\ (rest = 0 ==> d = 0) /\ d = n * l + rest)) (ensures ((n, rest) = split_at_last_lazy_nb_rem l d))
val split_at_last_lazy_nb_rem_spec (l : pos) (d n rest: nat) : Lemma (requires ( rest <= l /\ (rest = 0 ==> d = 0) /\ d = n * l + rest)) (ensures ((n, rest) = split_at_last_lazy_nb_rem l d))
let split_at_last_lazy_nb_rem_spec (l : pos) (d n rest: nat) : Lemma (requires ( rest <= l /\ (rest = 0 ==> d = 0) /\ d = n * l + rest)) (ensures ((n, rest) = split_at_last_lazy_nb_rem l d)) = (* We call ``split_at_last_lazy_nb_rem`` at the beginning to have its * postcondition in the context (the return values are only used in the second * branch *) let n', rest' = split_at_last_lazy_nb_rem l d in if d = 0 then begin Math.Lemmas.nat_times_nat_is_nat n l; Math.Lemmas.int_times_int_equal_zero_lemma n l; assert(n = 0) end else begin assert(d > 0); (* In order to prove the equality between all the lengths, we use the unicity * of the modulo to prove that the rests are equal, then that the numbers * of blocks are equal. *) let blocks = n * l in let rest = d - blocks in let blocks' = n' * l in Math.Lemmas.cancel_mul_mod n l; assert(blocks % l = 0); assert(blocks' % l = 0); (* comes from the spec of [split_at_last_lazy_nb_rem] *) Math.Lemmas.euclidean_division_definition blocks l; (* First, prove that the lengths of the rests are equal modulo the size of * a block *) assert(rest' % l = d % l); (* comes from the spec of [split_at_last] *) assert(rest + n * l = d); Math.Lemmas.lemma_mod_plus rest n l; (* doesn't work inside a calc: typing problem with squash *) assert(d % l = rest % l); assert(rest % l = rest' % l); (* If both rests are stricly smaller than a block, we can directly apply * the modulo injectivity and the rest follows immediately *) if rest < l && rest' < l then begin Math.Lemmas.lemma_mod_injective l rest rest'; assert(rest = rest'); assert(n * l + rest = n' * l + rest'); assert(n * l = n' * l); Math.Lemmas.lemma_cancel_mul n n' l; assert(n = n') end (* Otherwise, case one: both rests are equal to block length (even easier) *) else if rest = l && rest' = l then Math.Lemmas.lemma_cancel_mul n n' l (* Last two cases: one of the rests is smaller than a block, and the other is * of the size of a block. Because of modulo properties, the smaller rest * must be equal to 0, which gives us that the data is actually of length 0: * contradiction. *) else begin assert((rest = l && rest' < l) \/ (rest < l && rest' = l)); let rest, rest' = if rest = l then rest, rest' else rest', rest in assert(rest = l && rest' < l); (* [rest % l = 0] *) assert(rest = 1 * l); Math.Lemmas.cancel_mul_mod 1 l; assert(rest % l = 0); (* [rest' = 0 ] *) Math.Lemmas.modulo_lemma rest' l; assert(rest' = 0); (* By the current hypotheses, if rest' = 0 then d = 0 (contradiction) *) assert(False) end end
{ "file_name": "lib/Lib.UpdateMulti.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 8, "end_line": 77, "start_col": 0, "start_line": 5 }
module Lib.UpdateMulti.Lemmas /// This first auxiliary lemma only manipulates the lengths of the sequences.
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.UpdateMulti.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.UpdateMulti", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.UpdateMulti", "short_module": null }, { "abbrev": false, "full_module": "Lib.UpdateMulti", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
l: Prims.pos -> d: Prims.nat -> n: Prims.nat -> rest: Prims.nat -> FStar.Pervasives.Lemma (requires rest <= l /\ (rest = 0 ==> d = 0) /\ d = n * l + rest) (ensures (n, rest) = Lib.UpdateMulti.split_at_last_lazy_nb_rem l d)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.pos", "Prims.nat", "Prims.op_Equality", "Prims.int", "Prims._assert", "Prims.b2t", "Prims.unit", "FStar.Math.Lemmas.int_times_int_equal_zero_lemma", "FStar.Math.Lemmas.nat_times_nat_is_nat", "Prims.bool", "Prims.op_AmpAmp", "Prims.op_LessThan", "FStar.Math.Lemmas.lemma_cancel_mul", "FStar.Mul.op_Star", "Prims.op_Addition", "FStar.Math.Lemmas.lemma_mod_injective", "Prims.l_or", "Prims.op_GreaterThan", "Prims.op_GreaterThanOrEqual", "Prims.l_False", "FStar.Math.Lemmas.modulo_lemma", "Prims.op_Modulus", "FStar.Math.Lemmas.cancel_mul_mod", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "FStar.Math.Lemmas.lemma_mod_plus", "FStar.Math.Lemmas.euclidean_division_definition", "Prims.op_Subtraction", "Lib.UpdateMulti.split_at_last_lazy_nb_rem", "Prims.l_and", "Prims.op_LessThanOrEqual", "Prims.l_imp", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let split_at_last_lazy_nb_rem_spec (l: pos) (d n rest: nat) : Lemma (requires (rest <= l /\ (rest = 0 ==> d = 0) /\ d = n * l + rest)) (ensures ((n, rest) = split_at_last_lazy_nb_rem l d)) =
let n', rest' = split_at_last_lazy_nb_rem l d in if d = 0 then (Math.Lemmas.nat_times_nat_is_nat n l; Math.Lemmas.int_times_int_equal_zero_lemma n l; assert (n = 0)) else (assert (d > 0); let blocks = n * l in let rest = d - blocks in let blocks' = n' * l in Math.Lemmas.cancel_mul_mod n l; assert (blocks % l = 0); assert (blocks' % l = 0); Math.Lemmas.euclidean_division_definition blocks l; assert (rest' % l = d % l); assert (rest + n * l = d); Math.Lemmas.lemma_mod_plus rest n l; assert (d % l = rest % l); assert (rest % l = rest' % l); if rest < l && rest' < l then (Math.Lemmas.lemma_mod_injective l rest rest'; assert (rest = rest'); assert (n * l + rest = n' * l + rest'); assert (n * l = n' * l); Math.Lemmas.lemma_cancel_mul n n' l; assert (n = n')) else if rest = l && rest' = l then Math.Lemmas.lemma_cancel_mul n n' l else (assert ((rest = l && rest' < l) \/ (rest < l && rest' = l)); let rest, rest' = if rest = l then rest, rest' else rest', rest in assert (rest = l && rest' < l); assert (rest = 1 * l); Math.Lemmas.cancel_mul_mod 1 l; assert (rest % l = 0); Math.Lemmas.modulo_lemma rest' l; assert (rest' = 0); assert (False)))
false
Spec.Hash.Incremental.Definitions.fst
Spec.Hash.Incremental.Definitions.split_blocks
val split_blocks (a: hash_alg) (input: bytes) : Pure (bytes & bytes) (requires (S.length input) `less_than_max_input_length` a) (ensures fun (bs, l) -> S.length bs % block_length a = 0 /\ S.length l <= block_length a /\ S.append bs l == input )
val split_blocks (a: hash_alg) (input: bytes) : Pure (bytes & bytes) (requires (S.length input) `less_than_max_input_length` a) (ensures fun (bs, l) -> S.length bs % block_length a = 0 /\ S.length l <= block_length a /\ S.append bs l == input )
let split_blocks (a:hash_alg) (input:bytes) : Pure (bytes & bytes) (requires S.length input `less_than_max_input_length` a) (ensures fun (bs, l) -> S.length bs % block_length a = 0 /\ S.length l <= block_length a /\ S.append bs l == input) = UpdateMulti.split_at_last_lazy (block_length a) input
{ "file_name": "specs/lemmas/Spec.Hash.Incremental.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 55, "end_line": 63, "start_col": 0, "start_line": 56 }
module Spec.Hash.Incremental.Definitions module S = FStar.Seq module Blake2 = Spec.Blake2 open Spec.Agile.Hash open Spec.Hash.Definitions open Spec.Hash.MD open FStar.Mul open Lib.Sequence open Lib.ByteSequence open Lib.IntTypes module Loops = Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--fuel 0 --ifuel 0 --z3rlimit 50" let prev_length_t (a: hash_alg) = if is_keccak a then unit else n:nat { n % block_length a = 0 } (* An incremental specification better suited to a stateful API, allowing the client to perform the padding at the last minute upon hitting the last chunk of data. *) let update_last (a:hash_alg) (hash:words_state a) (prevlen:prev_length_t a) (input:bytes{ (if is_keccak a then True else (S.length input + prevlen) `less_than_max_input_length` a) /\ S.length input <= block_length a }): Tot (words_state a) = if is_blake a then Spec.Blake2.blake2_update_last (to_blake_alg a) prevlen (S.length input) input hash else if is_keccak a then // VERY UNPLEASANT! Because of the lazy split for Blake2 we need to unroll... let rateInBytes = rate a / 8 in let delimitedSuffix = if is_shake a then byte 0x1f else byte 0x06 in let s = hash in let l = S.length input in if l = block_length a then let s = Spec.SHA3.absorb_inner rateInBytes input s in Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s else Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length input) input s else let total_len = prevlen + S.length input in let padding = pad a total_len in (**) Math.Lemmas.lemma_mod_add_distr (S.length input + S.length padding) prevlen (block_length a); (**) assert(S.length S.(input @| padding) % block_length a = 0); update_multi a hash () S.(input @| padding)
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.fst.checked", "Spec.Hash.MD.fst.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Blake2.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Spec.Hash.Incremental.Definitions.fst" }
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.MD", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Blake2" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "Spec.Hash.Incremental", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Incremental", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Hash.Definitions.hash_alg -> input: Lib.ByteSequence.bytes -> Prims.Pure (Lib.ByteSequence.bytes * Lib.ByteSequence.bytes)
Prims.Pure
[]
[]
[ "Spec.Hash.Definitions.hash_alg", "Lib.ByteSequence.bytes", "Lib.UpdateMulti.split_at_last_lazy", "Spec.Hash.Definitions.block_length", "FStar.Pervasives.Native.tuple2", "Prims.b2t", "Spec.Hash.Definitions.less_than_max_input_length", "FStar.Seq.Base.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.l_and", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "Prims.op_LessThanOrEqual", "Prims.eq2", "FStar.Seq.Base.seq", "FStar.Seq.Base.append" ]
[]
false
false
false
false
false
let split_blocks (a: hash_alg) (input: bytes) : Pure (bytes & bytes) (requires (S.length input) `less_than_max_input_length` a) (ensures fun (bs, l) -> S.length bs % block_length a = 0 /\ S.length l <= block_length a /\ S.append bs l == input ) =
UpdateMulti.split_at_last_lazy (block_length a) input
false
Spec.Hash.Incremental.Definitions.fst
Spec.Hash.Incremental.Definitions.hash_incremental
val hash_incremental (a: hash_alg) (input: bytes{(S.length input) `less_than_max_input_length` a}) (out_length: output_length a) : Tot (hash: bytes{S.length hash = (hash_length' a out_length)})
val hash_incremental (a: hash_alg) (input: bytes{(S.length input) `less_than_max_input_length` a}) (out_length: output_length a) : Tot (hash: bytes{S.length hash = (hash_length' a out_length)})
let hash_incremental (a:hash_alg) (input:bytes{S.length input `less_than_max_input_length` a}) (out_length: output_length a): Tot (hash:bytes{S.length hash = (hash_length' a out_length)}) = let s = init a in let bs, l = split_blocks a input in let s = update_multi a s (init_extra_state a) bs in let s = update_last a s (if is_keccak a then () else S.length bs) l in finish a s out_length
{ "file_name": "specs/lemmas/Spec.Hash.Incremental.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 23, "end_line": 73, "start_col": 0, "start_line": 65 }
module Spec.Hash.Incremental.Definitions module S = FStar.Seq module Blake2 = Spec.Blake2 open Spec.Agile.Hash open Spec.Hash.Definitions open Spec.Hash.MD open FStar.Mul open Lib.Sequence open Lib.ByteSequence open Lib.IntTypes module Loops = Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--fuel 0 --ifuel 0 --z3rlimit 50" let prev_length_t (a: hash_alg) = if is_keccak a then unit else n:nat { n % block_length a = 0 } (* An incremental specification better suited to a stateful API, allowing the client to perform the padding at the last minute upon hitting the last chunk of data. *) let update_last (a:hash_alg) (hash:words_state a) (prevlen:prev_length_t a) (input:bytes{ (if is_keccak a then True else (S.length input + prevlen) `less_than_max_input_length` a) /\ S.length input <= block_length a }): Tot (words_state a) = if is_blake a then Spec.Blake2.blake2_update_last (to_blake_alg a) prevlen (S.length input) input hash else if is_keccak a then // VERY UNPLEASANT! Because of the lazy split for Blake2 we need to unroll... let rateInBytes = rate a / 8 in let delimitedSuffix = if is_shake a then byte 0x1f else byte 0x06 in let s = hash in let l = S.length input in if l = block_length a then let s = Spec.SHA3.absorb_inner rateInBytes input s in Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s else Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length input) input s else let total_len = prevlen + S.length input in let padding = pad a total_len in (**) Math.Lemmas.lemma_mod_add_distr (S.length input + S.length padding) prevlen (block_length a); (**) assert(S.length S.(input @| padding) % block_length a = 0); update_multi a hash () S.(input @| padding) let split_blocks (a:hash_alg) (input:bytes) : Pure (bytes & bytes) (requires S.length input `less_than_max_input_length` a) (ensures fun (bs, l) -> S.length bs % block_length a = 0 /\ S.length l <= block_length a /\ S.append bs l == input) = UpdateMulti.split_at_last_lazy (block_length a) input
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.fst.checked", "Spec.Hash.MD.fst.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Blake2.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Spec.Hash.Incremental.Definitions.fst" }
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.MD", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Blake2" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "Spec.Hash.Incremental", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Incremental", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Hash.Definitions.hash_alg -> input: Lib.ByteSequence.bytes {Spec.Hash.Definitions.less_than_max_input_length (FStar.Seq.Base.length input) a} -> out_length: Spec.Hash.Definitions.output_length a -> hash: Lib.ByteSequence.bytes {FStar.Seq.Base.length hash = Spec.Hash.Definitions.hash_length' a out_length}
Prims.Tot
[ "total" ]
[]
[ "Spec.Hash.Definitions.hash_alg", "Lib.ByteSequence.bytes", "Prims.b2t", "Spec.Hash.Definitions.less_than_max_input_length", "FStar.Seq.Base.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.Hash.Definitions.output_length", "Spec.Agile.Hash.finish", "Spec.Hash.Definitions.words_state", "Spec.Hash.Incremental.Definitions.update_last", "Spec.Hash.Definitions.is_keccak", "Prims.bool", "Spec.Hash.Incremental.Definitions.prev_length_t", "Spec.Agile.Hash.update_multi", "Spec.Agile.Hash.init_extra_state", "Prims.op_Equality", "Prims.nat", "Spec.Hash.Definitions.hash_length'", "FStar.Pervasives.Native.tuple2", "Lib.Sequence.seq", "Lib.IntTypes.int_t", "Spec.Hash.Incremental.Definitions.split_blocks", "Spec.Hash.Definitions.init_t", "Spec.Agile.Hash.init" ]
[]
false
false
false
false
false
let hash_incremental (a: hash_alg) (input: bytes{(S.length input) `less_than_max_input_length` a}) (out_length: output_length a) : Tot (hash: bytes{S.length hash = (hash_length' a out_length)}) =
let s = init a in let bs, l = split_blocks a input in let s = update_multi a s (init_extra_state a) bs in let s = update_last a s (if is_keccak a then () else S.length bs) l in finish a s out_length
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.qadd
val qadd (out f1 f2: qelem) : Stack unit (requires fun h -> live h out /\ live h f1 /\ live h f2 /\ eq_or_disjoint out f1 /\ eq_or_disjoint out f2 /\ eq_or_disjoint f1 f2 /\ qe_lt_q h f1 /\ qe_lt_q h f2) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == S.qadd (qas_nat h0 f1) (qas_nat h0 f2) /\ qe_lt_q h1 out)
val qadd (out f1 f2: qelem) : Stack unit (requires fun h -> live h out /\ live h f1 /\ live h f2 /\ eq_or_disjoint out f1 /\ eq_or_disjoint out f2 /\ eq_or_disjoint f1 f2 /\ qe_lt_q h f1 /\ qe_lt_q h f2) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == S.qadd (qas_nat h0 f1) (qas_nat h0 f2) /\ qe_lt_q h1 out)
let qadd out f1 f2 = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); let h0 = ST.get () in kn.BN.add_mod_n n f1 f2 out; SN.bn_add_mod_n_lemma (as_seq h0 n) (as_seq h0 f1) (as_seq h0 f2); pop_frame ()
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 14, "end_line": 231, "start_col": 0, "start_line": 223 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb let sub4: BN.bn_sub_eq_len_st U64 qnlimb = BN.bn_sub_eq_len qnlimb let add_mod4: BN.bn_add_mod_n_st U64 qnlimb = BN.bn_add_mod_n qnlimb let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb = BN.bn_sub_mod_n qnlimb let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a = BN.bn_mul qnlimb qnlimb a let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a = BN.bn_sqr qnlimb a inline_for_extraction noextract instance kn: BN.bn U64 = { BN.len = qnlimb; BN.add = add4; BN.sub = sub4; BN.add_mod_n = add_mod4; BN.sub_mod_n = sub_mod4; BN.mul = mul4; BN.sqr = sqr4 } let make_u64_4 out (f0, f1, f2, f3) = out.(0ul) <- f0; out.(1ul) <- f1; out.(2ul) <- f2; out.(3ul) <- f3; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h out); assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3)) let make_order_k256 () = [@inline_let] let r = (u64 0xbfd25e8cd0364141, u64 0xbaaedce6af48a03b, u64 0xfffffffffffffffe, u64 0xffffffffffffffff) in assert_norm (qas_nat4 r = S.q); r let create_qelem () = SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb); create qnlimb (u64 0) let create_one () = [@inline_let] let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in assert_norm (FStar.List.Tot.length l = 4); Seq.elim_of_list l; LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l); KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)); createL l [@CInline] let is_qelem_zero f = let h0 = ST.get () in SN.bn_is_zero_mask_lemma (as_seq h0 f); BN.bn_is_zero_mask qnlimb f [@CInline] let is_qelem_zero_vartime f = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3); is_qelem_zero_vartime4 (f0,f1,f2,f3) [@CInline] let is_qelem_eq_vartime f1 f2 = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f1); KL.qas_nat4_is_qas_nat (as_seq h f2); let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3); is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3) let load_qelem f b = let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b); Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f [@CInline] let load_qelem_check f b = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); load_qelem f b; let h0 = ST.get () in let is_zero = is_qelem_zero f in assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0)); let is_lt_q = BN.bn_lt_mask qnlimb f n in SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n); assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0)); let m = logand (lognot is_zero) is_lt_q in lognot_lemma is_zero; logand_lemma (lognot is_zero) is_lt_q; pop_frame (); m let load_qelem_conditional res b = push_frame (); let is_b_valid = load_qelem_check res b in let oneq = create_one () in let h0 = ST.get () in Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res; let h1 = ST.get () in assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res)); pop_frame (); is_b_valid [@CInline] let load_qelem_vartime f b = load_qelem f b; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let is_zero = is_qelem_zero_vartime f in let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in let is_lt_q_b = is_qelem_lt_q_vartime4 (a0,a1,a2,a3) in KL.is_qelem_lt_q_vartime4_lemma (a0,a1,a2,a3); not is_zero && is_lt_q_b val modq_short: out:qelem -> a:qelem -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == qas_nat h0 a % S.q) [@CInline] let modq_short out a = push_frame (); let tmp = create_qelem () in [@inline_let] let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in make_u64_4 tmp (t0,t1,t2,t3); let h0 = ST.get () in let c = kn.BN.add a tmp out in let mask = u64 0 -. c in map2T qnlimb out (BB.mask_select mask) out a; KL.mod_short_lseq_lemma (as_seq h0 a); pop_frame () [@CInline] let load_qelem_modq f b = push_frame (); let tmp = create_qelem () in load_qelem f b; copy tmp f; modq_short f tmp; pop_frame () [@CInline] let store_qelem b f = let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma #U64 32 (as_seq h0 f); Hacl.Bignum.Convert.mk_bn_to_bytes_be true 32ul f b
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
out: Hacl.K256.Scalar.qelem -> f1: Hacl.K256.Scalar.qelem -> f2: Hacl.K256.Scalar.qelem -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.K256.Scalar.qelem", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Spec.Bignum.bn_add_mod_n_lemma", "Lib.IntTypes.U64", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.K256.Scalar.qnlimb", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "Hacl.Bignum.__proj__Mkbn__item__add_mod_n", "Hacl.K256.Scalar.kn", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.K256.Scalar.make_u64_4", "Hacl.K256.Scalar.make_order_k256", "Hacl.K256.Scalar.create_qelem", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let qadd out f1 f2 =
push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); let h0 = ST.get () in kn.BN.add_mod_n n f1 f2 out; SN.bn_add_mod_n_lemma (as_seq h0 n) (as_seq h0 f1) (as_seq h0 f2); pop_frame ()
false
Spec.Hash.Incremental.Definitions.fst
Spec.Hash.Incremental.Definitions.update_last
val update_last (a: hash_alg) (hash: words_state a) (prevlen: prev_length_t a) (input: bytes { (if is_keccak a then True else (S.length input + prevlen) `less_than_max_input_length` a) /\ S.length input <= block_length a }) : Tot (words_state a)
val update_last (a: hash_alg) (hash: words_state a) (prevlen: prev_length_t a) (input: bytes { (if is_keccak a then True else (S.length input + prevlen) `less_than_max_input_length` a) /\ S.length input <= block_length a }) : Tot (words_state a)
let update_last (a:hash_alg) (hash:words_state a) (prevlen:prev_length_t a) (input:bytes{ (if is_keccak a then True else (S.length input + prevlen) `less_than_max_input_length` a) /\ S.length input <= block_length a }): Tot (words_state a) = if is_blake a then Spec.Blake2.blake2_update_last (to_blake_alg a) prevlen (S.length input) input hash else if is_keccak a then // VERY UNPLEASANT! Because of the lazy split for Blake2 we need to unroll... let rateInBytes = rate a / 8 in let delimitedSuffix = if is_shake a then byte 0x1f else byte 0x06 in let s = hash in let l = S.length input in if l = block_length a then let s = Spec.SHA3.absorb_inner rateInBytes input s in Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s else Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length input) input s else let total_len = prevlen + S.length input in let padding = pad a total_len in (**) Math.Lemmas.lemma_mod_add_distr (S.length input + S.length padding) prevlen (block_length a); (**) assert(S.length S.(input @| padding) % block_length a = 0); update_multi a hash () S.(input @| padding)
{ "file_name": "specs/lemmas/Spec.Hash.Incremental.Definitions.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 47, "end_line": 54, "start_col": 0, "start_line": 29 }
module Spec.Hash.Incremental.Definitions module S = FStar.Seq module Blake2 = Spec.Blake2 open Spec.Agile.Hash open Spec.Hash.Definitions open Spec.Hash.MD open FStar.Mul open Lib.Sequence open Lib.ByteSequence open Lib.IntTypes module Loops = Lib.LoopCombinators module UpdateMulti = Lib.UpdateMulti #set-options "--fuel 0 --ifuel 0 --z3rlimit 50" let prev_length_t (a: hash_alg) = if is_keccak a then unit else n:nat { n % block_length a = 0 } (* An incremental specification better suited to a stateful API, allowing the client to perform the padding at the last minute upon hitting the last chunk of
{ "checked_file": "/", "dependencies": [ "Spec.SHA3.fst.checked", "Spec.Hash.MD.fst.checked", "Spec.Hash.Definitions.fst.checked", "Spec.Blake2.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Spec.Hash.Incremental.Definitions.fst" }
[ { "abbrev": true, "full_module": "Lib.UpdateMulti", "short_module": "UpdateMulti" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.MD", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Blake2" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "Spec.Hash.Incremental", "short_module": null }, { "abbrev": false, "full_module": "Spec.Hash.Incremental", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Hash.Definitions.hash_alg -> hash: Spec.Hash.Definitions.words_state a -> prevlen: Spec.Hash.Incremental.Definitions.prev_length_t a -> input: Lib.ByteSequence.bytes { (match Spec.Hash.Definitions.is_keccak a with | true -> Prims.l_True | _ -> Spec.Hash.Definitions.less_than_max_input_length (FStar.Seq.Base.length input + prevlen) a) /\ FStar.Seq.Base.length input <= Spec.Hash.Definitions.block_length a } -> Spec.Hash.Definitions.words_state a
Prims.Tot
[ "total" ]
[]
[ "Spec.Hash.Definitions.hash_alg", "Spec.Hash.Definitions.words_state", "Spec.Hash.Incremental.Definitions.prev_length_t", "Lib.ByteSequence.bytes", "Prims.l_and", "Spec.Hash.Definitions.is_keccak", "Prims.l_True", "Prims.bool", "Prims.b2t", "Spec.Hash.Definitions.less_than_max_input_length", "Prims.op_Addition", "FStar.Seq.Base.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.logical", "Prims.op_LessThanOrEqual", "Spec.Hash.Definitions.block_length", "Spec.Hash.Definitions.is_blake", "Spec.Blake2.blake2_update_last", "Spec.Hash.Definitions.to_blake_alg", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "Prims.op_disEquality", "Spec.SHA3.absorb_last", "FStar.Seq.Base.empty", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Spec.SHA3.absorb_inner", "Prims.nat", "Lib.IntTypes.PUB", "Spec.Hash.Definitions.is_shake", "Lib.IntTypes.byte", "Lib.IntTypes.byte_t", "Prims.op_Division", "Spec.Hash.Definitions.rate", "Spec.Agile.Hash.update_multi", "FStar.Seq.Base.op_At_Bar", "Prims.unit", "Prims._assert", "Prims.op_Modulus", "FStar.Math.Lemmas.lemma_mod_add_distr", "Lib.IntTypes.uint8", "Spec.Hash.Definitions.bytes", "Spec.Hash.MD.pad" ]
[]
false
false
false
false
false
let update_last (a: hash_alg) (hash: words_state a) (prevlen: prev_length_t a) (input: bytes { (if is_keccak a then True else (S.length input + prevlen) `less_than_max_input_length` a) /\ S.length input <= block_length a }) : Tot (words_state a) =
if is_blake a then Spec.Blake2.blake2_update_last (to_blake_alg a) prevlen (S.length input) input hash else if is_keccak a then let rateInBytes = rate a / 8 in let delimitedSuffix = if is_shake a then byte 0x1f else byte 0x06 in let s = hash in let l = S.length input in if l = block_length a then let s = Spec.SHA3.absorb_inner rateInBytes input s in Spec.SHA3.absorb_last delimitedSuffix rateInBytes 0 S.empty s else Spec.SHA3.absorb_last delimitedSuffix rateInBytes (S.length input) input s else let total_len = prevlen + S.length input in let padding = pad a total_len in Math.Lemmas.lemma_mod_add_distr (S.length input + S.length padding) prevlen (block_length a); assert (S.length S.(input @| padding) % block_length a = 0); update_multi a hash () S.(input @| padding)
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.qmul_shift_384
val qmul_shift_384 (res a b: qelem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h res /\ eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res /\ qas_nat h a < S.q /\ qas_nat h b < S.q) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ qas_nat h1 res < S.q /\ qas_nat h1 res == SG.qmul_shift_384 (qas_nat h0 a) (qas_nat h0 b))
val qmul_shift_384 (res a b: qelem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h res /\ eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res /\ qas_nat h a < S.q /\ qas_nat h b < S.q) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ qas_nat h1 res < S.q /\ qas_nat h1 res == SG.qmul_shift_384 (qas_nat h0 a) (qas_nat h0 b))
let qmul_shift_384 res a b = push_frame (); let h0 = ST.get () in let l = create (2ul *! qnlimb) (u64 0) in kn.BN.mul a b l; // l = a * b let res_b_padded = create_qelem () in rshift_update_sub res_b_padded l; let _ = BN.bn_add1 qnlimb res_b_padded (u64 1) res in let flag = l.(5ul) >>. 63ul in let mask = u64 0 -. flag in map2T qnlimb res (BB.mask_select mask) res res_b_padded; let h2 = ST.get () in assert (as_seq h2 res == Hacl.Spec.K256.Scalar.qmul_shift_384 (as_seq h0 a) (as_seq h0 b)); KL.qmul_shift_384_lemma (as_seq h0 a) (as_seq h0 b); KL.qas_nat4_is_qas_nat (as_seq h0 a); KL.qas_nat4_is_qas_nat (as_seq h0 b); KL.qas_nat4_is_qas_nat (as_seq h2 res); pop_frame ()
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 14, "end_line": 417, "start_col": 0, "start_line": 400 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb let sub4: BN.bn_sub_eq_len_st U64 qnlimb = BN.bn_sub_eq_len qnlimb let add_mod4: BN.bn_add_mod_n_st U64 qnlimb = BN.bn_add_mod_n qnlimb let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb = BN.bn_sub_mod_n qnlimb let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a = BN.bn_mul qnlimb qnlimb a let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a = BN.bn_sqr qnlimb a inline_for_extraction noextract instance kn: BN.bn U64 = { BN.len = qnlimb; BN.add = add4; BN.sub = sub4; BN.add_mod_n = add_mod4; BN.sub_mod_n = sub_mod4; BN.mul = mul4; BN.sqr = sqr4 } let make_u64_4 out (f0, f1, f2, f3) = out.(0ul) <- f0; out.(1ul) <- f1; out.(2ul) <- f2; out.(3ul) <- f3; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h out); assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3)) let make_order_k256 () = [@inline_let] let r = (u64 0xbfd25e8cd0364141, u64 0xbaaedce6af48a03b, u64 0xfffffffffffffffe, u64 0xffffffffffffffff) in assert_norm (qas_nat4 r = S.q); r let create_qelem () = SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb); create qnlimb (u64 0) let create_one () = [@inline_let] let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in assert_norm (FStar.List.Tot.length l = 4); Seq.elim_of_list l; LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l); KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)); createL l [@CInline] let is_qelem_zero f = let h0 = ST.get () in SN.bn_is_zero_mask_lemma (as_seq h0 f); BN.bn_is_zero_mask qnlimb f [@CInline] let is_qelem_zero_vartime f = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3); is_qelem_zero_vartime4 (f0,f1,f2,f3) [@CInline] let is_qelem_eq_vartime f1 f2 = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f1); KL.qas_nat4_is_qas_nat (as_seq h f2); let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3); is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3) let load_qelem f b = let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b); Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f [@CInline] let load_qelem_check f b = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); load_qelem f b; let h0 = ST.get () in let is_zero = is_qelem_zero f in assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0)); let is_lt_q = BN.bn_lt_mask qnlimb f n in SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n); assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0)); let m = logand (lognot is_zero) is_lt_q in lognot_lemma is_zero; logand_lemma (lognot is_zero) is_lt_q; pop_frame (); m let load_qelem_conditional res b = push_frame (); let is_b_valid = load_qelem_check res b in let oneq = create_one () in let h0 = ST.get () in Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res; let h1 = ST.get () in assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res)); pop_frame (); is_b_valid [@CInline] let load_qelem_vartime f b = load_qelem f b; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let is_zero = is_qelem_zero_vartime f in let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in let is_lt_q_b = is_qelem_lt_q_vartime4 (a0,a1,a2,a3) in KL.is_qelem_lt_q_vartime4_lemma (a0,a1,a2,a3); not is_zero && is_lt_q_b val modq_short: out:qelem -> a:qelem -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == qas_nat h0 a % S.q) [@CInline] let modq_short out a = push_frame (); let tmp = create_qelem () in [@inline_let] let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in make_u64_4 tmp (t0,t1,t2,t3); let h0 = ST.get () in let c = kn.BN.add a tmp out in let mask = u64 0 -. c in map2T qnlimb out (BB.mask_select mask) out a; KL.mod_short_lseq_lemma (as_seq h0 a); pop_frame () [@CInline] let load_qelem_modq f b = push_frame (); let tmp = create_qelem () in load_qelem f b; copy tmp f; modq_short f tmp; pop_frame () [@CInline] let store_qelem b f = let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma #U64 32 (as_seq h0 f); Hacl.Bignum.Convert.mk_bn_to_bytes_be true 32ul f b [@CInline] let qadd out f1 f2 = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); let h0 = ST.get () in kn.BN.add_mod_n n f1 f2 out; SN.bn_add_mod_n_lemma (as_seq h0 n) (as_seq h0 f1) (as_seq h0 f2); pop_frame () val mul_pow2_256_minus_q_add: len:size_t -> resLen:size_t{2 + v len <= v resLen /\ 4 <= v resLen} -> t01:lbuffer uint64 2ul -> a:lbuffer uint64 len -> e:lbuffer uint64 4ul -> res:lbuffer uint64 resLen -> Stack (BB.carry U64) (requires fun h -> live h a /\ live h res /\ live h t01 /\ live h e /\ disjoint a res /\ disjoint a t01 /\ disjoint a e /\ disjoint res t01 /\ disjoint res e /\ disjoint t01 e /\ as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\ as_seq h res == LSeq.create (v resLen) (u64 0)) (ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\ (c, as_seq h1 res) == mul_pow2_256_minus_q_lseq_add (v len) (v resLen) (as_seq h0 a) (as_seq h0 e)) [@CInline] let mul_pow2_256_minus_q_add len resLen t01 a e res = push_frame (); let tmp = create (len +! 2ul) (u64 0) in BN.bn_mul len 2ul a t01 tmp; update_sub res 2ul len a; let _ = bn_add resLen res (len +! 2ul) tmp res in let c = bn_add resLen res 4ul e res in pop_frame (); c inline_for_extraction noextract val modq_before_final: t01:lbuffer uint64 2ul -> a:lbuffer uint64 (2ul *! qnlimb) -> out:qelem -> Stack (BB.carry U64) (requires fun h -> live h a /\ live h out /\ live h t01 /\ disjoint a out /\ disjoint a t01 /\ disjoint out t01 /\ as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\ as_seq h out == LSeq.create 4 (u64 0)) (ensures fun h0 c h1 -> modifies (loc out) h0 h1 /\ (c, as_seq h1 out) == mod_lseq_before_final (as_seq h0 a)) let modq_before_final t01 a out = push_frame (); let m = create 7ul (u64 0) in let p = create 5ul (u64 0) in let c0 = mul_pow2_256_minus_q_add 4ul 7ul t01 (sub a 4ul 4ul) (sub a 0ul 4ul) m in let c1 = mul_pow2_256_minus_q_add 3ul 5ul t01 (sub m 4ul 3ul) (sub m 0ul 4ul) p in let c2 = mul_pow2_256_minus_q_add 1ul 4ul t01 (sub p 4ul 1ul) (sub p 0ul 4ul) out in pop_frame (); c2 val modq: out:qelem -> a:lbuffer uint64 (2ul *! qnlimb) -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == BD.bn_v h0 a % S.q) [@CInline] let modq out a = push_frame (); let r = create_qelem () in let tmp = create_qelem () in [@inline_let] let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in make_u64_4 tmp (t0,t1,t2,t3); let t01 = sub tmp 0ul 2ul in let h0 = ST.get () in assert (Seq.equal (as_seq h0 t01) (LSeq.create2 t0 t1)); let c0 = modq_before_final t01 a r in let c1 = kn.BN.add r tmp out in let mask = u64 0 -. (c0 +. c1) in map2T qnlimb out (BB.mask_select mask) out r; let h1 = ST.get () in KL.mod_lseq_lemma (as_seq h0 a); pop_frame () [@CInline] let qmul out f1 f2 = push_frame (); let h0 = ST.get () in let tmp = create (2ul *! qnlimb) (u64 0) in kn.BN.mul f1 f2 tmp; SN.bn_mul_lemma (as_seq h0 f1) (as_seq h0 f2); modq out tmp; pop_frame () [@CInline] let qsqr out f = push_frame (); let h0 = ST.get () in let tmp = create (2ul *! qnlimb) (u64 0) in kn.BN.sqr f tmp; SN.bn_sqr_lemma (as_seq h0 f); modq out tmp; pop_frame () [@CInline] let qnegate_conditional_vartime f is_negate = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); let zero = create_qelem () in if is_negate then begin let h0 = ST.get () in kn.BN.sub_mod_n n zero f f; SN.bn_sub_mod_n_lemma (as_seq h0 n) (as_seq h0 zero) (as_seq h0 f); let h1 = ST.get () in assert (qas_nat h1 f = (0 - qas_nat h0 f) % S.q); Math.Lemmas.modulo_addition_lemma (- qas_nat h0 f) S.q 1; assert (qas_nat h1 f == (S.q - qas_nat h0 f) % S.q) end; pop_frame () [@CInline] let is_qelem_le_q_halved_vartime f = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in KL.is_qelem_le_q_halved_vartime4_lemma (a0,a1,a2,a3); is_qelem_le_q_halved_vartime4 (a0,a1,a2,a3) let is_qelem_lt_pow2_128_vartime f = let open Lib.RawIntTypes in let h0 = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h0 f); let f0 = Ghost.hide (LSeq.index (as_seq h0 f) 0) in let f1 = Ghost.hide (LSeq.index (as_seq h0 f) 1) in let f2 = f.(2ul) in let f3 = f.(3ul) in KL.is_qelem_lt_pow2_128_vartime4_lemma (Ghost.reveal f0, Ghost.reveal f1,f2,f3); u64_to_UInt64 f2 =. 0uL && u64_to_UInt64 f3 =. 0uL inline_for_extraction noextract val rshift_update_sub: res:qelem -> l:lbuffer uint64 8ul -> Stack unit (requires fun h -> live h res /\ live h l /\ disjoint res l /\ as_seq h res == LSeq.create 4 (u64 0)) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ (let res_b = SN.bn_rshift (as_seq h0 l) 6 in let res_b_padded = LSeq.create 4 (u64 0) in let res_b_padded = LSeq.update_sub res_b_padded 0 2 res_b in as_seq h1 res == res_b_padded)) let rshift_update_sub res l = let h1 = ST.get () in update_sub_f h1 res 0ul 2ul (fun h -> SN.bn_rshift (as_seq h1 l) 6) (fun _ -> BN.bn_rshift 8ul l 6ul (sub res 0ul 2ul))
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
res: Hacl.K256.Scalar.qelem -> a: Hacl.K256.Scalar.qelem -> b: Hacl.K256.Scalar.qelem -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.K256.Scalar.qelem", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Spec.K256.Scalar.Lemmas.qas_nat4_is_qas_nat", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "Hacl.K256.Scalar.qnlimb", "Hacl.Spec.K256.Scalar.Lemmas.qmul_shift_384_lemma", "Prims._assert", "Prims.eq2", "Lib.Sequence.lseq", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Spec.K256.Scalar.qmul_shift_384", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.Buffer.map2T", "Hacl.Spec.Bignum.Base.mask_select", "Lib.IntTypes.U64", "Lib.IntTypes.int_t", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Subtraction_Dot", "Lib.IntTypes.u64", "Lib.IntTypes.op_Greater_Greater_Dot", "FStar.UInt32.__uint_to_t", "Lib.Buffer.op_Array_Access", "Hacl.Bignum.Definitions.limb", "Lib.IntTypes.op_Star_Bang", "Hacl.Spec.Bignum.Base.carry", "Hacl.Bignum.bn_add1", "Hacl.K256.Scalar.rshift_update_sub", "Hacl.K256.Scalar.create_qelem", "Hacl.Bignum.__proj__Mkbn__item__mul", "Hacl.K256.Scalar.kn", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.mul", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.create", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let qmul_shift_384 res a b =
push_frame (); let h0 = ST.get () in let l = create (2ul *! qnlimb) (u64 0) in kn.BN.mul a b l; let res_b_padded = create_qelem () in rshift_update_sub res_b_padded l; let _ = BN.bn_add1 qnlimb res_b_padded (u64 1) res in let flag = l.(5ul) >>. 63ul in let mask = u64 0 -. flag in map2T qnlimb res (BB.mask_select mask) res res_b_padded; let h2 = ST.get () in assert (as_seq h2 res == Hacl.Spec.K256.Scalar.qmul_shift_384 (as_seq h0 a) (as_seq h0 b)); KL.qmul_shift_384_lemma (as_seq h0 a) (as_seq h0 b); KL.qas_nat4_is_qas_nat (as_seq h0 a); KL.qas_nat4_is_qas_nat (as_seq h0 b); KL.qas_nat4_is_qas_nat (as_seq h2 res); pop_frame ()
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.mul_pow2_256_minus_q_add
val mul_pow2_256_minus_q_add: len:size_t -> resLen:size_t{2 + v len <= v resLen /\ 4 <= v resLen} -> t01:lbuffer uint64 2ul -> a:lbuffer uint64 len -> e:lbuffer uint64 4ul -> res:lbuffer uint64 resLen -> Stack (BB.carry U64) (requires fun h -> live h a /\ live h res /\ live h t01 /\ live h e /\ disjoint a res /\ disjoint a t01 /\ disjoint a e /\ disjoint res t01 /\ disjoint res e /\ disjoint t01 e /\ as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\ as_seq h res == LSeq.create (v resLen) (u64 0)) (ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\ (c, as_seq h1 res) == mul_pow2_256_minus_q_lseq_add (v len) (v resLen) (as_seq h0 a) (as_seq h0 e))
val mul_pow2_256_minus_q_add: len:size_t -> resLen:size_t{2 + v len <= v resLen /\ 4 <= v resLen} -> t01:lbuffer uint64 2ul -> a:lbuffer uint64 len -> e:lbuffer uint64 4ul -> res:lbuffer uint64 resLen -> Stack (BB.carry U64) (requires fun h -> live h a /\ live h res /\ live h t01 /\ live h e /\ disjoint a res /\ disjoint a t01 /\ disjoint a e /\ disjoint res t01 /\ disjoint res e /\ disjoint t01 e /\ as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\ as_seq h res == LSeq.create (v resLen) (u64 0)) (ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\ (c, as_seq h1 res) == mul_pow2_256_minus_q_lseq_add (v len) (v resLen) (as_seq h0 a) (as_seq h0 e))
let mul_pow2_256_minus_q_add len resLen t01 a e res = push_frame (); let tmp = create (len +! 2ul) (u64 0) in BN.bn_mul len 2ul a t01 tmp; update_sub res 2ul len a; let _ = bn_add resLen res (len +! 2ul) tmp res in let c = bn_add resLen res 4ul e res in pop_frame (); c
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 261, "start_col": 0, "start_line": 253 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb let sub4: BN.bn_sub_eq_len_st U64 qnlimb = BN.bn_sub_eq_len qnlimb let add_mod4: BN.bn_add_mod_n_st U64 qnlimb = BN.bn_add_mod_n qnlimb let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb = BN.bn_sub_mod_n qnlimb let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a = BN.bn_mul qnlimb qnlimb a let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a = BN.bn_sqr qnlimb a inline_for_extraction noextract instance kn: BN.bn U64 = { BN.len = qnlimb; BN.add = add4; BN.sub = sub4; BN.add_mod_n = add_mod4; BN.sub_mod_n = sub_mod4; BN.mul = mul4; BN.sqr = sqr4 } let make_u64_4 out (f0, f1, f2, f3) = out.(0ul) <- f0; out.(1ul) <- f1; out.(2ul) <- f2; out.(3ul) <- f3; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h out); assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3)) let make_order_k256 () = [@inline_let] let r = (u64 0xbfd25e8cd0364141, u64 0xbaaedce6af48a03b, u64 0xfffffffffffffffe, u64 0xffffffffffffffff) in assert_norm (qas_nat4 r = S.q); r let create_qelem () = SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb); create qnlimb (u64 0) let create_one () = [@inline_let] let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in assert_norm (FStar.List.Tot.length l = 4); Seq.elim_of_list l; LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l); KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)); createL l [@CInline] let is_qelem_zero f = let h0 = ST.get () in SN.bn_is_zero_mask_lemma (as_seq h0 f); BN.bn_is_zero_mask qnlimb f [@CInline] let is_qelem_zero_vartime f = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3); is_qelem_zero_vartime4 (f0,f1,f2,f3) [@CInline] let is_qelem_eq_vartime f1 f2 = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f1); KL.qas_nat4_is_qas_nat (as_seq h f2); let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3); is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3) let load_qelem f b = let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b); Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f [@CInline] let load_qelem_check f b = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); load_qelem f b; let h0 = ST.get () in let is_zero = is_qelem_zero f in assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0)); let is_lt_q = BN.bn_lt_mask qnlimb f n in SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n); assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0)); let m = logand (lognot is_zero) is_lt_q in lognot_lemma is_zero; logand_lemma (lognot is_zero) is_lt_q; pop_frame (); m let load_qelem_conditional res b = push_frame (); let is_b_valid = load_qelem_check res b in let oneq = create_one () in let h0 = ST.get () in Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res; let h1 = ST.get () in assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res)); pop_frame (); is_b_valid [@CInline] let load_qelem_vartime f b = load_qelem f b; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let is_zero = is_qelem_zero_vartime f in let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in let is_lt_q_b = is_qelem_lt_q_vartime4 (a0,a1,a2,a3) in KL.is_qelem_lt_q_vartime4_lemma (a0,a1,a2,a3); not is_zero && is_lt_q_b val modq_short: out:qelem -> a:qelem -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == qas_nat h0 a % S.q) [@CInline] let modq_short out a = push_frame (); let tmp = create_qelem () in [@inline_let] let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in make_u64_4 tmp (t0,t1,t2,t3); let h0 = ST.get () in let c = kn.BN.add a tmp out in let mask = u64 0 -. c in map2T qnlimb out (BB.mask_select mask) out a; KL.mod_short_lseq_lemma (as_seq h0 a); pop_frame () [@CInline] let load_qelem_modq f b = push_frame (); let tmp = create_qelem () in load_qelem f b; copy tmp f; modq_short f tmp; pop_frame () [@CInline] let store_qelem b f = let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma #U64 32 (as_seq h0 f); Hacl.Bignum.Convert.mk_bn_to_bytes_be true 32ul f b [@CInline] let qadd out f1 f2 = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); let h0 = ST.get () in kn.BN.add_mod_n n f1 f2 out; SN.bn_add_mod_n_lemma (as_seq h0 n) (as_seq h0 f1) (as_seq h0 f2); pop_frame () val mul_pow2_256_minus_q_add: len:size_t -> resLen:size_t{2 + v len <= v resLen /\ 4 <= v resLen} -> t01:lbuffer uint64 2ul -> a:lbuffer uint64 len -> e:lbuffer uint64 4ul -> res:lbuffer uint64 resLen -> Stack (BB.carry U64) (requires fun h -> live h a /\ live h res /\ live h t01 /\ live h e /\ disjoint a res /\ disjoint a t01 /\ disjoint a e /\ disjoint res t01 /\ disjoint res e /\ disjoint t01 e /\ as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\ as_seq h res == LSeq.create (v resLen) (u64 0)) (ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\ (c, as_seq h1 res) == mul_pow2_256_minus_q_lseq_add (v len) (v resLen) (as_seq h0 a) (as_seq h0 e))
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
len: Lib.IntTypes.size_t -> resLen: Lib.IntTypes.size_t {2 + Lib.IntTypes.v len <= Lib.IntTypes.v resLen /\ 4 <= Lib.IntTypes.v resLen} -> t01: Lib.Buffer.lbuffer Lib.IntTypes.uint64 2ul -> a: Lib.Buffer.lbuffer Lib.IntTypes.uint64 len -> e: Lib.Buffer.lbuffer Lib.IntTypes.uint64 4ul -> res: Lib.Buffer.lbuffer Lib.IntTypes.uint64 resLen -> FStar.HyperStack.ST.Stack (Hacl.Spec.Bignum.Base.carry Lib.IntTypes.U64)
FStar.HyperStack.ST.Stack
[]
[]
[ "Lib.IntTypes.size_t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Hacl.Spec.Bignum.Base.carry", "Lib.IntTypes.U64", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Hacl.K256.Scalar.bn_add", "Lib.IntTypes.op_Plus_Bang", "Lib.Buffer.update_sub", "Lib.Buffer.MUT", "Hacl.Bignum.bn_mul", "Lib.Buffer.lbuffer_t", "Hacl.Bignum.Definitions.limb", "Lib.IntTypes.add", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.create", "Lib.IntTypes.u64", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let mul_pow2_256_minus_q_add len resLen t01 a e res =
push_frame (); let tmp = create (len +! 2ul) (u64 0) in BN.bn_mul len 2ul a t01 tmp; update_sub res 2ul len a; let _ = bn_add resLen res (len +! 2ul) tmp res in let c = bn_add resLen res 4ul e res in pop_frame (); c
false
CQueue.Cell.fsti
CQueue.Cell.ccell
val ccell (#a: Type0) (c: ccell_ptrvalue a) : Tot vprop
val ccell (#a: Type0) (c: ccell_ptrvalue a) : Tot vprop
let ccell (#a: Type0) (c: ccell_ptrvalue a) : Tot vprop = VUnit (ccell' c)
{ "file_name": "share/steel/examples/steel/CQueue.Cell.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 18, "end_line": 115, "start_col": 0, "start_line": 114 }
module CQueue.Cell open Steel.Memory open Steel.Effect open Steel.Effect.Atomic open Steel.FractionalPermission open Steel.Reference (* A C lvalue view of a cell struct, as a pair of two references for its data and next fields *) val ccell_ptrvalue (a: Type0) : Tot Type0 (* "ccell *" seen as a rvalue *) val ccell_ptrvalue_null (a: Type0) : Tot (ccell_ptrvalue a) (* Pointer arithmetic: comparison to null, and pointer to fields. TODO: split these operations between Ghost and Steel, with a proper model of a "permission to do pointer arithmetic without actually reading the value/dereferencing" *) val ccell_ptrvalue_is_null (#a: Type0) (c: ccell_ptrvalue a) : Pure bool (requires True) (ensures (fun b -> b == true <==> c == ccell_ptrvalue_null a)) let ccell_lvalue (a: Type0) = (c: ccell_ptrvalue a { ccell_ptrvalue_is_null c == false }) (* "ccell" seen as a lvalue, or "ccell * const". IMPORTANT: one MUST NOT use "ref ccell_lvalue" in C code. In other words, ref can be used to model pointers to rvalues only. *) val ccell_data (#a: Type0) (c: ccell_lvalue a) : Pure (ref a) (requires True) (ensures (fun v -> ~ (is_null v))) val ccell_next (#a: Type0) (c: ccell_lvalue a) : Pure (ref (ccell_ptrvalue a)) (requires True) (ensures (fun v -> ~ (is_null v))) (* Important: we DO NOT provide a pure constructor for this data type, since its fields MUST be allocated at the same time and a cell MUST NOT be forged from references that would not come from such same-time allocation. *) (* The high-level value of a cell (should NEVER be used in C code, only in specs) *) noeq type vcell (a: Type0) = { vcell_data : a; vcell_next : ccell_ptrvalue a; } val ccell_is_lvalue_hp (#a: Type) (c: ccell_ptrvalue a) : Tot (slprop u#1) val ccell_is_lvalue_sel (#a: Type) (c: ccell_ptrvalue a) : GTot (selector (ccell_lvalue a) (ccell_is_lvalue_hp c)) [@@ __steel_reduce__] let ccell_is_lvalue' (#a: Type0) (c: ccell_ptrvalue a) : GTot vprop' = { hp = ccell_is_lvalue_hp c; t = ccell_lvalue a; sel = ccell_is_lvalue_sel c; } [@@ __steel_reduce__ ] let ccell_is_lvalue (#a: Type0) (c: ccell_ptrvalue a) : Tot vprop = VUnit (ccell_is_lvalue' c) val intro_ccell_is_lvalue (#opened: _) (#a: Type) (c: ccell_ptrvalue a) : SteelGhost unit opened emp (fun _ -> ccell_is_lvalue c) (fun _ -> ccell_ptrvalue_is_null c == false) (fun _ res h' -> ccell_ptrvalue_is_null c == false /\ (h' (ccell_is_lvalue c) <: ccell_ptrvalue a) == c ) val elim_ccell_is_lvalue (#opened: _) (#a: Type) (c: ccell_ptrvalue a) : SteelGhost unit opened (ccell_is_lvalue c) (fun _ -> emp) (fun _ -> True) (fun h _ _ -> (h (ccell_is_lvalue c) <: ccell_ptrvalue a) == c /\ ccell_ptrvalue_is_null c == false ) val ccell_hp (#a: Type0) (c: ccell_ptrvalue a) : Tot (slprop u#1) val ccell_sel (#a: Type0) (c: ccell_ptrvalue a) : GTot (selector (vcell a) (ccell_hp c)) [@__steel_reduce__] let ccell' (#a: Type0) (c: ccell_ptrvalue a) : GTot vprop' = { hp = ccell_hp c; t = vcell a; sel = ccell_sel c; }
{ "checked_file": "/", "dependencies": [ "Steel.Reference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "CQueue.Cell.fsti" }
[ { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "CQueue", "short_module": null }, { "abbrev": false, "full_module": "CQueue", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c: CQueue.Cell.ccell_ptrvalue a -> Steel.Effect.Common.vprop
Prims.Tot
[ "total" ]
[]
[ "CQueue.Cell.ccell_ptrvalue", "Steel.Effect.Common.VUnit", "CQueue.Cell.ccell'", "Steel.Effect.Common.vprop" ]
[]
false
false
false
true
false
let ccell (#a: Type0) (c: ccell_ptrvalue a) : Tot vprop =
VUnit (ccell' c)
false
CQueue.Cell.fsti
CQueue.Cell.ccell_is_lvalue
val ccell_is_lvalue (#a: Type0) (c: ccell_ptrvalue a) : Tot vprop
val ccell_is_lvalue (#a: Type0) (c: ccell_ptrvalue a) : Tot vprop
let ccell_is_lvalue (#a: Type0) (c: ccell_ptrvalue a) : Tot vprop = VUnit (ccell_is_lvalue' c)
{ "file_name": "share/steel/examples/steel/CQueue.Cell.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 28, "end_line": 64, "start_col": 0, "start_line": 63 }
module CQueue.Cell open Steel.Memory open Steel.Effect open Steel.Effect.Atomic open Steel.FractionalPermission open Steel.Reference (* A C lvalue view of a cell struct, as a pair of two references for its data and next fields *) val ccell_ptrvalue (a: Type0) : Tot Type0 (* "ccell *" seen as a rvalue *) val ccell_ptrvalue_null (a: Type0) : Tot (ccell_ptrvalue a) (* Pointer arithmetic: comparison to null, and pointer to fields. TODO: split these operations between Ghost and Steel, with a proper model of a "permission to do pointer arithmetic without actually reading the value/dereferencing" *) val ccell_ptrvalue_is_null (#a: Type0) (c: ccell_ptrvalue a) : Pure bool (requires True) (ensures (fun b -> b == true <==> c == ccell_ptrvalue_null a)) let ccell_lvalue (a: Type0) = (c: ccell_ptrvalue a { ccell_ptrvalue_is_null c == false }) (* "ccell" seen as a lvalue, or "ccell * const". IMPORTANT: one MUST NOT use "ref ccell_lvalue" in C code. In other words, ref can be used to model pointers to rvalues only. *) val ccell_data (#a: Type0) (c: ccell_lvalue a) : Pure (ref a) (requires True) (ensures (fun v -> ~ (is_null v))) val ccell_next (#a: Type0) (c: ccell_lvalue a) : Pure (ref (ccell_ptrvalue a)) (requires True) (ensures (fun v -> ~ (is_null v))) (* Important: we DO NOT provide a pure constructor for this data type, since its fields MUST be allocated at the same time and a cell MUST NOT be forged from references that would not come from such same-time allocation. *) (* The high-level value of a cell (should NEVER be used in C code, only in specs) *) noeq type vcell (a: Type0) = { vcell_data : a; vcell_next : ccell_ptrvalue a; } val ccell_is_lvalue_hp (#a: Type) (c: ccell_ptrvalue a) : Tot (slprop u#1) val ccell_is_lvalue_sel (#a: Type) (c: ccell_ptrvalue a) : GTot (selector (ccell_lvalue a) (ccell_is_lvalue_hp c)) [@@ __steel_reduce__] let ccell_is_lvalue' (#a: Type0) (c: ccell_ptrvalue a) : GTot vprop' = { hp = ccell_is_lvalue_hp c; t = ccell_lvalue a; sel = ccell_is_lvalue_sel c; }
{ "checked_file": "/", "dependencies": [ "Steel.Reference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "CQueue.Cell.fsti" }
[ { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "CQueue", "short_module": null }, { "abbrev": false, "full_module": "CQueue", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c: CQueue.Cell.ccell_ptrvalue a -> Steel.Effect.Common.vprop
Prims.Tot
[ "total" ]
[]
[ "CQueue.Cell.ccell_ptrvalue", "Steel.Effect.Common.VUnit", "CQueue.Cell.ccell_is_lvalue'", "Steel.Effect.Common.vprop" ]
[]
false
false
false
true
false
let ccell_is_lvalue (#a: Type0) (c: ccell_ptrvalue a) : Tot vprop =
VUnit (ccell_is_lvalue' c)
false
CQueue.Cell.fsti
CQueue.Cell.ccell_lvalue
val ccell_lvalue : a: Type0 -> Type0
let ccell_lvalue (a: Type0) = (c: ccell_ptrvalue a { ccell_ptrvalue_is_null c == false })
{ "file_name": "share/steel/examples/steel/CQueue.Cell.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 89, "end_line": 20, "start_col": 0, "start_line": 20 }
module CQueue.Cell open Steel.Memory open Steel.Effect open Steel.Effect.Atomic open Steel.FractionalPermission open Steel.Reference (* A C lvalue view of a cell struct, as a pair of two references for its data and next fields *) val ccell_ptrvalue (a: Type0) : Tot Type0 (* "ccell *" seen as a rvalue *) val ccell_ptrvalue_null (a: Type0) : Tot (ccell_ptrvalue a) (* Pointer arithmetic: comparison to null, and pointer to fields. TODO: split these operations between Ghost and Steel, with a proper model of a "permission to do pointer arithmetic without actually reading the value/dereferencing" *) val ccell_ptrvalue_is_null (#a: Type0) (c: ccell_ptrvalue a) : Pure bool (requires True) (ensures (fun b -> b == true <==> c == ccell_ptrvalue_null a))
{ "checked_file": "/", "dependencies": [ "Steel.Reference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "CQueue.Cell.fsti" }
[ { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "CQueue", "short_module": null }, { "abbrev": false, "full_module": "CQueue", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type0 -> Type0
Prims.Tot
[ "total" ]
[]
[ "CQueue.Cell.ccell_ptrvalue", "Prims.eq2", "Prims.bool", "CQueue.Cell.ccell_ptrvalue_is_null" ]
[]
false
false
false
true
true
let ccell_lvalue (a: Type0) =
(c: ccell_ptrvalue a {ccell_ptrvalue_is_null c == false})
false
CQueue.Cell.fsti
CQueue.Cell.ccell'
val ccell' (#a: Type0) (c: ccell_ptrvalue a) : GTot vprop'
val ccell' (#a: Type0) (c: ccell_ptrvalue a) : GTot vprop'
let ccell' (#a: Type0) (c: ccell_ptrvalue a) : GTot vprop' = { hp = ccell_hp c; t = vcell a; sel = ccell_sel c; }
{ "file_name": "share/steel/examples/steel/CQueue.Cell.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 1, "end_line": 111, "start_col": 0, "start_line": 103 }
module CQueue.Cell open Steel.Memory open Steel.Effect open Steel.Effect.Atomic open Steel.FractionalPermission open Steel.Reference (* A C lvalue view of a cell struct, as a pair of two references for its data and next fields *) val ccell_ptrvalue (a: Type0) : Tot Type0 (* "ccell *" seen as a rvalue *) val ccell_ptrvalue_null (a: Type0) : Tot (ccell_ptrvalue a) (* Pointer arithmetic: comparison to null, and pointer to fields. TODO: split these operations between Ghost and Steel, with a proper model of a "permission to do pointer arithmetic without actually reading the value/dereferencing" *) val ccell_ptrvalue_is_null (#a: Type0) (c: ccell_ptrvalue a) : Pure bool (requires True) (ensures (fun b -> b == true <==> c == ccell_ptrvalue_null a)) let ccell_lvalue (a: Type0) = (c: ccell_ptrvalue a { ccell_ptrvalue_is_null c == false }) (* "ccell" seen as a lvalue, or "ccell * const". IMPORTANT: one MUST NOT use "ref ccell_lvalue" in C code. In other words, ref can be used to model pointers to rvalues only. *) val ccell_data (#a: Type0) (c: ccell_lvalue a) : Pure (ref a) (requires True) (ensures (fun v -> ~ (is_null v))) val ccell_next (#a: Type0) (c: ccell_lvalue a) : Pure (ref (ccell_ptrvalue a)) (requires True) (ensures (fun v -> ~ (is_null v))) (* Important: we DO NOT provide a pure constructor for this data type, since its fields MUST be allocated at the same time and a cell MUST NOT be forged from references that would not come from such same-time allocation. *) (* The high-level value of a cell (should NEVER be used in C code, only in specs) *) noeq type vcell (a: Type0) = { vcell_data : a; vcell_next : ccell_ptrvalue a; } val ccell_is_lvalue_hp (#a: Type) (c: ccell_ptrvalue a) : Tot (slprop u#1) val ccell_is_lvalue_sel (#a: Type) (c: ccell_ptrvalue a) : GTot (selector (ccell_lvalue a) (ccell_is_lvalue_hp c)) [@@ __steel_reduce__] let ccell_is_lvalue' (#a: Type0) (c: ccell_ptrvalue a) : GTot vprop' = { hp = ccell_is_lvalue_hp c; t = ccell_lvalue a; sel = ccell_is_lvalue_sel c; } [@@ __steel_reduce__ ] let ccell_is_lvalue (#a: Type0) (c: ccell_ptrvalue a) : Tot vprop = VUnit (ccell_is_lvalue' c) val intro_ccell_is_lvalue (#opened: _) (#a: Type) (c: ccell_ptrvalue a) : SteelGhost unit opened emp (fun _ -> ccell_is_lvalue c) (fun _ -> ccell_ptrvalue_is_null c == false) (fun _ res h' -> ccell_ptrvalue_is_null c == false /\ (h' (ccell_is_lvalue c) <: ccell_ptrvalue a) == c ) val elim_ccell_is_lvalue (#opened: _) (#a: Type) (c: ccell_ptrvalue a) : SteelGhost unit opened (ccell_is_lvalue c) (fun _ -> emp) (fun _ -> True) (fun h _ _ -> (h (ccell_is_lvalue c) <: ccell_ptrvalue a) == c /\ ccell_ptrvalue_is_null c == false ) val ccell_hp (#a: Type0) (c: ccell_ptrvalue a) : Tot (slprop u#1) val ccell_sel (#a: Type0) (c: ccell_ptrvalue a) : GTot (selector (vcell a) (ccell_hp c))
{ "checked_file": "/", "dependencies": [ "Steel.Reference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "CQueue.Cell.fsti" }
[ { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "CQueue", "short_module": null }, { "abbrev": false, "full_module": "CQueue", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c: CQueue.Cell.ccell_ptrvalue a -> Prims.GTot Steel.Effect.Common.vprop'
Prims.GTot
[ "sometrivial" ]
[]
[ "CQueue.Cell.ccell_ptrvalue", "Steel.Effect.Common.Mkvprop'", "CQueue.Cell.ccell_hp", "CQueue.Cell.vcell", "CQueue.Cell.ccell_sel", "Steel.Effect.Common.vprop'" ]
[]
false
false
false
false
false
let ccell' (#a: Type0) (c: ccell_ptrvalue a) : GTot vprop' =
{ hp = ccell_hp c; t = vcell a; sel = ccell_sel c }
false
CQueue.Cell.fsti
CQueue.Cell.ccell_is_lvalue'
val ccell_is_lvalue' (#a: Type0) (c: ccell_ptrvalue a) : GTot vprop'
val ccell_is_lvalue' (#a: Type0) (c: ccell_ptrvalue a) : GTot vprop'
let ccell_is_lvalue' (#a: Type0) (c: ccell_ptrvalue a) : GTot vprop' = { hp = ccell_is_lvalue_hp c; t = ccell_lvalue a; sel = ccell_is_lvalue_sel c; }
{ "file_name": "share/steel/examples/steel/CQueue.Cell.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 1, "end_line": 60, "start_col": 0, "start_line": 52 }
module CQueue.Cell open Steel.Memory open Steel.Effect open Steel.Effect.Atomic open Steel.FractionalPermission open Steel.Reference (* A C lvalue view of a cell struct, as a pair of two references for its data and next fields *) val ccell_ptrvalue (a: Type0) : Tot Type0 (* "ccell *" seen as a rvalue *) val ccell_ptrvalue_null (a: Type0) : Tot (ccell_ptrvalue a) (* Pointer arithmetic: comparison to null, and pointer to fields. TODO: split these operations between Ghost and Steel, with a proper model of a "permission to do pointer arithmetic without actually reading the value/dereferencing" *) val ccell_ptrvalue_is_null (#a: Type0) (c: ccell_ptrvalue a) : Pure bool (requires True) (ensures (fun b -> b == true <==> c == ccell_ptrvalue_null a)) let ccell_lvalue (a: Type0) = (c: ccell_ptrvalue a { ccell_ptrvalue_is_null c == false }) (* "ccell" seen as a lvalue, or "ccell * const". IMPORTANT: one MUST NOT use "ref ccell_lvalue" in C code. In other words, ref can be used to model pointers to rvalues only. *) val ccell_data (#a: Type0) (c: ccell_lvalue a) : Pure (ref a) (requires True) (ensures (fun v -> ~ (is_null v))) val ccell_next (#a: Type0) (c: ccell_lvalue a) : Pure (ref (ccell_ptrvalue a)) (requires True) (ensures (fun v -> ~ (is_null v))) (* Important: we DO NOT provide a pure constructor for this data type, since its fields MUST be allocated at the same time and a cell MUST NOT be forged from references that would not come from such same-time allocation. *) (* The high-level value of a cell (should NEVER be used in C code, only in specs) *) noeq type vcell (a: Type0) = { vcell_data : a; vcell_next : ccell_ptrvalue a; } val ccell_is_lvalue_hp (#a: Type) (c: ccell_ptrvalue a) : Tot (slprop u#1) val ccell_is_lvalue_sel (#a: Type) (c: ccell_ptrvalue a) : GTot (selector (ccell_lvalue a) (ccell_is_lvalue_hp c))
{ "checked_file": "/", "dependencies": [ "Steel.Reference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "CQueue.Cell.fsti" }
[ { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "CQueue", "short_module": null }, { "abbrev": false, "full_module": "CQueue", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c: CQueue.Cell.ccell_ptrvalue a -> Prims.GTot Steel.Effect.Common.vprop'
Prims.GTot
[ "sometrivial" ]
[]
[ "CQueue.Cell.ccell_ptrvalue", "Steel.Effect.Common.Mkvprop'", "CQueue.Cell.ccell_is_lvalue_hp", "CQueue.Cell.ccell_lvalue", "CQueue.Cell.ccell_is_lvalue_sel", "Steel.Effect.Common.vprop'" ]
[]
false
false
false
false
false
let ccell_is_lvalue' (#a: Type0) (c: ccell_ptrvalue a) : GTot vprop' =
{ hp = ccell_is_lvalue_hp c; t = ccell_lvalue a; sel = ccell_is_lvalue_sel c }
false
MerkleTree.New.High.Correct.Rhs.fst
MerkleTree.New.High.Correct.Rhs.rhs_equiv
val rhs_equiv: #hsz:pos -> j:nat -> rhs1:hashes #hsz {S.length rhs1 = log2c j} -> rhs2:hashes #hsz {S.length rhs2 = log2c j} -> actd:bool -> GTot Type0 (decreases j)
val rhs_equiv: #hsz:pos -> j:nat -> rhs1:hashes #hsz {S.length rhs1 = log2c j} -> rhs2:hashes #hsz {S.length rhs2 = log2c j} -> actd:bool -> GTot Type0 (decreases j)
let rec rhs_equiv #hsz j rhs1 rhs2 actd = if j = 0 then true else if j % 2 = 0 then rhs_equiv #hsz (j / 2) (S.tail rhs1) (S.tail rhs2) actd else ((if actd then S.head rhs1 == S.head rhs2 else true) /\ rhs_equiv #hsz (j / 2) (S.tail rhs1) (S.tail rhs2) true)
{ "file_name": "src/MerkleTree.New.High.Correct.Rhs.fst", "git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6", "git_url": "https://github.com/hacl-star/merkle-tree.git", "project_name": "merkle-tree" }
{ "end_col": 63, "end_line": 184, "start_col": 0, "start_line": 179 }
module MerkleTree.New.High.Correct.Rhs open FStar.Classical open FStar.Ghost open FStar.Seq module S = FStar.Seq module MTS = MerkleTree.Spec open MerkleTree.New.High open MerkleTree.New.High.Correct.Base #set-options "--z3rlimit 10 --initial_fuel 1 --max_fuel 1 --initial_ifuel 0 --max_ifuel 0" /// Correctness of rightmost hashes // Another version of `construct_rhs` that recursively // accumulates rightmost hashes. val construct_rhs_acc: #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} -> acc:hash #hsz -> actd:bool -> GTot (rhs:hashes #hsz {S.length rhs = log2c j} * hash #hsz) (decreases j) let rec construct_rhs_acc #_ #f j fhs acc actd = if j = 0 then (S.empty, acc) else begin if j % 2 = 0 then (let nrhsh = construct_rhs_acc #_ #f(j / 2) (S.tail fhs) acc actd in (S.cons hash_init (fst nrhsh), snd nrhsh)) else (let rhd = if actd then acc else hash_init in let nacc = if actd then f (S.last (S.head fhs)) acc else S.last (S.head fhs) in let nrhsh = construct_rhs_acc #_ #f (j / 2) (S.tail fhs) nacc true in (S.cons rhd (fst nrhsh), snd nrhsh)) end #push-options "--initial_ifuel 1 --max_ifuel 1" val construct_rhs_acc_odd: #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} -> acc:hash #hsz -> actd:bool -> Lemma (requires (j % 2 <> 0)) (ensures (let rrf = construct_rhs_acc #_ #f j fhs acc actd in let nacc = if actd then f (S.last (S.head fhs)) acc else S.last (S.head fhs) in let nrrf = construct_rhs_acc #_ #f (j / 2) (S.tail fhs) nacc true in S.equal (S.tail (fst rrf)) (fst nrrf) /\ snd rrf == snd nrrf)) let construct_rhs_acc_odd #_ #f j fhs acc actd = () #pop-options #push-options "--initial_fuel 2 --max_fuel 2" val construct_rhs_acc_inv_ok_0: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> fhs:hashess #hsz { S.length fhs = 1 /\ mt_hashes_lth_inv_log #hsz 1 fhs /\ mt_hashes_inv_log #_ #f 1 fhs} -> acc:hash #hsz -> actd:bool -> Lemma (requires True) (ensures (let crhs = construct_rhs_acc #_ #f 1 fhs acc actd in mt_rhs_inv #_ #f 1 (hash_seq_spec_full #_ #f (S.head fhs) acc actd) (fst crhs) actd /\ MTS.mt_get_root #_ #f #1 (hash_seq_spec_full #_ #f (S.head fhs) acc actd) == MTS.HRaw #hsz (snd crhs))) let construct_rhs_acc_inv_ok_0 #_ #f fhs acc actd = () #pop-options #push-options "--z3rlimit 300" #restart-solver val construct_rhs_acc_inv_ok: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> j:nat{j > 0} -> fhs:hashess #hsz { S.length fhs = log2c j /\ mt_hashes_lth_inv_log #hsz j fhs /\ mt_hashes_inv_log #_ #f j fhs} -> acc:hash #hsz -> actd:bool -> Lemma (requires True) (ensures (let crhs = construct_rhs_acc #_ #f j fhs acc actd in mt_rhs_inv #_ #f j (hash_seq_spec_full #_ #f (S.head fhs) acc actd) (fst crhs) actd /\ MTS.mt_get_root #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.head fhs) acc actd) == MTS.HRaw (snd crhs))) (decreases j) let rec construct_rhs_acc_inv_ok #hsz #f j fhs acc actd = if j = 1 then construct_rhs_acc_inv_ok_0 #_ #f fhs acc actd else if j % 2 = 0 then begin construct_rhs_acc_inv_ok #_ #f (j / 2) (S.tail fhs) acc actd; let rcrhs = construct_rhs_acc #_ #f (j / 2) (S.tail fhs) acc actd in assert (mt_rhs_inv #_ #f (j / 2) (hash_seq_spec_full #_ #f (S.head (S.tail fhs)) acc actd) (fst rcrhs) actd); assert (MTS.mt_get_root #_ #f #(log2c j - 1) (hash_seq_spec_full #_ #f (S.head (S.tail fhs)) acc actd) == MTS.HRaw (snd rcrhs)); let crhs = (S.cons hash_init (fst rcrhs), snd rcrhs) in mt_hashes_lth_inv_log_next #_ #f j fhs; hash_seq_spec_full_even_next #_ #f j (S.head fhs) (S.head (S.tail fhs)) acc actd; assert (mt_rhs_inv #_ #f (j / 2) (MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.head fhs) acc actd)) (fst rcrhs) actd); assert (mt_rhs_inv #_ #f j (hash_seq_spec_full #_ #f (S.head fhs) acc actd) (fst crhs) actd); assert (MTS.mt_get_root #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.head fhs) acc actd) == MTS.HRaw (snd rcrhs)) end else begin let rhd = if actd then acc else hash_init #hsz in let nacc = if actd then f (S.last (S.head fhs)) acc else S.last (S.head fhs) in construct_rhs_acc_inv_ok #_ #f (j / 2) (S.tail fhs) nacc true; let rcrhs = construct_rhs_acc #_ #f (j / 2) (S.tail fhs) nacc true in assert (mt_rhs_inv #_ #f (j / 2) (hash_seq_spec_full #_ #f (S.head (S.tail fhs)) nacc true) (fst rcrhs) true); assert (MTS.mt_get_root #_ #f #(log2c j - 1) (hash_seq_spec_full #_ #f (S.head (S.tail fhs)) nacc true) == MTS.HRaw (snd rcrhs)); let crhs = (S.cons rhd (fst rcrhs), snd rcrhs) in mt_hashes_lth_inv_log_next #_ #f j fhs; hash_seq_spec_full_odd_next #_ #f j (S.head fhs) (S.head (S.tail fhs)) acc actd nacc; (if actd then hash_seq_spec_full_case_true #_ #f (S.head fhs) acc); assert (if actd then (S.index (hash_seq_spec_full #_ #f (S.head fhs) acc actd) j == MTS.HRaw rhd) else true); assert (mt_rhs_inv #_ #f (j / 2) (MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.head fhs) acc actd)) (fst rcrhs) true); assert (mt_rhs_inv #_ #f j (hash_seq_spec_full #_ #f (S.head fhs) acc actd) (fst crhs) actd); assert (MTS.mt_get_root #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.head fhs) acc actd) == MTS.HRaw (snd crhs)) end #pop-options val rhs_equiv: #hsz:pos -> j:nat -> rhs1:hashes #hsz {S.length rhs1 = log2c j} -> rhs2:hashes #hsz {S.length rhs2 = log2c j} -> actd:bool ->
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "MerkleTree.Spec.fst.checked", "MerkleTree.New.High.Correct.Base.fst.checked", "MerkleTree.New.High.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "MerkleTree.New.High.Correct.Rhs.fst" }
[ { "abbrev": false, "full_module": "MerkleTree.New.High.Correct.Base", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree.New.High", "short_module": null }, { "abbrev": true, "full_module": "MerkleTree.Spec", "short_module": "MTS" }, { "abbrev": true, "full_module": "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
j: Prims.nat -> rhs1: MerkleTree.New.High.hashes {FStar.Seq.Base.length rhs1 = MerkleTree.New.High.Correct.Base.log2c j} -> rhs2: MerkleTree.New.High.hashes {FStar.Seq.Base.length rhs2 = MerkleTree.New.High.Correct.Base.log2c j} -> actd: Prims.bool -> Prims.GTot Type0
Prims.GTot
[ "sometrivial", "" ]
[]
[ "Prims.pos", "Prims.nat", "MerkleTree.New.High.hashes", "Prims.b2t", "Prims.op_Equality", "FStar.Seq.Base.length", "MerkleTree.New.High.hash", "MerkleTree.New.High.Correct.Base.log2c", "Prims.bool", "Prims.int", "Prims.op_Modulus", "MerkleTree.New.High.Correct.Rhs.rhs_equiv", "Prims.op_Division", "FStar.Seq.Properties.tail", "Prims.l_and", "Prims.eq2", "FStar.Seq.Properties.head", "Prims.logical" ]
[ "recursion" ]
false
false
false
false
true
let rec rhs_equiv #hsz j rhs1 rhs2 actd =
if j = 0 then true else if j % 2 = 0 then rhs_equiv #hsz (j / 2) (S.tail rhs1) (S.tail rhs2) actd else ((if actd then S.head rhs1 == S.head rhs2 else true) /\ rhs_equiv #hsz (j / 2) (S.tail rhs1) (S.tail rhs2) true)
false
MerkleTree.New.High.Correct.Rhs.fst
MerkleTree.New.High.Correct.Rhs.construct_rhs_base_inv_ok
val construct_rhs_base_inv_ok: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> i:nat -> j:nat{j > 0 /\ i <= j /\ j < pow2 32} -> olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz 0 i olds} -> hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts 0 hs i j} -> rhs:hashes #hsz {S.length rhs = 32} -> acc:hash #hsz -> actd:bool -> Lemma (requires (mt_olds_hs_lth_inv_ok #_ #f 0 i j olds hs; mt_hashes_inv #_ #f 0 j (merge_hs #_ #f olds hs))) (ensures (log2c_bound j 32; mt_olds_hs_lth_inv_ok #_ #f 0 i j olds hs; (let crhs = construct_rhs #_ #f 0 hs rhs i j acc actd in mt_rhs_inv #_ #f j (hash_seq_spec_full #_ #f (S.head (merge_hs #_ #f olds hs)) acc actd) (S.slice (fst crhs) 0 (log2c j)) actd /\ MTS.mt_get_root #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.head (merge_hs #_ #f olds hs)) acc actd) == MTS.HRaw (snd crhs))))
val construct_rhs_base_inv_ok: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> i:nat -> j:nat{j > 0 /\ i <= j /\ j < pow2 32} -> olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz 0 i olds} -> hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts 0 hs i j} -> rhs:hashes #hsz {S.length rhs = 32} -> acc:hash #hsz -> actd:bool -> Lemma (requires (mt_olds_hs_lth_inv_ok #_ #f 0 i j olds hs; mt_hashes_inv #_ #f 0 j (merge_hs #_ #f olds hs))) (ensures (log2c_bound j 32; mt_olds_hs_lth_inv_ok #_ #f 0 i j olds hs; (let crhs = construct_rhs #_ #f 0 hs rhs i j acc actd in mt_rhs_inv #_ #f j (hash_seq_spec_full #_ #f (S.head (merge_hs #_ #f olds hs)) acc actd) (S.slice (fst crhs) 0 (log2c j)) actd /\ MTS.mt_get_root #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.head (merge_hs #_ #f olds hs)) acc actd) == MTS.HRaw (snd crhs))))
let construct_rhs_base_inv_ok #hsz #f i j olds hs rhs acc actd = construct_rhs_inv_ok #_ #f 0 i j olds hs rhs acc actd
{ "file_name": "src/MerkleTree.New.High.Correct.Rhs.fst", "git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6", "git_url": "https://github.com/hacl-star/merkle-tree.git", "project_name": "merkle-tree" }
{ "end_col": 55, "end_line": 374, "start_col": 0, "start_line": 373 }
module MerkleTree.New.High.Correct.Rhs open FStar.Classical open FStar.Ghost open FStar.Seq module S = FStar.Seq module MTS = MerkleTree.Spec open MerkleTree.New.High open MerkleTree.New.High.Correct.Base #set-options "--z3rlimit 10 --initial_fuel 1 --max_fuel 1 --initial_ifuel 0 --max_ifuel 0" /// Correctness of rightmost hashes // Another version of `construct_rhs` that recursively // accumulates rightmost hashes. val construct_rhs_acc: #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} -> acc:hash #hsz -> actd:bool -> GTot (rhs:hashes #hsz {S.length rhs = log2c j} * hash #hsz) (decreases j) let rec construct_rhs_acc #_ #f j fhs acc actd = if j = 0 then (S.empty, acc) else begin if j % 2 = 0 then (let nrhsh = construct_rhs_acc #_ #f(j / 2) (S.tail fhs) acc actd in (S.cons hash_init (fst nrhsh), snd nrhsh)) else (let rhd = if actd then acc else hash_init in let nacc = if actd then f (S.last (S.head fhs)) acc else S.last (S.head fhs) in let nrhsh = construct_rhs_acc #_ #f (j / 2) (S.tail fhs) nacc true in (S.cons rhd (fst nrhsh), snd nrhsh)) end #push-options "--initial_ifuel 1 --max_ifuel 1" val construct_rhs_acc_odd: #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} -> acc:hash #hsz -> actd:bool -> Lemma (requires (j % 2 <> 0)) (ensures (let rrf = construct_rhs_acc #_ #f j fhs acc actd in let nacc = if actd then f (S.last (S.head fhs)) acc else S.last (S.head fhs) in let nrrf = construct_rhs_acc #_ #f (j / 2) (S.tail fhs) nacc true in S.equal (S.tail (fst rrf)) (fst nrrf) /\ snd rrf == snd nrrf)) let construct_rhs_acc_odd #_ #f j fhs acc actd = () #pop-options #push-options "--initial_fuel 2 --max_fuel 2" val construct_rhs_acc_inv_ok_0: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> fhs:hashess #hsz { S.length fhs = 1 /\ mt_hashes_lth_inv_log #hsz 1 fhs /\ mt_hashes_inv_log #_ #f 1 fhs} -> acc:hash #hsz -> actd:bool -> Lemma (requires True) (ensures (let crhs = construct_rhs_acc #_ #f 1 fhs acc actd in mt_rhs_inv #_ #f 1 (hash_seq_spec_full #_ #f (S.head fhs) acc actd) (fst crhs) actd /\ MTS.mt_get_root #_ #f #1 (hash_seq_spec_full #_ #f (S.head fhs) acc actd) == MTS.HRaw #hsz (snd crhs))) let construct_rhs_acc_inv_ok_0 #_ #f fhs acc actd = () #pop-options #push-options "--z3rlimit 300" #restart-solver val construct_rhs_acc_inv_ok: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> j:nat{j > 0} -> fhs:hashess #hsz { S.length fhs = log2c j /\ mt_hashes_lth_inv_log #hsz j fhs /\ mt_hashes_inv_log #_ #f j fhs} -> acc:hash #hsz -> actd:bool -> Lemma (requires True) (ensures (let crhs = construct_rhs_acc #_ #f j fhs acc actd in mt_rhs_inv #_ #f j (hash_seq_spec_full #_ #f (S.head fhs) acc actd) (fst crhs) actd /\ MTS.mt_get_root #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.head fhs) acc actd) == MTS.HRaw (snd crhs))) (decreases j) let rec construct_rhs_acc_inv_ok #hsz #f j fhs acc actd = if j = 1 then construct_rhs_acc_inv_ok_0 #_ #f fhs acc actd else if j % 2 = 0 then begin construct_rhs_acc_inv_ok #_ #f (j / 2) (S.tail fhs) acc actd; let rcrhs = construct_rhs_acc #_ #f (j / 2) (S.tail fhs) acc actd in assert (mt_rhs_inv #_ #f (j / 2) (hash_seq_spec_full #_ #f (S.head (S.tail fhs)) acc actd) (fst rcrhs) actd); assert (MTS.mt_get_root #_ #f #(log2c j - 1) (hash_seq_spec_full #_ #f (S.head (S.tail fhs)) acc actd) == MTS.HRaw (snd rcrhs)); let crhs = (S.cons hash_init (fst rcrhs), snd rcrhs) in mt_hashes_lth_inv_log_next #_ #f j fhs; hash_seq_spec_full_even_next #_ #f j (S.head fhs) (S.head (S.tail fhs)) acc actd; assert (mt_rhs_inv #_ #f (j / 2) (MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.head fhs) acc actd)) (fst rcrhs) actd); assert (mt_rhs_inv #_ #f j (hash_seq_spec_full #_ #f (S.head fhs) acc actd) (fst crhs) actd); assert (MTS.mt_get_root #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.head fhs) acc actd) == MTS.HRaw (snd rcrhs)) end else begin let rhd = if actd then acc else hash_init #hsz in let nacc = if actd then f (S.last (S.head fhs)) acc else S.last (S.head fhs) in construct_rhs_acc_inv_ok #_ #f (j / 2) (S.tail fhs) nacc true; let rcrhs = construct_rhs_acc #_ #f (j / 2) (S.tail fhs) nacc true in assert (mt_rhs_inv #_ #f (j / 2) (hash_seq_spec_full #_ #f (S.head (S.tail fhs)) nacc true) (fst rcrhs) true); assert (MTS.mt_get_root #_ #f #(log2c j - 1) (hash_seq_spec_full #_ #f (S.head (S.tail fhs)) nacc true) == MTS.HRaw (snd rcrhs)); let crhs = (S.cons rhd (fst rcrhs), snd rcrhs) in mt_hashes_lth_inv_log_next #_ #f j fhs; hash_seq_spec_full_odd_next #_ #f j (S.head fhs) (S.head (S.tail fhs)) acc actd nacc; (if actd then hash_seq_spec_full_case_true #_ #f (S.head fhs) acc); assert (if actd then (S.index (hash_seq_spec_full #_ #f (S.head fhs) acc actd) j == MTS.HRaw rhd) else true); assert (mt_rhs_inv #_ #f (j / 2) (MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.head fhs) acc actd)) (fst rcrhs) true); assert (mt_rhs_inv #_ #f j (hash_seq_spec_full #_ #f (S.head fhs) acc actd) (fst crhs) actd); assert (MTS.mt_get_root #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.head fhs) acc actd) == MTS.HRaw (snd crhs)) end #pop-options val rhs_equiv: #hsz:pos -> j:nat -> rhs1:hashes #hsz {S.length rhs1 = log2c j} -> rhs2:hashes #hsz {S.length rhs2 = log2c j} -> actd:bool -> GTot Type0 (decreases j) let rec rhs_equiv #hsz j rhs1 rhs2 actd = if j = 0 then true else if j % 2 = 0 then rhs_equiv #hsz (j / 2) (S.tail rhs1) (S.tail rhs2) actd else ((if actd then S.head rhs1 == S.head rhs2 else true) /\ rhs_equiv #hsz (j / 2) (S.tail rhs1) (S.tail rhs2) true) val rhs_equiv_inv_preserved: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> j:nat -> smt:MTS.merkle_tree (log2c j) -> rhs1:hashes #hsz {S.length rhs1 = log2c j} -> rhs2:hashes #hsz {S.length rhs2 = log2c j} -> actd:bool -> Lemma (requires (mt_rhs_inv #_ #f j smt rhs1 actd /\ rhs_equiv #hsz j rhs1 rhs2 actd)) (ensures (mt_rhs_inv #_ #f j smt rhs2 actd)) (decreases j) let rec rhs_equiv_inv_preserved #_ #f j smt rhs1 rhs2 actd = if j = 0 then () else if j % 2 = 0 then rhs_equiv_inv_preserved #_ #f (j / 2) (MTS.mt_next_lv #_ #f #(log2c j) smt) (S.tail rhs1) (S.tail rhs2) actd else begin (if actd then (assert (S.index smt j == MTS.HRaw (S.head rhs1)); assert (S.head rhs1 == S.head rhs2)) else ()); rhs_equiv_inv_preserved #_ #f (j / 2) (MTS.mt_next_lv #_ #f #(log2c j) smt) (S.tail rhs1) (S.tail rhs2) true end val construct_rhs_acc_consistent: #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 lv hs i j} -> rhs:hashes #hsz {S.length rhs = 32} -> acc:hash #hsz -> actd:bool -> Lemma (requires True) (ensures (log2c_bound j (32 - lv); mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs; mt_hashes_lth_inv_log_converted_ #_ #f lv j (merge_hs #_ #f olds hs); (let rrf = construct_rhs_acc #_ #f j (S.slice (merge_hs #_ #f olds hs) lv (lv + log2c j)) acc actd in let rr = construct_rhs #_ #f lv hs rhs i j acc actd in rhs_equiv #hsz j (fst rrf) (S.slice (fst rr) lv (lv + log2c j)) actd /\ snd rrf == snd rr))) (decreases j) #push-options "--z3rlimit 300 --ifuel 1" #push-options "--retry 3" let rec construct_rhs_acc_consistent #hsz #f lv i j olds hs rhs acc actd = assert (j < pow2 (32 - lv)); assert (j <> 0 ==> j / 2 < pow2 (32 - (lv + 1))); log2c_bound j (32 - lv); mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs; mt_hashes_lth_inv_log_converted_ #_ #f lv j (merge_hs #_ #f olds hs); let rrf = construct_rhs_acc #_ #f j (S.slice (merge_hs #_ #f olds hs) lv (lv + log2c j)) acc actd in let rr = construct_rhs #_ #f lv hs rhs i j acc actd in construct_rhs_unchanged #_ #f lv hs rhs i j acc actd; assert (S.equal (S.slice rhs 0 lv) (S.slice (fst rr) 0 lv)); if j = 0 then () else begin log2c_div j; assert (32 - (lv + 1) >= 0); log2c_bound (j / 2) (32 - (lv + 1)); mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs; mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) (merge_hs #_ #f olds hs); if j % 2 = 0 then begin construct_rhs_acc_consistent #_ #f (lv + 1) (i / 2) (j / 2) olds hs rhs acc actd; log2c_bound (j/2) (32 - (lv + 1)); mt_olds_hs_lth_inv_ok #hsz #f (lv+1) (i/2) (j/2) olds hs; mt_hashes_lth_inv_log_converted_ #_ #f lv j (merge_hs #_ #f olds hs); let rrf = construct_rhs_acc #_ #f j (S.slice (merge_hs #_ #f olds hs) lv (lv + log2c j)) acc actd in let rr = construct_rhs #_ #f lv hs rhs i j acc actd in assert (rhs_equiv #hsz j (fst rrf) (S.slice (fst rr) lv (lv + log2c j)) actd); assert (snd rrf == snd rr) end else begin let rhd = if actd then acc else hash_init in let nacc = if actd then f (S.last (S.index hs lv)) acc else S.last (S.index hs lv) in assert (S.equal (S.tail (S.slice (merge_hs #_ #f olds hs) lv (lv + log2c j))) (S.slice (merge_hs #_ #f olds hs) (lv + 1) (lv + 1 + log2c (j / 2)))); // Recursion step for `construct_rhs_acc` let nrrf = construct_rhs_acc #_ #f (j / 2) (S.slice (merge_hs #_ #f olds hs) (lv + 1) (lv + 1 + (log2c (j / 2)))) nacc true in construct_rhs_acc_odd #_ #f j (S.slice (merge_hs #_ #f olds hs) lv (lv + log2c j)) acc actd; // Recursion step for `construct_rhs` assert (hs_wf_elts (lv + 1) hs (i / 2) (j / 2)); let nrhs = if actd then S.upd rhs lv acc else rhs in let nrr = construct_rhs #_ #f (lv + 1) hs nrhs (i / 2) (j / 2) nacc true in construct_rhs_odd #_ #f lv hs rhs i j acc actd; construct_rhs_unchanged #_ #f (lv + 1) hs nrhs (i / 2) (j / 2) nacc true; assert (S.equal (S.slice nrhs 0 (lv + 1)) (S.slice (fst nrr) 0 (lv + 1))); assert (S.index (fst nrr) lv == S.index nrhs lv); // Recursion for the proof construct_rhs_acc_consistent #_ #f (lv + 1) (i / 2) (j / 2) olds hs nrhs nacc true; assert (rhs_equiv #hsz (j / 2) (fst nrrf) (S.slice (fst nrr) (lv + 1) (lv + 1 + log2c (j / 2))) true); assert (snd nrrf == snd nrr); // All together (if actd then (assert (S.head (fst rrf) == rhd); assert (rhd == acc); assert (S.index (fst rr) lv == S.index nrhs lv); assert (S.index nrhs lv == acc); assert (S.head (fst rrf) == S.index (fst rr) lv)) else ()); assert (if actd then S.head (fst rrf) == S.index (fst rr) lv else true); assert (rhs_equiv #hsz (j / 2) (S.tail (fst rrf)) (S.slice (fst rr) (lv + 1) (lv + 1 + log2c (j / 2))) true); assert (rhs_equiv #hsz j (fst rrf) (S.slice (fst rr) lv (lv + log2c j)) actd); assert (snd rrf == snd rr) end end #pop-options val construct_rhs_inv_ok: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> lv:nat{lv <= 32} -> i:nat -> j:nat{j > 0 /\ 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 lv hs i j} -> rhs:hashes #hsz {S.length rhs = 32} -> acc:hash #hsz -> actd:bool -> Lemma (requires (mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs; mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs))) (ensures (log2c_bound j (32 - lv); mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs; (let crhs = construct_rhs #_ #f lv hs rhs i j acc actd in mt_rhs_inv #_ #f j (hash_seq_spec_full #_ #f (S.index (merge_hs #_ #f olds hs) lv) acc actd) (S.slice (fst crhs) lv (lv + log2c j)) actd /\ MTS.mt_get_root #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.index (merge_hs #_ #f olds hs) lv) acc actd) == MTS.HRaw (snd crhs)))) let construct_rhs_inv_ok #hsz #f lv i j olds hs rhs acc actd = log2c_div j; log2c_bound j (32 - lv); mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs; mt_hashes_lth_inv_log_converted_ #_ #f lv j (merge_hs #_ #f olds hs); mt_hashes_inv_log_converted_ #_ #f lv j (merge_hs #_ #f olds hs); let crhs = construct_rhs #_ #f lv hs rhs i j acc actd in let crhsf = construct_rhs_acc #_ #f j (S.slice (merge_hs #_ #f olds hs) lv (lv + log2c j)) acc actd in construct_rhs_acc_consistent #_ #f lv i j olds hs rhs acc actd; construct_rhs_acc_inv_ok #_ #f j (S.slice (merge_hs #_ #f olds hs) lv (lv + log2c j)) acc actd; rhs_equiv_inv_preserved #_ #f j (hash_seq_spec_full #_ #f (S.index (merge_hs #_ #f olds hs) lv) acc actd) (fst crhsf) (S.slice (fst crhs) lv (lv + log2c j)) actd #pop-options val construct_rhs_base_inv_ok: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> i:nat -> j:nat{j > 0 /\ i <= j /\ j < pow2 32} -> olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz 0 i olds} -> hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts 0 hs i j} -> rhs:hashes #hsz {S.length rhs = 32} -> acc:hash #hsz -> actd:bool -> Lemma (requires (mt_olds_hs_lth_inv_ok #_ #f 0 i j olds hs; mt_hashes_inv #_ #f 0 j (merge_hs #_ #f olds hs))) (ensures (log2c_bound j 32; mt_olds_hs_lth_inv_ok #_ #f 0 i j olds hs; (let crhs = construct_rhs #_ #f 0 hs rhs i j acc actd in mt_rhs_inv #_ #f j (hash_seq_spec_full #_ #f (S.head (merge_hs #_ #f olds hs)) acc actd) (S.slice (fst crhs) 0 (log2c j)) actd /\ MTS.mt_get_root #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.head (merge_hs #_ #f olds hs)) acc actd) ==
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "MerkleTree.Spec.fst.checked", "MerkleTree.New.High.Correct.Base.fst.checked", "MerkleTree.New.High.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "MerkleTree.New.High.Correct.Rhs.fst" }
[ { "abbrev": false, "full_module": "MerkleTree.New.High.Correct.Base", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree.New.High", "short_module": null }, { "abbrev": true, "full_module": "MerkleTree.Spec", "short_module": "MTS" }, { "abbrev": true, "full_module": "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
i: Prims.nat -> j: Prims.nat{j > 0 /\ i <= j /\ j < Prims.pow2 32} -> olds: MerkleTree.New.High.hashess {FStar.Seq.Base.length olds = 32 /\ MerkleTree.New.High.Correct.Base.mt_olds_inv 0 i olds} -> hs: MerkleTree.New.High.hashess {FStar.Seq.Base.length hs = 32 /\ MerkleTree.New.High.hs_wf_elts 0 hs i j} -> rhs: MerkleTree.New.High.hashes{FStar.Seq.Base.length rhs = 32} -> acc: MerkleTree.New.High.hash -> actd: Prims.bool -> FStar.Pervasives.Lemma (requires (MerkleTree.New.High.Correct.Base.mt_olds_hs_lth_inv_ok 0 i j olds hs; MerkleTree.New.High.Correct.Base.mt_hashes_inv 0 j (MerkleTree.New.High.Correct.Base.merge_hs olds hs))) (ensures (MerkleTree.New.High.Correct.Base.log2c_bound j 32; MerkleTree.New.High.Correct.Base.mt_olds_hs_lth_inv_ok 0 i j olds hs; let crhs = MerkleTree.New.High.construct_rhs 0 hs rhs i j acc actd in MerkleTree.New.High.Correct.Base.mt_rhs_inv j (MerkleTree.New.High.Correct.Base.hash_seq_spec_full (FStar.Seq.Properties.head (MerkleTree.New.High.Correct.Base.merge_hs olds hs)) acc actd) (FStar.Seq.Base.slice (FStar.Pervasives.Native.fst crhs) 0 (MerkleTree.New.High.Correct.Base.log2c j)) actd /\ MerkleTree.Spec.mt_get_root (MerkleTree.New.High.Correct.Base.hash_seq_spec_full (FStar.Seq.Properties.head (MerkleTree.New.High.Correct.Base.merge_hs olds hs)) acc actd) == MerkleTree.Spec.HRaw (FStar.Pervasives.Native.snd crhs)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.pos", "MerkleTree.Spec.hash_fun_t", "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "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_olds_inv", "MerkleTree.New.High.hs_wf_elts", "MerkleTree.New.High.hash", "Prims.bool", "MerkleTree.New.High.Correct.Rhs.construct_rhs_inv_ok", "Prims.unit" ]
[]
true
false
true
false
false
let construct_rhs_base_inv_ok #hsz #f i j olds hs rhs acc actd =
construct_rhs_inv_ok #_ #f 0 i j olds hs rhs acc actd
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.modq
val modq: out:qelem -> a:lbuffer uint64 (2ul *! qnlimb) -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == BD.bn_v h0 a % S.q)
val modq: out:qelem -> a:lbuffer uint64 (2ul *! qnlimb) -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == BD.bn_v h0 a % S.q)
let modq out a = push_frame (); let r = create_qelem () in let tmp = create_qelem () in [@inline_let] let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in make_u64_4 tmp (t0,t1,t2,t3); let t01 = sub tmp 0ul 2ul in let h0 = ST.get () in assert (Seq.equal (as_seq h0 t01) (LSeq.create2 t0 t1)); let c0 = modq_before_final t01 a r in let c1 = kn.BN.add r tmp out in let mask = u64 0 -. (c0 +. c1) in map2T qnlimb out (BB.mask_select mask) out r; let h1 = ST.get () in KL.mod_lseq_lemma (as_seq h0 a); pop_frame ()
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 14, "end_line": 315, "start_col": 0, "start_line": 296 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb let sub4: BN.bn_sub_eq_len_st U64 qnlimb = BN.bn_sub_eq_len qnlimb let add_mod4: BN.bn_add_mod_n_st U64 qnlimb = BN.bn_add_mod_n qnlimb let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb = BN.bn_sub_mod_n qnlimb let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a = BN.bn_mul qnlimb qnlimb a let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a = BN.bn_sqr qnlimb a inline_for_extraction noextract instance kn: BN.bn U64 = { BN.len = qnlimb; BN.add = add4; BN.sub = sub4; BN.add_mod_n = add_mod4; BN.sub_mod_n = sub_mod4; BN.mul = mul4; BN.sqr = sqr4 } let make_u64_4 out (f0, f1, f2, f3) = out.(0ul) <- f0; out.(1ul) <- f1; out.(2ul) <- f2; out.(3ul) <- f3; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h out); assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3)) let make_order_k256 () = [@inline_let] let r = (u64 0xbfd25e8cd0364141, u64 0xbaaedce6af48a03b, u64 0xfffffffffffffffe, u64 0xffffffffffffffff) in assert_norm (qas_nat4 r = S.q); r let create_qelem () = SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb); create qnlimb (u64 0) let create_one () = [@inline_let] let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in assert_norm (FStar.List.Tot.length l = 4); Seq.elim_of_list l; LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l); KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)); createL l [@CInline] let is_qelem_zero f = let h0 = ST.get () in SN.bn_is_zero_mask_lemma (as_seq h0 f); BN.bn_is_zero_mask qnlimb f [@CInline] let is_qelem_zero_vartime f = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3); is_qelem_zero_vartime4 (f0,f1,f2,f3) [@CInline] let is_qelem_eq_vartime f1 f2 = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f1); KL.qas_nat4_is_qas_nat (as_seq h f2); let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3); is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3) let load_qelem f b = let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b); Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f [@CInline] let load_qelem_check f b = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); load_qelem f b; let h0 = ST.get () in let is_zero = is_qelem_zero f in assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0)); let is_lt_q = BN.bn_lt_mask qnlimb f n in SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n); assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0)); let m = logand (lognot is_zero) is_lt_q in lognot_lemma is_zero; logand_lemma (lognot is_zero) is_lt_q; pop_frame (); m let load_qelem_conditional res b = push_frame (); let is_b_valid = load_qelem_check res b in let oneq = create_one () in let h0 = ST.get () in Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res; let h1 = ST.get () in assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res)); pop_frame (); is_b_valid [@CInline] let load_qelem_vartime f b = load_qelem f b; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let is_zero = is_qelem_zero_vartime f in let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in let is_lt_q_b = is_qelem_lt_q_vartime4 (a0,a1,a2,a3) in KL.is_qelem_lt_q_vartime4_lemma (a0,a1,a2,a3); not is_zero && is_lt_q_b val modq_short: out:qelem -> a:qelem -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == qas_nat h0 a % S.q) [@CInline] let modq_short out a = push_frame (); let tmp = create_qelem () in [@inline_let] let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in make_u64_4 tmp (t0,t1,t2,t3); let h0 = ST.get () in let c = kn.BN.add a tmp out in let mask = u64 0 -. c in map2T qnlimb out (BB.mask_select mask) out a; KL.mod_short_lseq_lemma (as_seq h0 a); pop_frame () [@CInline] let load_qelem_modq f b = push_frame (); let tmp = create_qelem () in load_qelem f b; copy tmp f; modq_short f tmp; pop_frame () [@CInline] let store_qelem b f = let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma #U64 32 (as_seq h0 f); Hacl.Bignum.Convert.mk_bn_to_bytes_be true 32ul f b [@CInline] let qadd out f1 f2 = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); let h0 = ST.get () in kn.BN.add_mod_n n f1 f2 out; SN.bn_add_mod_n_lemma (as_seq h0 n) (as_seq h0 f1) (as_seq h0 f2); pop_frame () val mul_pow2_256_minus_q_add: len:size_t -> resLen:size_t{2 + v len <= v resLen /\ 4 <= v resLen} -> t01:lbuffer uint64 2ul -> a:lbuffer uint64 len -> e:lbuffer uint64 4ul -> res:lbuffer uint64 resLen -> Stack (BB.carry U64) (requires fun h -> live h a /\ live h res /\ live h t01 /\ live h e /\ disjoint a res /\ disjoint a t01 /\ disjoint a e /\ disjoint res t01 /\ disjoint res e /\ disjoint t01 e /\ as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\ as_seq h res == LSeq.create (v resLen) (u64 0)) (ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\ (c, as_seq h1 res) == mul_pow2_256_minus_q_lseq_add (v len) (v resLen) (as_seq h0 a) (as_seq h0 e)) [@CInline] let mul_pow2_256_minus_q_add len resLen t01 a e res = push_frame (); let tmp = create (len +! 2ul) (u64 0) in BN.bn_mul len 2ul a t01 tmp; update_sub res 2ul len a; let _ = bn_add resLen res (len +! 2ul) tmp res in let c = bn_add resLen res 4ul e res in pop_frame (); c inline_for_extraction noextract val modq_before_final: t01:lbuffer uint64 2ul -> a:lbuffer uint64 (2ul *! qnlimb) -> out:qelem -> Stack (BB.carry U64) (requires fun h -> live h a /\ live h out /\ live h t01 /\ disjoint a out /\ disjoint a t01 /\ disjoint out t01 /\ as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\ as_seq h out == LSeq.create 4 (u64 0)) (ensures fun h0 c h1 -> modifies (loc out) h0 h1 /\ (c, as_seq h1 out) == mod_lseq_before_final (as_seq h0 a)) let modq_before_final t01 a out = push_frame (); let m = create 7ul (u64 0) in let p = create 5ul (u64 0) in let c0 = mul_pow2_256_minus_q_add 4ul 7ul t01 (sub a 4ul 4ul) (sub a 0ul 4ul) m in let c1 = mul_pow2_256_minus_q_add 3ul 5ul t01 (sub m 4ul 3ul) (sub m 0ul 4ul) p in let c2 = mul_pow2_256_minus_q_add 1ul 4ul t01 (sub p 4ul 1ul) (sub p 0ul 4ul) out in pop_frame (); c2 val modq: out:qelem -> a:lbuffer uint64 (2ul *! qnlimb) -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == BD.bn_v h0 a % S.q)
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
out: Hacl.K256.Scalar.qelem -> a: Lib.Buffer.lbuffer Lib.IntTypes.uint64 (2ul *! Hacl.K256.Scalar.qnlimb) -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.K256.Scalar.qelem", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint64", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.UInt32.__uint_to_t", "Hacl.K256.Scalar.qnlimb", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Spec.K256.Scalar.Lemmas.mod_lseq_lemma", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.Buffer.map2T", "Hacl.Spec.Bignum.Base.mask_select", "Lib.IntTypes.U64", "Lib.IntTypes.int_t", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Subtraction_Dot", "Lib.IntTypes.u64", "Lib.IntTypes.op_Plus_Dot", "Hacl.Spec.Bignum.Base.carry", "Hacl.Bignum.__proj__Mkbn__item__add", "Hacl.K256.Scalar.kn", "Hacl.K256.Scalar.modq_before_final", "Prims._assert", "FStar.Seq.Base.equal", "Lib.Sequence.create2", "Lib.Buffer.lbuffer_t", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.sub", "Hacl.K256.Scalar.make_u64_4", "FStar.Pervasives.Native.Mktuple4", "Hacl.Spec.K256.Scalar.qelem4", "Hacl.Spec.K256.Scalar.make_pow2_256_minus_order_k256", "Hacl.K256.Scalar.create_qelem", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let modq out a =
push_frame (); let r = create_qelem () in let tmp = create_qelem () in [@@ inline_let ]let t0, t1, t2, t3 = make_pow2_256_minus_order_k256 () in make_u64_4 tmp (t0, t1, t2, t3); let t01 = sub tmp 0ul 2ul in let h0 = ST.get () in assert (Seq.equal (as_seq h0 t01) (LSeq.create2 t0 t1)); let c0 = modq_before_final t01 a r in let c1 = kn.BN.add r tmp out in let mask = u64 0 -. (c0 +. c1) in map2T qnlimb out (BB.mask_select mask) out r; let h1 = ST.get () in KL.mod_lseq_lemma (as_seq h0 a); pop_frame ()
false
MerkleTree.New.High.Correct.Rhs.fst
MerkleTree.New.High.Correct.Rhs.construct_rhs_init_ignored
val construct_rhs_init_ignored: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> lv:nat{lv <= 32} -> hs:hashess #hsz {S.length hs = 32} -> rhs:hashes #hsz {S.length rhs = 32} -> i:nat -> j:nat{ i <= j /\ j < pow2 (32 - lv) /\ hs_wf_elts lv hs i j} -> acc1:hash #hsz -> acc2:hash #hsz -> Lemma (requires (j > 0)) (ensures (let rr1 = construct_rhs #_ #f lv hs rhs i j acc1 false in let rr2 = construct_rhs #_ #f lv hs rhs i j acc2 false in S.equal (fst rr1) (fst rr2) /\ snd rr1 == snd rr2)) (decreases j)
val construct_rhs_init_ignored: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> lv:nat{lv <= 32} -> hs:hashess #hsz {S.length hs = 32} -> rhs:hashes #hsz {S.length rhs = 32} -> i:nat -> j:nat{ i <= j /\ j < pow2 (32 - lv) /\ hs_wf_elts lv hs i j} -> acc1:hash #hsz -> acc2:hash #hsz -> Lemma (requires (j > 0)) (ensures (let rr1 = construct_rhs #_ #f lv hs rhs i j acc1 false in let rr2 = construct_rhs #_ #f lv hs rhs i j acc2 false in S.equal (fst rr1) (fst rr2) /\ snd rr1 == snd rr2)) (decreases j)
let rec construct_rhs_init_ignored #hsz #f lv hs rhs i j acc1 acc2 = if j % 2 = 0 then construct_rhs_init_ignored #_ #f (lv + 1) hs rhs (i / 2) (j / 2) acc1 acc2 else ()
{ "file_name": "src/MerkleTree.New.High.Correct.Rhs.fst", "git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6", "git_url": "https://github.com/hacl-star/merkle-tree.git", "project_name": "merkle-tree" }
{ "end_col": 9, "end_line": 395, "start_col": 0, "start_line": 392 }
module MerkleTree.New.High.Correct.Rhs open FStar.Classical open FStar.Ghost open FStar.Seq module S = FStar.Seq module MTS = MerkleTree.Spec open MerkleTree.New.High open MerkleTree.New.High.Correct.Base #set-options "--z3rlimit 10 --initial_fuel 1 --max_fuel 1 --initial_ifuel 0 --max_ifuel 0" /// Correctness of rightmost hashes // Another version of `construct_rhs` that recursively // accumulates rightmost hashes. val construct_rhs_acc: #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} -> acc:hash #hsz -> actd:bool -> GTot (rhs:hashes #hsz {S.length rhs = log2c j} * hash #hsz) (decreases j) let rec construct_rhs_acc #_ #f j fhs acc actd = if j = 0 then (S.empty, acc) else begin if j % 2 = 0 then (let nrhsh = construct_rhs_acc #_ #f(j / 2) (S.tail fhs) acc actd in (S.cons hash_init (fst nrhsh), snd nrhsh)) else (let rhd = if actd then acc else hash_init in let nacc = if actd then f (S.last (S.head fhs)) acc else S.last (S.head fhs) in let nrhsh = construct_rhs_acc #_ #f (j / 2) (S.tail fhs) nacc true in (S.cons rhd (fst nrhsh), snd nrhsh)) end #push-options "--initial_ifuel 1 --max_ifuel 1" val construct_rhs_acc_odd: #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} -> acc:hash #hsz -> actd:bool -> Lemma (requires (j % 2 <> 0)) (ensures (let rrf = construct_rhs_acc #_ #f j fhs acc actd in let nacc = if actd then f (S.last (S.head fhs)) acc else S.last (S.head fhs) in let nrrf = construct_rhs_acc #_ #f (j / 2) (S.tail fhs) nacc true in S.equal (S.tail (fst rrf)) (fst nrrf) /\ snd rrf == snd nrrf)) let construct_rhs_acc_odd #_ #f j fhs acc actd = () #pop-options #push-options "--initial_fuel 2 --max_fuel 2" val construct_rhs_acc_inv_ok_0: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> fhs:hashess #hsz { S.length fhs = 1 /\ mt_hashes_lth_inv_log #hsz 1 fhs /\ mt_hashes_inv_log #_ #f 1 fhs} -> acc:hash #hsz -> actd:bool -> Lemma (requires True) (ensures (let crhs = construct_rhs_acc #_ #f 1 fhs acc actd in mt_rhs_inv #_ #f 1 (hash_seq_spec_full #_ #f (S.head fhs) acc actd) (fst crhs) actd /\ MTS.mt_get_root #_ #f #1 (hash_seq_spec_full #_ #f (S.head fhs) acc actd) == MTS.HRaw #hsz (snd crhs))) let construct_rhs_acc_inv_ok_0 #_ #f fhs acc actd = () #pop-options #push-options "--z3rlimit 300" #restart-solver val construct_rhs_acc_inv_ok: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> j:nat{j > 0} -> fhs:hashess #hsz { S.length fhs = log2c j /\ mt_hashes_lth_inv_log #hsz j fhs /\ mt_hashes_inv_log #_ #f j fhs} -> acc:hash #hsz -> actd:bool -> Lemma (requires True) (ensures (let crhs = construct_rhs_acc #_ #f j fhs acc actd in mt_rhs_inv #_ #f j (hash_seq_spec_full #_ #f (S.head fhs) acc actd) (fst crhs) actd /\ MTS.mt_get_root #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.head fhs) acc actd) == MTS.HRaw (snd crhs))) (decreases j) let rec construct_rhs_acc_inv_ok #hsz #f j fhs acc actd = if j = 1 then construct_rhs_acc_inv_ok_0 #_ #f fhs acc actd else if j % 2 = 0 then begin construct_rhs_acc_inv_ok #_ #f (j / 2) (S.tail fhs) acc actd; let rcrhs = construct_rhs_acc #_ #f (j / 2) (S.tail fhs) acc actd in assert (mt_rhs_inv #_ #f (j / 2) (hash_seq_spec_full #_ #f (S.head (S.tail fhs)) acc actd) (fst rcrhs) actd); assert (MTS.mt_get_root #_ #f #(log2c j - 1) (hash_seq_spec_full #_ #f (S.head (S.tail fhs)) acc actd) == MTS.HRaw (snd rcrhs)); let crhs = (S.cons hash_init (fst rcrhs), snd rcrhs) in mt_hashes_lth_inv_log_next #_ #f j fhs; hash_seq_spec_full_even_next #_ #f j (S.head fhs) (S.head (S.tail fhs)) acc actd; assert (mt_rhs_inv #_ #f (j / 2) (MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.head fhs) acc actd)) (fst rcrhs) actd); assert (mt_rhs_inv #_ #f j (hash_seq_spec_full #_ #f (S.head fhs) acc actd) (fst crhs) actd); assert (MTS.mt_get_root #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.head fhs) acc actd) == MTS.HRaw (snd rcrhs)) end else begin let rhd = if actd then acc else hash_init #hsz in let nacc = if actd then f (S.last (S.head fhs)) acc else S.last (S.head fhs) in construct_rhs_acc_inv_ok #_ #f (j / 2) (S.tail fhs) nacc true; let rcrhs = construct_rhs_acc #_ #f (j / 2) (S.tail fhs) nacc true in assert (mt_rhs_inv #_ #f (j / 2) (hash_seq_spec_full #_ #f (S.head (S.tail fhs)) nacc true) (fst rcrhs) true); assert (MTS.mt_get_root #_ #f #(log2c j - 1) (hash_seq_spec_full #_ #f (S.head (S.tail fhs)) nacc true) == MTS.HRaw (snd rcrhs)); let crhs = (S.cons rhd (fst rcrhs), snd rcrhs) in mt_hashes_lth_inv_log_next #_ #f j fhs; hash_seq_spec_full_odd_next #_ #f j (S.head fhs) (S.head (S.tail fhs)) acc actd nacc; (if actd then hash_seq_spec_full_case_true #_ #f (S.head fhs) acc); assert (if actd then (S.index (hash_seq_spec_full #_ #f (S.head fhs) acc actd) j == MTS.HRaw rhd) else true); assert (mt_rhs_inv #_ #f (j / 2) (MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.head fhs) acc actd)) (fst rcrhs) true); assert (mt_rhs_inv #_ #f j (hash_seq_spec_full #_ #f (S.head fhs) acc actd) (fst crhs) actd); assert (MTS.mt_get_root #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.head fhs) acc actd) == MTS.HRaw (snd crhs)) end #pop-options val rhs_equiv: #hsz:pos -> j:nat -> rhs1:hashes #hsz {S.length rhs1 = log2c j} -> rhs2:hashes #hsz {S.length rhs2 = log2c j} -> actd:bool -> GTot Type0 (decreases j) let rec rhs_equiv #hsz j rhs1 rhs2 actd = if j = 0 then true else if j % 2 = 0 then rhs_equiv #hsz (j / 2) (S.tail rhs1) (S.tail rhs2) actd else ((if actd then S.head rhs1 == S.head rhs2 else true) /\ rhs_equiv #hsz (j / 2) (S.tail rhs1) (S.tail rhs2) true) val rhs_equiv_inv_preserved: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> j:nat -> smt:MTS.merkle_tree (log2c j) -> rhs1:hashes #hsz {S.length rhs1 = log2c j} -> rhs2:hashes #hsz {S.length rhs2 = log2c j} -> actd:bool -> Lemma (requires (mt_rhs_inv #_ #f j smt rhs1 actd /\ rhs_equiv #hsz j rhs1 rhs2 actd)) (ensures (mt_rhs_inv #_ #f j smt rhs2 actd)) (decreases j) let rec rhs_equiv_inv_preserved #_ #f j smt rhs1 rhs2 actd = if j = 0 then () else if j % 2 = 0 then rhs_equiv_inv_preserved #_ #f (j / 2) (MTS.mt_next_lv #_ #f #(log2c j) smt) (S.tail rhs1) (S.tail rhs2) actd else begin (if actd then (assert (S.index smt j == MTS.HRaw (S.head rhs1)); assert (S.head rhs1 == S.head rhs2)) else ()); rhs_equiv_inv_preserved #_ #f (j / 2) (MTS.mt_next_lv #_ #f #(log2c j) smt) (S.tail rhs1) (S.tail rhs2) true end val construct_rhs_acc_consistent: #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 lv hs i j} -> rhs:hashes #hsz {S.length rhs = 32} -> acc:hash #hsz -> actd:bool -> Lemma (requires True) (ensures (log2c_bound j (32 - lv); mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs; mt_hashes_lth_inv_log_converted_ #_ #f lv j (merge_hs #_ #f olds hs); (let rrf = construct_rhs_acc #_ #f j (S.slice (merge_hs #_ #f olds hs) lv (lv + log2c j)) acc actd in let rr = construct_rhs #_ #f lv hs rhs i j acc actd in rhs_equiv #hsz j (fst rrf) (S.slice (fst rr) lv (lv + log2c j)) actd /\ snd rrf == snd rr))) (decreases j) #push-options "--z3rlimit 300 --ifuel 1" #push-options "--retry 3" let rec construct_rhs_acc_consistent #hsz #f lv i j olds hs rhs acc actd = assert (j < pow2 (32 - lv)); assert (j <> 0 ==> j / 2 < pow2 (32 - (lv + 1))); log2c_bound j (32 - lv); mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs; mt_hashes_lth_inv_log_converted_ #_ #f lv j (merge_hs #_ #f olds hs); let rrf = construct_rhs_acc #_ #f j (S.slice (merge_hs #_ #f olds hs) lv (lv + log2c j)) acc actd in let rr = construct_rhs #_ #f lv hs rhs i j acc actd in construct_rhs_unchanged #_ #f lv hs rhs i j acc actd; assert (S.equal (S.slice rhs 0 lv) (S.slice (fst rr) 0 lv)); if j = 0 then () else begin log2c_div j; assert (32 - (lv + 1) >= 0); log2c_bound (j / 2) (32 - (lv + 1)); mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs; mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) (merge_hs #_ #f olds hs); if j % 2 = 0 then begin construct_rhs_acc_consistent #_ #f (lv + 1) (i / 2) (j / 2) olds hs rhs acc actd; log2c_bound (j/2) (32 - (lv + 1)); mt_olds_hs_lth_inv_ok #hsz #f (lv+1) (i/2) (j/2) olds hs; mt_hashes_lth_inv_log_converted_ #_ #f lv j (merge_hs #_ #f olds hs); let rrf = construct_rhs_acc #_ #f j (S.slice (merge_hs #_ #f olds hs) lv (lv + log2c j)) acc actd in let rr = construct_rhs #_ #f lv hs rhs i j acc actd in assert (rhs_equiv #hsz j (fst rrf) (S.slice (fst rr) lv (lv + log2c j)) actd); assert (snd rrf == snd rr) end else begin let rhd = if actd then acc else hash_init in let nacc = if actd then f (S.last (S.index hs lv)) acc else S.last (S.index hs lv) in assert (S.equal (S.tail (S.slice (merge_hs #_ #f olds hs) lv (lv + log2c j))) (S.slice (merge_hs #_ #f olds hs) (lv + 1) (lv + 1 + log2c (j / 2)))); // Recursion step for `construct_rhs_acc` let nrrf = construct_rhs_acc #_ #f (j / 2) (S.slice (merge_hs #_ #f olds hs) (lv + 1) (lv + 1 + (log2c (j / 2)))) nacc true in construct_rhs_acc_odd #_ #f j (S.slice (merge_hs #_ #f olds hs) lv (lv + log2c j)) acc actd; // Recursion step for `construct_rhs` assert (hs_wf_elts (lv + 1) hs (i / 2) (j / 2)); let nrhs = if actd then S.upd rhs lv acc else rhs in let nrr = construct_rhs #_ #f (lv + 1) hs nrhs (i / 2) (j / 2) nacc true in construct_rhs_odd #_ #f lv hs rhs i j acc actd; construct_rhs_unchanged #_ #f (lv + 1) hs nrhs (i / 2) (j / 2) nacc true; assert (S.equal (S.slice nrhs 0 (lv + 1)) (S.slice (fst nrr) 0 (lv + 1))); assert (S.index (fst nrr) lv == S.index nrhs lv); // Recursion for the proof construct_rhs_acc_consistent #_ #f (lv + 1) (i / 2) (j / 2) olds hs nrhs nacc true; assert (rhs_equiv #hsz (j / 2) (fst nrrf) (S.slice (fst nrr) (lv + 1) (lv + 1 + log2c (j / 2))) true); assert (snd nrrf == snd nrr); // All together (if actd then (assert (S.head (fst rrf) == rhd); assert (rhd == acc); assert (S.index (fst rr) lv == S.index nrhs lv); assert (S.index nrhs lv == acc); assert (S.head (fst rrf) == S.index (fst rr) lv)) else ()); assert (if actd then S.head (fst rrf) == S.index (fst rr) lv else true); assert (rhs_equiv #hsz (j / 2) (S.tail (fst rrf)) (S.slice (fst rr) (lv + 1) (lv + 1 + log2c (j / 2))) true); assert (rhs_equiv #hsz j (fst rrf) (S.slice (fst rr) lv (lv + log2c j)) actd); assert (snd rrf == snd rr) end end #pop-options val construct_rhs_inv_ok: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> lv:nat{lv <= 32} -> i:nat -> j:nat{j > 0 /\ 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 lv hs i j} -> rhs:hashes #hsz {S.length rhs = 32} -> acc:hash #hsz -> actd:bool -> Lemma (requires (mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs; mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs))) (ensures (log2c_bound j (32 - lv); mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs; (let crhs = construct_rhs #_ #f lv hs rhs i j acc actd in mt_rhs_inv #_ #f j (hash_seq_spec_full #_ #f (S.index (merge_hs #_ #f olds hs) lv) acc actd) (S.slice (fst crhs) lv (lv + log2c j)) actd /\ MTS.mt_get_root #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.index (merge_hs #_ #f olds hs) lv) acc actd) == MTS.HRaw (snd crhs)))) let construct_rhs_inv_ok #hsz #f lv i j olds hs rhs acc actd = log2c_div j; log2c_bound j (32 - lv); mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs; mt_hashes_lth_inv_log_converted_ #_ #f lv j (merge_hs #_ #f olds hs); mt_hashes_inv_log_converted_ #_ #f lv j (merge_hs #_ #f olds hs); let crhs = construct_rhs #_ #f lv hs rhs i j acc actd in let crhsf = construct_rhs_acc #_ #f j (S.slice (merge_hs #_ #f olds hs) lv (lv + log2c j)) acc actd in construct_rhs_acc_consistent #_ #f lv i j olds hs rhs acc actd; construct_rhs_acc_inv_ok #_ #f j (S.slice (merge_hs #_ #f olds hs) lv (lv + log2c j)) acc actd; rhs_equiv_inv_preserved #_ #f j (hash_seq_spec_full #_ #f (S.index (merge_hs #_ #f olds hs) lv) acc actd) (fst crhsf) (S.slice (fst crhs) lv (lv + log2c j)) actd #pop-options val construct_rhs_base_inv_ok: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> i:nat -> j:nat{j > 0 /\ i <= j /\ j < pow2 32} -> olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz 0 i olds} -> hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts 0 hs i j} -> rhs:hashes #hsz {S.length rhs = 32} -> acc:hash #hsz -> actd:bool -> Lemma (requires (mt_olds_hs_lth_inv_ok #_ #f 0 i j olds hs; mt_hashes_inv #_ #f 0 j (merge_hs #_ #f olds hs))) (ensures (log2c_bound j 32; mt_olds_hs_lth_inv_ok #_ #f 0 i j olds hs; (let crhs = construct_rhs #_ #f 0 hs rhs i j acc actd in mt_rhs_inv #_ #f j (hash_seq_spec_full #_ #f (S.head (merge_hs #_ #f olds hs)) acc actd) (S.slice (fst crhs) 0 (log2c j)) actd /\ MTS.mt_get_root #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.head (merge_hs #_ #f olds hs)) acc actd) == MTS.HRaw (snd crhs)))) let construct_rhs_base_inv_ok #hsz #f i j olds hs rhs acc actd = construct_rhs_inv_ok #_ #f 0 i j olds hs rhs acc actd val construct_rhs_init_ignored: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> lv:nat{lv <= 32} -> hs:hashess #hsz {S.length hs = 32} -> rhs:hashes #hsz {S.length rhs = 32} -> i:nat -> j:nat{ i <= j /\ j < pow2 (32 - lv) /\ hs_wf_elts lv hs i j} -> acc1:hash #hsz -> acc2:hash #hsz -> Lemma (requires (j > 0)) (ensures (let rr1 = construct_rhs #_ #f lv hs rhs i j acc1 false in let rr2 = construct_rhs #_ #f lv hs rhs i j acc2 false in S.equal (fst rr1) (fst rr2) /\ snd rr1 == snd rr2)) (decreases j)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "MerkleTree.Spec.fst.checked", "MerkleTree.New.High.Correct.Base.fst.checked", "MerkleTree.New.High.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "MerkleTree.New.High.Correct.Rhs.fst" }
[ { "abbrev": false, "full_module": "MerkleTree.New.High.Correct.Base", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree.New.High", "short_module": null }, { "abbrev": true, "full_module": "MerkleTree.Spec", "short_module": "MTS" }, { "abbrev": true, "full_module": "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
lv: Prims.nat{lv <= 32} -> hs: MerkleTree.New.High.hashess{FStar.Seq.Base.length hs = 32} -> rhs: MerkleTree.New.High.hashes{FStar.Seq.Base.length rhs = 32} -> i: Prims.nat -> j: Prims.nat{i <= j /\ j < Prims.pow2 (32 - lv) /\ MerkleTree.New.High.hs_wf_elts lv hs i j} -> acc1: MerkleTree.New.High.hash -> acc2: MerkleTree.New.High.hash -> FStar.Pervasives.Lemma (requires j > 0) (ensures (let rr1 = MerkleTree.New.High.construct_rhs lv hs rhs i j acc1 false in let rr2 = MerkleTree.New.High.construct_rhs lv hs rhs i j acc2 false in FStar.Seq.Base.equal (FStar.Pervasives.Native.fst rr1) (FStar.Pervasives.Native.fst rr2) /\ FStar.Pervasives.Native.snd rr1 == FStar.Pervasives.Native.snd rr2)) (decreases j)
FStar.Pervasives.Lemma
[ "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", "MerkleTree.New.High.hash", "Prims.l_and", "Prims.op_LessThan", "Prims.pow2", "Prims.op_Subtraction", "MerkleTree.New.High.hs_wf_elts", "Prims.op_Modulus", "MerkleTree.New.High.Correct.Rhs.construct_rhs_init_ignored", "Prims.op_Addition", "Prims.op_Division", "Prims.bool", "Prims.unit" ]
[ "recursion" ]
false
false
true
false
false
let rec construct_rhs_init_ignored #hsz #f lv hs rhs i j acc1 acc2 =
if j % 2 = 0 then construct_rhs_init_ignored #_ #f (lv + 1) hs rhs (i / 2) (j / 2) acc1 acc2
false
MerkleTree.New.High.Correct.Rhs.fst
MerkleTree.New.High.Correct.Rhs.rhs_equiv_inv_preserved
val rhs_equiv_inv_preserved: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> j:nat -> smt:MTS.merkle_tree (log2c j) -> rhs1:hashes #hsz {S.length rhs1 = log2c j} -> rhs2:hashes #hsz {S.length rhs2 = log2c j} -> actd:bool -> Lemma (requires (mt_rhs_inv #_ #f j smt rhs1 actd /\ rhs_equiv #hsz j rhs1 rhs2 actd)) (ensures (mt_rhs_inv #_ #f j smt rhs2 actd)) (decreases j)
val rhs_equiv_inv_preserved: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> j:nat -> smt:MTS.merkle_tree (log2c j) -> rhs1:hashes #hsz {S.length rhs1 = log2c j} -> rhs2:hashes #hsz {S.length rhs2 = log2c j} -> actd:bool -> Lemma (requires (mt_rhs_inv #_ #f j smt rhs1 actd /\ rhs_equiv #hsz j rhs1 rhs2 actd)) (ensures (mt_rhs_inv #_ #f j smt rhs2 actd)) (decreases j)
let rec rhs_equiv_inv_preserved #_ #f j smt rhs1 rhs2 actd = if j = 0 then () else if j % 2 = 0 then rhs_equiv_inv_preserved #_ #f (j / 2) (MTS.mt_next_lv #_ #f #(log2c j) smt) (S.tail rhs1) (S.tail rhs2) actd else begin (if actd then (assert (S.index smt j == MTS.HRaw (S.head rhs1)); assert (S.head rhs1 == S.head rhs2)) else ()); rhs_equiv_inv_preserved #_ #f (j / 2) (MTS.mt_next_lv #_ #f #(log2c j) smt) (S.tail rhs1) (S.tail rhs2) true end
{ "file_name": "src/MerkleTree.New.High.Correct.Rhs.fst", "git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6", "git_url": "https://github.com/hacl-star/merkle-tree.git", "project_name": "merkle-tree" }
{ "end_col": 5, "end_line": 209, "start_col": 0, "start_line": 197 }
module MerkleTree.New.High.Correct.Rhs open FStar.Classical open FStar.Ghost open FStar.Seq module S = FStar.Seq module MTS = MerkleTree.Spec open MerkleTree.New.High open MerkleTree.New.High.Correct.Base #set-options "--z3rlimit 10 --initial_fuel 1 --max_fuel 1 --initial_ifuel 0 --max_ifuel 0" /// Correctness of rightmost hashes // Another version of `construct_rhs` that recursively // accumulates rightmost hashes. val construct_rhs_acc: #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} -> acc:hash #hsz -> actd:bool -> GTot (rhs:hashes #hsz {S.length rhs = log2c j} * hash #hsz) (decreases j) let rec construct_rhs_acc #_ #f j fhs acc actd = if j = 0 then (S.empty, acc) else begin if j % 2 = 0 then (let nrhsh = construct_rhs_acc #_ #f(j / 2) (S.tail fhs) acc actd in (S.cons hash_init (fst nrhsh), snd nrhsh)) else (let rhd = if actd then acc else hash_init in let nacc = if actd then f (S.last (S.head fhs)) acc else S.last (S.head fhs) in let nrhsh = construct_rhs_acc #_ #f (j / 2) (S.tail fhs) nacc true in (S.cons rhd (fst nrhsh), snd nrhsh)) end #push-options "--initial_ifuel 1 --max_ifuel 1" val construct_rhs_acc_odd: #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} -> acc:hash #hsz -> actd:bool -> Lemma (requires (j % 2 <> 0)) (ensures (let rrf = construct_rhs_acc #_ #f j fhs acc actd in let nacc = if actd then f (S.last (S.head fhs)) acc else S.last (S.head fhs) in let nrrf = construct_rhs_acc #_ #f (j / 2) (S.tail fhs) nacc true in S.equal (S.tail (fst rrf)) (fst nrrf) /\ snd rrf == snd nrrf)) let construct_rhs_acc_odd #_ #f j fhs acc actd = () #pop-options #push-options "--initial_fuel 2 --max_fuel 2" val construct_rhs_acc_inv_ok_0: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> fhs:hashess #hsz { S.length fhs = 1 /\ mt_hashes_lth_inv_log #hsz 1 fhs /\ mt_hashes_inv_log #_ #f 1 fhs} -> acc:hash #hsz -> actd:bool -> Lemma (requires True) (ensures (let crhs = construct_rhs_acc #_ #f 1 fhs acc actd in mt_rhs_inv #_ #f 1 (hash_seq_spec_full #_ #f (S.head fhs) acc actd) (fst crhs) actd /\ MTS.mt_get_root #_ #f #1 (hash_seq_spec_full #_ #f (S.head fhs) acc actd) == MTS.HRaw #hsz (snd crhs))) let construct_rhs_acc_inv_ok_0 #_ #f fhs acc actd = () #pop-options #push-options "--z3rlimit 300" #restart-solver val construct_rhs_acc_inv_ok: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> j:nat{j > 0} -> fhs:hashess #hsz { S.length fhs = log2c j /\ mt_hashes_lth_inv_log #hsz j fhs /\ mt_hashes_inv_log #_ #f j fhs} -> acc:hash #hsz -> actd:bool -> Lemma (requires True) (ensures (let crhs = construct_rhs_acc #_ #f j fhs acc actd in mt_rhs_inv #_ #f j (hash_seq_spec_full #_ #f (S.head fhs) acc actd) (fst crhs) actd /\ MTS.mt_get_root #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.head fhs) acc actd) == MTS.HRaw (snd crhs))) (decreases j) let rec construct_rhs_acc_inv_ok #hsz #f j fhs acc actd = if j = 1 then construct_rhs_acc_inv_ok_0 #_ #f fhs acc actd else if j % 2 = 0 then begin construct_rhs_acc_inv_ok #_ #f (j / 2) (S.tail fhs) acc actd; let rcrhs = construct_rhs_acc #_ #f (j / 2) (S.tail fhs) acc actd in assert (mt_rhs_inv #_ #f (j / 2) (hash_seq_spec_full #_ #f (S.head (S.tail fhs)) acc actd) (fst rcrhs) actd); assert (MTS.mt_get_root #_ #f #(log2c j - 1) (hash_seq_spec_full #_ #f (S.head (S.tail fhs)) acc actd) == MTS.HRaw (snd rcrhs)); let crhs = (S.cons hash_init (fst rcrhs), snd rcrhs) in mt_hashes_lth_inv_log_next #_ #f j fhs; hash_seq_spec_full_even_next #_ #f j (S.head fhs) (S.head (S.tail fhs)) acc actd; assert (mt_rhs_inv #_ #f (j / 2) (MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.head fhs) acc actd)) (fst rcrhs) actd); assert (mt_rhs_inv #_ #f j (hash_seq_spec_full #_ #f (S.head fhs) acc actd) (fst crhs) actd); assert (MTS.mt_get_root #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.head fhs) acc actd) == MTS.HRaw (snd rcrhs)) end else begin let rhd = if actd then acc else hash_init #hsz in let nacc = if actd then f (S.last (S.head fhs)) acc else S.last (S.head fhs) in construct_rhs_acc_inv_ok #_ #f (j / 2) (S.tail fhs) nacc true; let rcrhs = construct_rhs_acc #_ #f (j / 2) (S.tail fhs) nacc true in assert (mt_rhs_inv #_ #f (j / 2) (hash_seq_spec_full #_ #f (S.head (S.tail fhs)) nacc true) (fst rcrhs) true); assert (MTS.mt_get_root #_ #f #(log2c j - 1) (hash_seq_spec_full #_ #f (S.head (S.tail fhs)) nacc true) == MTS.HRaw (snd rcrhs)); let crhs = (S.cons rhd (fst rcrhs), snd rcrhs) in mt_hashes_lth_inv_log_next #_ #f j fhs; hash_seq_spec_full_odd_next #_ #f j (S.head fhs) (S.head (S.tail fhs)) acc actd nacc; (if actd then hash_seq_spec_full_case_true #_ #f (S.head fhs) acc); assert (if actd then (S.index (hash_seq_spec_full #_ #f (S.head fhs) acc actd) j == MTS.HRaw rhd) else true); assert (mt_rhs_inv #_ #f (j / 2) (MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.head fhs) acc actd)) (fst rcrhs) true); assert (mt_rhs_inv #_ #f j (hash_seq_spec_full #_ #f (S.head fhs) acc actd) (fst crhs) actd); assert (MTS.mt_get_root #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.head fhs) acc actd) == MTS.HRaw (snd crhs)) end #pop-options val rhs_equiv: #hsz:pos -> j:nat -> rhs1:hashes #hsz {S.length rhs1 = log2c j} -> rhs2:hashes #hsz {S.length rhs2 = log2c j} -> actd:bool -> GTot Type0 (decreases j) let rec rhs_equiv #hsz j rhs1 rhs2 actd = if j = 0 then true else if j % 2 = 0 then rhs_equiv #hsz (j / 2) (S.tail rhs1) (S.tail rhs2) actd else ((if actd then S.head rhs1 == S.head rhs2 else true) /\ rhs_equiv #hsz (j / 2) (S.tail rhs1) (S.tail rhs2) true) val rhs_equiv_inv_preserved: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> j:nat -> smt:MTS.merkle_tree (log2c j) -> rhs1:hashes #hsz {S.length rhs1 = log2c j} -> rhs2:hashes #hsz {S.length rhs2 = log2c j} -> actd:bool -> Lemma (requires (mt_rhs_inv #_ #f j smt rhs1 actd /\ rhs_equiv #hsz j rhs1 rhs2 actd)) (ensures (mt_rhs_inv #_ #f j smt rhs2 actd))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "MerkleTree.Spec.fst.checked", "MerkleTree.New.High.Correct.Base.fst.checked", "MerkleTree.New.High.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "MerkleTree.New.High.Correct.Rhs.fst" }
[ { "abbrev": false, "full_module": "MerkleTree.New.High.Correct.Base", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree.New.High", "short_module": null }, { "abbrev": true, "full_module": "MerkleTree.Spec", "short_module": "MTS" }, { "abbrev": true, "full_module": "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
j: Prims.nat -> smt: MerkleTree.Spec.merkle_tree (MerkleTree.New.High.Correct.Base.log2c j) -> rhs1: MerkleTree.New.High.hashes {FStar.Seq.Base.length rhs1 = MerkleTree.New.High.Correct.Base.log2c j} -> rhs2: MerkleTree.New.High.hashes {FStar.Seq.Base.length rhs2 = MerkleTree.New.High.Correct.Base.log2c j} -> actd: Prims.bool -> FStar.Pervasives.Lemma (requires MerkleTree.New.High.Correct.Base.mt_rhs_inv j smt rhs1 actd /\ MerkleTree.New.High.Correct.Rhs.rhs_equiv j rhs1 rhs2 actd) (ensures MerkleTree.New.High.Correct.Base.mt_rhs_inv j smt rhs2 actd) (decreases j)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "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.op_Modulus", "MerkleTree.New.High.Correct.Rhs.rhs_equiv_inv_preserved", "Prims.op_Division", "MerkleTree.Spec.mt_next_lv", "FStar.Seq.Properties.tail", "Prims.unit", "Prims._assert", "Prims.eq2", "FStar.Seq.Properties.head", "MerkleTree.Spec.padded_hash", "FStar.Seq.Base.index", "MerkleTree.Spec.HRaw" ]
[ "recursion" ]
false
false
true
false
false
let rec rhs_equiv_inv_preserved #_ #f j smt rhs1 rhs2 actd =
if j = 0 then () else if j % 2 = 0 then rhs_equiv_inv_preserved #_ #f (j / 2) (MTS.mt_next_lv #_ #f #(log2c j) smt) (S.tail rhs1) (S.tail rhs2) actd else ((if actd then (assert (S.index smt j == MTS.HRaw (S.head rhs1)); assert (S.head rhs1 == S.head rhs2))); rhs_equiv_inv_preserved #_ #f (j / 2) (MTS.mt_next_lv #_ #f #(log2c j) smt) (S.tail rhs1) (S.tail rhs2) true)
false
MerkleTree.New.High.Correct.Rhs.fst
MerkleTree.New.High.Correct.Rhs.mt_get_root_inv_ok
val mt_get_root_inv_ok: #hsz:pos -> mt:merkle_tree #hsz {mt_wf_elts mt} -> drt:hash -> olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz 0 (MT?.i mt) olds} -> Lemma (requires (mt_inv mt olds)) (ensures (let nmt, rt = mt_get_root mt drt in // Only `MT?.rhs` and `MT?.mroot` are changed. MT?.i mt == MT?.i nmt /\ MT?.j mt == MT?.j nmt /\ MT?.hs mt == MT?.hs nmt /\ // A Merkle tree with new `MT?.rhs` and `MT?.mroot` is valid. mt_inv nmt olds /\ // A returned root is indeed the Merkle root. rt == MT?.mroot nmt))
val mt_get_root_inv_ok: #hsz:pos -> mt:merkle_tree #hsz {mt_wf_elts mt} -> drt:hash -> olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz 0 (MT?.i mt) olds} -> Lemma (requires (mt_inv mt olds)) (ensures (let nmt, rt = mt_get_root mt drt in // Only `MT?.rhs` and `MT?.mroot` are changed. MT?.i mt == MT?.i nmt /\ MT?.j mt == MT?.j nmt /\ MT?.hs mt == MT?.hs nmt /\ // A Merkle tree with new `MT?.rhs` and `MT?.mroot` is valid. mt_inv nmt olds /\ // A returned root is indeed the Merkle root. rt == MT?.mroot nmt))
let mt_get_root_inv_ok #hsz mt drt olds = if MT?.rhs_ok mt then () else if MT?.j mt = 0 then () else begin construct_rhs_base_inv_ok #_ #(MT?.hash_fun mt) (MT?.i mt) (MT?.j mt) olds (MT?.hs mt) (MT?.rhs mt) hash_init false; construct_rhs_init_ignored #_ #(MT?.hash_fun mt) 0 (MT?.hs mt) (MT?.rhs mt) (MT?.i mt) (MT?.j mt) hash_init drt end
{ "file_name": "src/MerkleTree.New.High.Correct.Rhs.fst", "git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6", "git_url": "https://github.com/hacl-star/merkle-tree.git", "project_name": "merkle-tree" }
{ "end_col": 5, "end_line": 422, "start_col": 0, "start_line": 412 }
module MerkleTree.New.High.Correct.Rhs open FStar.Classical open FStar.Ghost open FStar.Seq module S = FStar.Seq module MTS = MerkleTree.Spec open MerkleTree.New.High open MerkleTree.New.High.Correct.Base #set-options "--z3rlimit 10 --initial_fuel 1 --max_fuel 1 --initial_ifuel 0 --max_ifuel 0" /// Correctness of rightmost hashes // Another version of `construct_rhs` that recursively // accumulates rightmost hashes. val construct_rhs_acc: #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} -> acc:hash #hsz -> actd:bool -> GTot (rhs:hashes #hsz {S.length rhs = log2c j} * hash #hsz) (decreases j) let rec construct_rhs_acc #_ #f j fhs acc actd = if j = 0 then (S.empty, acc) else begin if j % 2 = 0 then (let nrhsh = construct_rhs_acc #_ #f(j / 2) (S.tail fhs) acc actd in (S.cons hash_init (fst nrhsh), snd nrhsh)) else (let rhd = if actd then acc else hash_init in let nacc = if actd then f (S.last (S.head fhs)) acc else S.last (S.head fhs) in let nrhsh = construct_rhs_acc #_ #f (j / 2) (S.tail fhs) nacc true in (S.cons rhd (fst nrhsh), snd nrhsh)) end #push-options "--initial_ifuel 1 --max_ifuel 1" val construct_rhs_acc_odd: #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} -> acc:hash #hsz -> actd:bool -> Lemma (requires (j % 2 <> 0)) (ensures (let rrf = construct_rhs_acc #_ #f j fhs acc actd in let nacc = if actd then f (S.last (S.head fhs)) acc else S.last (S.head fhs) in let nrrf = construct_rhs_acc #_ #f (j / 2) (S.tail fhs) nacc true in S.equal (S.tail (fst rrf)) (fst nrrf) /\ snd rrf == snd nrrf)) let construct_rhs_acc_odd #_ #f j fhs acc actd = () #pop-options #push-options "--initial_fuel 2 --max_fuel 2" val construct_rhs_acc_inv_ok_0: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> fhs:hashess #hsz { S.length fhs = 1 /\ mt_hashes_lth_inv_log #hsz 1 fhs /\ mt_hashes_inv_log #_ #f 1 fhs} -> acc:hash #hsz -> actd:bool -> Lemma (requires True) (ensures (let crhs = construct_rhs_acc #_ #f 1 fhs acc actd in mt_rhs_inv #_ #f 1 (hash_seq_spec_full #_ #f (S.head fhs) acc actd) (fst crhs) actd /\ MTS.mt_get_root #_ #f #1 (hash_seq_spec_full #_ #f (S.head fhs) acc actd) == MTS.HRaw #hsz (snd crhs))) let construct_rhs_acc_inv_ok_0 #_ #f fhs acc actd = () #pop-options #push-options "--z3rlimit 300" #restart-solver val construct_rhs_acc_inv_ok: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> j:nat{j > 0} -> fhs:hashess #hsz { S.length fhs = log2c j /\ mt_hashes_lth_inv_log #hsz j fhs /\ mt_hashes_inv_log #_ #f j fhs} -> acc:hash #hsz -> actd:bool -> Lemma (requires True) (ensures (let crhs = construct_rhs_acc #_ #f j fhs acc actd in mt_rhs_inv #_ #f j (hash_seq_spec_full #_ #f (S.head fhs) acc actd) (fst crhs) actd /\ MTS.mt_get_root #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.head fhs) acc actd) == MTS.HRaw (snd crhs))) (decreases j) let rec construct_rhs_acc_inv_ok #hsz #f j fhs acc actd = if j = 1 then construct_rhs_acc_inv_ok_0 #_ #f fhs acc actd else if j % 2 = 0 then begin construct_rhs_acc_inv_ok #_ #f (j / 2) (S.tail fhs) acc actd; let rcrhs = construct_rhs_acc #_ #f (j / 2) (S.tail fhs) acc actd in assert (mt_rhs_inv #_ #f (j / 2) (hash_seq_spec_full #_ #f (S.head (S.tail fhs)) acc actd) (fst rcrhs) actd); assert (MTS.mt_get_root #_ #f #(log2c j - 1) (hash_seq_spec_full #_ #f (S.head (S.tail fhs)) acc actd) == MTS.HRaw (snd rcrhs)); let crhs = (S.cons hash_init (fst rcrhs), snd rcrhs) in mt_hashes_lth_inv_log_next #_ #f j fhs; hash_seq_spec_full_even_next #_ #f j (S.head fhs) (S.head (S.tail fhs)) acc actd; assert (mt_rhs_inv #_ #f (j / 2) (MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.head fhs) acc actd)) (fst rcrhs) actd); assert (mt_rhs_inv #_ #f j (hash_seq_spec_full #_ #f (S.head fhs) acc actd) (fst crhs) actd); assert (MTS.mt_get_root #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.head fhs) acc actd) == MTS.HRaw (snd rcrhs)) end else begin let rhd = if actd then acc else hash_init #hsz in let nacc = if actd then f (S.last (S.head fhs)) acc else S.last (S.head fhs) in construct_rhs_acc_inv_ok #_ #f (j / 2) (S.tail fhs) nacc true; let rcrhs = construct_rhs_acc #_ #f (j / 2) (S.tail fhs) nacc true in assert (mt_rhs_inv #_ #f (j / 2) (hash_seq_spec_full #_ #f (S.head (S.tail fhs)) nacc true) (fst rcrhs) true); assert (MTS.mt_get_root #_ #f #(log2c j - 1) (hash_seq_spec_full #_ #f (S.head (S.tail fhs)) nacc true) == MTS.HRaw (snd rcrhs)); let crhs = (S.cons rhd (fst rcrhs), snd rcrhs) in mt_hashes_lth_inv_log_next #_ #f j fhs; hash_seq_spec_full_odd_next #_ #f j (S.head fhs) (S.head (S.tail fhs)) acc actd nacc; (if actd then hash_seq_spec_full_case_true #_ #f (S.head fhs) acc); assert (if actd then (S.index (hash_seq_spec_full #_ #f (S.head fhs) acc actd) j == MTS.HRaw rhd) else true); assert (mt_rhs_inv #_ #f (j / 2) (MTS.mt_next_lv #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.head fhs) acc actd)) (fst rcrhs) true); assert (mt_rhs_inv #_ #f j (hash_seq_spec_full #_ #f (S.head fhs) acc actd) (fst crhs) actd); assert (MTS.mt_get_root #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.head fhs) acc actd) == MTS.HRaw (snd crhs)) end #pop-options val rhs_equiv: #hsz:pos -> j:nat -> rhs1:hashes #hsz {S.length rhs1 = log2c j} -> rhs2:hashes #hsz {S.length rhs2 = log2c j} -> actd:bool -> GTot Type0 (decreases j) let rec rhs_equiv #hsz j rhs1 rhs2 actd = if j = 0 then true else if j % 2 = 0 then rhs_equiv #hsz (j / 2) (S.tail rhs1) (S.tail rhs2) actd else ((if actd then S.head rhs1 == S.head rhs2 else true) /\ rhs_equiv #hsz (j / 2) (S.tail rhs1) (S.tail rhs2) true) val rhs_equiv_inv_preserved: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> j:nat -> smt:MTS.merkle_tree (log2c j) -> rhs1:hashes #hsz {S.length rhs1 = log2c j} -> rhs2:hashes #hsz {S.length rhs2 = log2c j} -> actd:bool -> Lemma (requires (mt_rhs_inv #_ #f j smt rhs1 actd /\ rhs_equiv #hsz j rhs1 rhs2 actd)) (ensures (mt_rhs_inv #_ #f j smt rhs2 actd)) (decreases j) let rec rhs_equiv_inv_preserved #_ #f j smt rhs1 rhs2 actd = if j = 0 then () else if j % 2 = 0 then rhs_equiv_inv_preserved #_ #f (j / 2) (MTS.mt_next_lv #_ #f #(log2c j) smt) (S.tail rhs1) (S.tail rhs2) actd else begin (if actd then (assert (S.index smt j == MTS.HRaw (S.head rhs1)); assert (S.head rhs1 == S.head rhs2)) else ()); rhs_equiv_inv_preserved #_ #f (j / 2) (MTS.mt_next_lv #_ #f #(log2c j) smt) (S.tail rhs1) (S.tail rhs2) true end val construct_rhs_acc_consistent: #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 lv hs i j} -> rhs:hashes #hsz {S.length rhs = 32} -> acc:hash #hsz -> actd:bool -> Lemma (requires True) (ensures (log2c_bound j (32 - lv); mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs; mt_hashes_lth_inv_log_converted_ #_ #f lv j (merge_hs #_ #f olds hs); (let rrf = construct_rhs_acc #_ #f j (S.slice (merge_hs #_ #f olds hs) lv (lv + log2c j)) acc actd in let rr = construct_rhs #_ #f lv hs rhs i j acc actd in rhs_equiv #hsz j (fst rrf) (S.slice (fst rr) lv (lv + log2c j)) actd /\ snd rrf == snd rr))) (decreases j) #push-options "--z3rlimit 300 --ifuel 1" #push-options "--retry 3" let rec construct_rhs_acc_consistent #hsz #f lv i j olds hs rhs acc actd = assert (j < pow2 (32 - lv)); assert (j <> 0 ==> j / 2 < pow2 (32 - (lv + 1))); log2c_bound j (32 - lv); mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs; mt_hashes_lth_inv_log_converted_ #_ #f lv j (merge_hs #_ #f olds hs); let rrf = construct_rhs_acc #_ #f j (S.slice (merge_hs #_ #f olds hs) lv (lv + log2c j)) acc actd in let rr = construct_rhs #_ #f lv hs rhs i j acc actd in construct_rhs_unchanged #_ #f lv hs rhs i j acc actd; assert (S.equal (S.slice rhs 0 lv) (S.slice (fst rr) 0 lv)); if j = 0 then () else begin log2c_div j; assert (32 - (lv + 1) >= 0); log2c_bound (j / 2) (32 - (lv + 1)); mt_olds_hs_lth_inv_ok #_ #f (lv + 1) (i / 2) (j / 2) olds hs; mt_hashes_lth_inv_log_converted_ #_ #f (lv + 1) (j / 2) (merge_hs #_ #f olds hs); if j % 2 = 0 then begin construct_rhs_acc_consistent #_ #f (lv + 1) (i / 2) (j / 2) olds hs rhs acc actd; log2c_bound (j/2) (32 - (lv + 1)); mt_olds_hs_lth_inv_ok #hsz #f (lv+1) (i/2) (j/2) olds hs; mt_hashes_lth_inv_log_converted_ #_ #f lv j (merge_hs #_ #f olds hs); let rrf = construct_rhs_acc #_ #f j (S.slice (merge_hs #_ #f olds hs) lv (lv + log2c j)) acc actd in let rr = construct_rhs #_ #f lv hs rhs i j acc actd in assert (rhs_equiv #hsz j (fst rrf) (S.slice (fst rr) lv (lv + log2c j)) actd); assert (snd rrf == snd rr) end else begin let rhd = if actd then acc else hash_init in let nacc = if actd then f (S.last (S.index hs lv)) acc else S.last (S.index hs lv) in assert (S.equal (S.tail (S.slice (merge_hs #_ #f olds hs) lv (lv + log2c j))) (S.slice (merge_hs #_ #f olds hs) (lv + 1) (lv + 1 + log2c (j / 2)))); // Recursion step for `construct_rhs_acc` let nrrf = construct_rhs_acc #_ #f (j / 2) (S.slice (merge_hs #_ #f olds hs) (lv + 1) (lv + 1 + (log2c (j / 2)))) nacc true in construct_rhs_acc_odd #_ #f j (S.slice (merge_hs #_ #f olds hs) lv (lv + log2c j)) acc actd; // Recursion step for `construct_rhs` assert (hs_wf_elts (lv + 1) hs (i / 2) (j / 2)); let nrhs = if actd then S.upd rhs lv acc else rhs in let nrr = construct_rhs #_ #f (lv + 1) hs nrhs (i / 2) (j / 2) nacc true in construct_rhs_odd #_ #f lv hs rhs i j acc actd; construct_rhs_unchanged #_ #f (lv + 1) hs nrhs (i / 2) (j / 2) nacc true; assert (S.equal (S.slice nrhs 0 (lv + 1)) (S.slice (fst nrr) 0 (lv + 1))); assert (S.index (fst nrr) lv == S.index nrhs lv); // Recursion for the proof construct_rhs_acc_consistent #_ #f (lv + 1) (i / 2) (j / 2) olds hs nrhs nacc true; assert (rhs_equiv #hsz (j / 2) (fst nrrf) (S.slice (fst nrr) (lv + 1) (lv + 1 + log2c (j / 2))) true); assert (snd nrrf == snd nrr); // All together (if actd then (assert (S.head (fst rrf) == rhd); assert (rhd == acc); assert (S.index (fst rr) lv == S.index nrhs lv); assert (S.index nrhs lv == acc); assert (S.head (fst rrf) == S.index (fst rr) lv)) else ()); assert (if actd then S.head (fst rrf) == S.index (fst rr) lv else true); assert (rhs_equiv #hsz (j / 2) (S.tail (fst rrf)) (S.slice (fst rr) (lv + 1) (lv + 1 + log2c (j / 2))) true); assert (rhs_equiv #hsz j (fst rrf) (S.slice (fst rr) lv (lv + log2c j)) actd); assert (snd rrf == snd rr) end end #pop-options val construct_rhs_inv_ok: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> lv:nat{lv <= 32} -> i:nat -> j:nat{j > 0 /\ 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 lv hs i j} -> rhs:hashes #hsz {S.length rhs = 32} -> acc:hash #hsz -> actd:bool -> Lemma (requires (mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs; mt_hashes_inv #_ #f lv j (merge_hs #_ #f olds hs))) (ensures (log2c_bound j (32 - lv); mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs; (let crhs = construct_rhs #_ #f lv hs rhs i j acc actd in mt_rhs_inv #_ #f j (hash_seq_spec_full #_ #f (S.index (merge_hs #_ #f olds hs) lv) acc actd) (S.slice (fst crhs) lv (lv + log2c j)) actd /\ MTS.mt_get_root #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.index (merge_hs #_ #f olds hs) lv) acc actd) == MTS.HRaw (snd crhs)))) let construct_rhs_inv_ok #hsz #f lv i j olds hs rhs acc actd = log2c_div j; log2c_bound j (32 - lv); mt_olds_hs_lth_inv_ok #_ #f lv i j olds hs; mt_hashes_lth_inv_log_converted_ #_ #f lv j (merge_hs #_ #f olds hs); mt_hashes_inv_log_converted_ #_ #f lv j (merge_hs #_ #f olds hs); let crhs = construct_rhs #_ #f lv hs rhs i j acc actd in let crhsf = construct_rhs_acc #_ #f j (S.slice (merge_hs #_ #f olds hs) lv (lv + log2c j)) acc actd in construct_rhs_acc_consistent #_ #f lv i j olds hs rhs acc actd; construct_rhs_acc_inv_ok #_ #f j (S.slice (merge_hs #_ #f olds hs) lv (lv + log2c j)) acc actd; rhs_equiv_inv_preserved #_ #f j (hash_seq_spec_full #_ #f (S.index (merge_hs #_ #f olds hs) lv) acc actd) (fst crhsf) (S.slice (fst crhs) lv (lv + log2c j)) actd #pop-options val construct_rhs_base_inv_ok: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> i:nat -> j:nat{j > 0 /\ i <= j /\ j < pow2 32} -> olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz 0 i olds} -> hs:hashess #hsz {S.length hs = 32 /\ hs_wf_elts 0 hs i j} -> rhs:hashes #hsz {S.length rhs = 32} -> acc:hash #hsz -> actd:bool -> Lemma (requires (mt_olds_hs_lth_inv_ok #_ #f 0 i j olds hs; mt_hashes_inv #_ #f 0 j (merge_hs #_ #f olds hs))) (ensures (log2c_bound j 32; mt_olds_hs_lth_inv_ok #_ #f 0 i j olds hs; (let crhs = construct_rhs #_ #f 0 hs rhs i j acc actd in mt_rhs_inv #_ #f j (hash_seq_spec_full #_ #f (S.head (merge_hs #_ #f olds hs)) acc actd) (S.slice (fst crhs) 0 (log2c j)) actd /\ MTS.mt_get_root #_ #f #(log2c j) (hash_seq_spec_full #_ #f (S.head (merge_hs #_ #f olds hs)) acc actd) == MTS.HRaw (snd crhs)))) let construct_rhs_base_inv_ok #hsz #f i j olds hs rhs acc actd = construct_rhs_inv_ok #_ #f 0 i j olds hs rhs acc actd val construct_rhs_init_ignored: #hsz:pos -> #f:MTS.hash_fun_t #hsz -> lv:nat{lv <= 32} -> hs:hashess #hsz {S.length hs = 32} -> rhs:hashes #hsz {S.length rhs = 32} -> i:nat -> j:nat{ i <= j /\ j < pow2 (32 - lv) /\ hs_wf_elts lv hs i j} -> acc1:hash #hsz -> acc2:hash #hsz -> Lemma (requires (j > 0)) (ensures (let rr1 = construct_rhs #_ #f lv hs rhs i j acc1 false in let rr2 = construct_rhs #_ #f lv hs rhs i j acc2 false in S.equal (fst rr1) (fst rr2) /\ snd rr1 == snd rr2)) (decreases j) #push-options "--z3rlimit 100 --initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1" let rec construct_rhs_init_ignored #hsz #f lv hs rhs i j acc1 acc2 = if j % 2 = 0 then construct_rhs_init_ignored #_ #f (lv + 1) hs rhs (i / 2) (j / 2) acc1 acc2 else () #pop-options val mt_get_root_inv_ok: #hsz:pos -> mt:merkle_tree #hsz {mt_wf_elts mt} -> drt:hash -> olds:hashess #hsz {S.length olds = 32 /\ mt_olds_inv #hsz 0 (MT?.i mt) olds} -> Lemma (requires (mt_inv mt olds)) (ensures (let nmt, rt = mt_get_root mt drt in // Only `MT?.rhs` and `MT?.mroot` are changed. MT?.i mt == MT?.i nmt /\ MT?.j mt == MT?.j nmt /\ MT?.hs mt == MT?.hs nmt /\ // A Merkle tree with new `MT?.rhs` and `MT?.mroot` is valid. mt_inv nmt olds /\ // A returned root is indeed the Merkle root.
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "MerkleTree.Spec.fst.checked", "MerkleTree.New.High.Correct.Base.fst.checked", "MerkleTree.New.High.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "MerkleTree.New.High.Correct.Rhs.fst" }
[ { "abbrev": false, "full_module": "MerkleTree.New.High.Correct.Base", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree.New.High", "short_module": null }, { "abbrev": true, "full_module": "MerkleTree.Spec", "short_module": "MTS" }, { "abbrev": true, "full_module": "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
mt: MerkleTree.New.High.merkle_tree{MerkleTree.New.High.mt_wf_elts mt} -> drt: MerkleTree.New.High.hash -> olds: MerkleTree.New.High.hashess { FStar.Seq.Base.length olds = 32 /\ MerkleTree.New.High.Correct.Base.mt_olds_inv 0 (MT?.i mt) olds } -> FStar.Pervasives.Lemma (requires MerkleTree.New.High.Correct.Base.mt_inv mt olds) (ensures (let _ = MerkleTree.New.High.mt_get_root mt drt in (let FStar.Pervasives.Native.Mktuple2 #_ #_ nmt rt = _ in MT?.i mt == MT?.i nmt /\ MT?.j mt == MT?.j nmt /\ MT?.hs mt == MT?.hs nmt /\ MerkleTree.New.High.Correct.Base.mt_inv nmt olds /\ rt == MT?.mroot nmt) <: Type0))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.pos", "MerkleTree.New.High.merkle_tree", "MerkleTree.New.High.mt_wf_elts", "MerkleTree.New.High.hash", "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.__proj__MT__item__rhs_ok", "Prims.bool", "MerkleTree.New.High.__proj__MT__item__j", "MerkleTree.New.High.Correct.Rhs.construct_rhs_init_ignored", "MerkleTree.New.High.__proj__MT__item__hash_fun", "MerkleTree.New.High.__proj__MT__item__hs", "MerkleTree.New.High.__proj__MT__item__rhs", "MerkleTree.New.High.hash_init", "Prims.unit", "MerkleTree.New.High.Correct.Rhs.construct_rhs_base_inv_ok" ]
[]
false
false
true
false
false
let mt_get_root_inv_ok #hsz mt drt olds =
if MT?.rhs_ok mt then () else if MT?.j mt = 0 then () else (construct_rhs_base_inv_ok #_ #(MT?.hash_fun mt) (MT?.i mt) (MT?.j mt) olds (MT?.hs mt) (MT?.rhs mt) hash_init false; construct_rhs_init_ignored #_ #(MT?.hash_fun mt) 0 (MT?.hs mt) (MT?.rhs mt) (MT?.i mt) (MT?.j mt) hash_init drt)
false
Vale.AES.X64.GCMdecryptOpt.fsti
Vale.AES.X64.GCMdecryptOpt.aes_reqs
val aes_reqs (alg: algorithm) (key: seq nat32) (round_keys: seq quad32) (keys_b: buffer128) (key_ptr: int) (heap0: vale_heap) (layout: vale_heap_layout) : prop0
val aes_reqs (alg: algorithm) (key: seq nat32) (round_keys: seq quad32) (keys_b: buffer128) (key_ptr: int) (heap0: vale_heap) (layout: vale_heap_layout) : prop0
let aes_reqs (alg:algorithm) (key:seq nat32) (round_keys:seq quad32) (keys_b:buffer128) (key_ptr:int) (heap0:vale_heap) (layout:vale_heap_layout) : prop0 = aesni_enabled /\ avx_enabled /\ (alg = AES_128 \/ alg = AES_256) /\ is_aes_key_LE alg key /\ length(round_keys) == nr(alg) + 1 /\ round_keys == key_to_round_keys_LE alg key /\ validSrcAddrs128 heap0 key_ptr keys_b (nr alg + 1) layout Secret /\ s128 heap0 keys_b == round_keys
{ "file_name": "obj/Vale.AES.X64.GCMdecryptOpt.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 33, "end_line": 56, "start_col": 0, "start_line": 46 }
module Vale.AES.X64.GCMdecryptOpt open Vale.Def.Prop_s open Vale.Def.Opaque_s open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.Arch.HeapImpl open Vale.AES.AES_s open Vale.AES.GCTR_s open Vale.AES.GCTR open Vale.AES.GCM open Vale.AES.GHash_s open Vale.AES.GHash open Vale.AES.GCM_s open Vale.AES.X64.AES open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.Poly1305.Math open Vale.AES.GCM_helpers open Vale.AES.X64.GHash open Vale.AES.X64.GCTR open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsStack open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.AES.X64.GF128_Mul open Vale.X64.Stack open Vale.X64.CPU_Features_s open Vale.Math.Poly2.Bits_s open Vale.AES.X64.AESopt open Vale.AES.X64.AESGCM open Vale.AES.X64.AESopt2 open Vale.Lib.Meta open Vale.AES.X64.GCMencryptOpt
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_i.fsti.checked", "Vale.X64.Stack.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsStack.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Poly1305.Math.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Lib.Meta.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.AES.X64.GHash.fsti.checked", "Vale.AES.X64.GF128_Mul.fsti.checked", "Vale.AES.X64.GCTR.fsti.checked", "Vale.AES.X64.GCMencryptOpt.fsti.checked", "Vale.AES.X64.AESopt2.fsti.checked", "Vale.AES.X64.AESopt.fsti.checked", "Vale.AES.X64.AESGCM.fsti.checked", "Vale.AES.X64.AES.fsti.checked", "Vale.AES.OptPublic.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCTR.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.GCM.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.AES.X64.GCMdecryptOpt.fsti" }
[ { "abbrev": false, "full_module": "Vale.AES.OptPublic", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCMencryptOpt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt2", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESGCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 -> round_keys: FStar.Seq.Base.seq Vale.X64.Decls.quad32 -> keys_b: Vale.X64.Memory.buffer128 -> key_ptr: Prims.int -> heap0: Vale.X64.InsBasic.vale_heap -> layout: Vale.Arch.HeapImpl.vale_heap_layout -> Vale.Def.Prop_s.prop0
Prims.Tot
[ "total" ]
[]
[ "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.X64.Memory.nat32", "Vale.X64.Decls.quad32", "Vale.X64.Memory.buffer128", "Prims.int", "Vale.X64.InsBasic.vale_heap", "Vale.Arch.HeapImpl.vale_heap_layout", "Prims.l_and", "Prims.b2t", "Vale.X64.CPU_Features_s.aesni_enabled", "Vale.X64.CPU_Features_s.avx_enabled", "Prims.l_or", "Prims.op_Equality", "Vale.AES.AES_common_s.AES_128", "Vale.AES.AES_common_s.AES_256", "Vale.AES.AES_s.is_aes_key_LE", "Prims.eq2", "FStar.Seq.Base.length", "Prims.op_Addition", "Vale.AES.AES_common_s.nr", "Vale.Def.Types_s.quad32", "Vale.AES.AES_s.key_to_round_keys_LE", "Vale.X64.Decls.validSrcAddrs128", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.Decls.s128", "Vale.Def.Prop_s.prop0" ]
[]
false
false
false
true
false
let aes_reqs (alg: algorithm) (key: seq nat32) (round_keys: seq quad32) (keys_b: buffer128) (key_ptr: int) (heap0: vale_heap) (layout: vale_heap_layout) : prop0 =
aesni_enabled /\ avx_enabled /\ (alg = AES_128 \/ alg = AES_256) /\ is_aes_key_LE alg key /\ length (round_keys) == nr (alg) + 1 /\ round_keys == key_to_round_keys_LE alg key /\ validSrcAddrs128 heap0 key_ptr keys_b (nr alg + 1) layout Secret /\ s128 heap0 keys_b == round_keys
false
MerkleTree.New.High.Correct.Rhs.fst
MerkleTree.New.High.Correct.Rhs.construct_rhs_acc
val construct_rhs_acc: #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} -> acc:hash #hsz -> actd:bool -> GTot (rhs:hashes #hsz {S.length rhs = log2c j} * hash #hsz) (decreases j)
val construct_rhs_acc: #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} -> acc:hash #hsz -> actd:bool -> GTot (rhs:hashes #hsz {S.length rhs = log2c j} * hash #hsz) (decreases j)
let rec construct_rhs_acc #_ #f j fhs acc actd = if j = 0 then (S.empty, acc) else begin if j % 2 = 0 then (let nrhsh = construct_rhs_acc #_ #f(j / 2) (S.tail fhs) acc actd in (S.cons hash_init (fst nrhsh), snd nrhsh)) else (let rhd = if actd then acc else hash_init in let nacc = if actd then f (S.last (S.head fhs)) acc else S.last (S.head fhs) in let nrhsh = construct_rhs_acc #_ #f (j / 2) (S.tail fhs) nacc true in (S.cons rhd (fst nrhsh), snd nrhsh)) end
{ "file_name": "src/MerkleTree.New.High.Correct.Rhs.fst", "git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6", "git_url": "https://github.com/hacl-star/merkle-tree.git", "project_name": "merkle-tree" }
{ "end_col": 5, "end_line": 41, "start_col": 0, "start_line": 29 }
module MerkleTree.New.High.Correct.Rhs open FStar.Classical open FStar.Ghost open FStar.Seq module S = FStar.Seq module MTS = MerkleTree.Spec open MerkleTree.New.High open MerkleTree.New.High.Correct.Base #set-options "--z3rlimit 10 --initial_fuel 1 --max_fuel 1 --initial_ifuel 0 --max_ifuel 0" /// Correctness of rightmost hashes // Another version of `construct_rhs` that recursively // accumulates rightmost hashes. val construct_rhs_acc: #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} -> acc:hash #hsz -> actd:bool ->
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "MerkleTree.Spec.fst.checked", "MerkleTree.New.High.Correct.Base.fst.checked", "MerkleTree.New.High.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "MerkleTree.New.High.Correct.Rhs.fst" }
[ { "abbrev": false, "full_module": "MerkleTree.New.High.Correct.Base", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree.New.High", "short_module": null }, { "abbrev": true, "full_module": "MerkleTree.Spec", "short_module": "MTS" }, { "abbrev": true, "full_module": "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 } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
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 } -> acc: MerkleTree.New.High.hash -> actd: Prims.bool -> Prims.GTot (rhs: MerkleTree.New.High.hashes {FStar.Seq.Base.length rhs = MerkleTree.New.High.Correct.Base.log2c j} * MerkleTree.New.High.hash)
Prims.GTot
[ "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", "MerkleTree.New.High.hash", "Prims.bool", "Prims.int", "FStar.Pervasives.Native.Mktuple2", "FStar.Seq.Base.empty", "Prims.op_Modulus", "FStar.Seq.Base.cons", "MerkleTree.New.High.hash_init", "FStar.Pervasives.Native.fst", "Prims.op_Division", "FStar.Pervasives.Native.snd", "FStar.Pervasives.Native.tuple2", "MerkleTree.New.High.Correct.Rhs.construct_rhs_acc", "FStar.Seq.Properties.tail", "FStar.Seq.Properties.last", "FStar.Seq.Properties.head" ]
[ "recursion" ]
false
false
false
false
false
let rec construct_rhs_acc #_ #f j fhs acc actd =
if j = 0 then (S.empty, acc) else if j % 2 = 0 then (let nrhsh = construct_rhs_acc #_ #f (j / 2) (S.tail fhs) acc actd in (S.cons hash_init (fst nrhsh), snd nrhsh)) else (let rhd = if actd then acc else hash_init in let nacc = if actd then f (S.last (S.head fhs)) acc else S.last (S.head fhs) in let nrhsh = construct_rhs_acc #_ #f (j / 2) (S.tail fhs) nacc true in (S.cons rhd (fst nrhsh), snd nrhsh))
false
Lib.UpdateMulti.Lemmas.fst
Lib.UpdateMulti.Lemmas.update_multi_is_repeat_blocks_multi
val update_multi_is_repeat_blocks_multi: #a:Type0 -> block_length:pos{ block_length < pow2 32 } -> update: (a -> s:S.seq uint8 { S.length s = block_length } -> a) -> acc:a -> input:S.seq uint8 -> Lemma (requires (S.length input % block_length == 0)) (ensures ( let repeat_f = repeat_f block_length update in Lib.Sequence.repeat_blocks_multi #uint8 block_length input repeat_f acc == Lib.UpdateMulti.mk_update_multi block_length update acc input)) (decreases (S.length input))
val update_multi_is_repeat_blocks_multi: #a:Type0 -> block_length:pos{ block_length < pow2 32 } -> update: (a -> s:S.seq uint8 { S.length s = block_length } -> a) -> acc:a -> input:S.seq uint8 -> Lemma (requires (S.length input % block_length == 0)) (ensures ( let repeat_f = repeat_f block_length update in Lib.Sequence.repeat_blocks_multi #uint8 block_length input repeat_f acc == Lib.UpdateMulti.mk_update_multi block_length update acc input)) (decreases (S.length input))
let rec update_multi_is_repeat_blocks_multi #a block_length update acc input = // Lib.UpdateMulti side let n_blocks = S.length input / block_length in // triggers! let blocks, rest = S.split input (n_blocks * block_length) in FStar.Math.Lemmas.nat_over_pos_is_nat (S.length input) block_length; // Lib.Sequence side let repeat_f = repeat_f block_length update in let repeat_blocks_f = Lib.Sequence.repeat_blocks_f in if S.length input = 0 then begin Lib.Sequence.lemma_repeat_blocks_multi block_length input repeat_f acc; Lib.LoopCombinators.eq_repeati0 n_blocks (Lib.Sequence.repeat_blocks_f block_length input repeat_f n_blocks) acc; Lib.UpdateMulti.update_multi_zero block_length update acc end else let split_index = S.length input - block_length in FStar.Math.Lemmas.modulo_lemma 0 block_length; FStar.Math.Lemmas.lemma_mod_plus (S.length input) (-1) block_length; Lib.Sequence.Lemmas.repeat_blocks_multi_split block_length split_index input repeat_f acc; let acc0 = Lib.UpdateMulti.mk_update_multi block_length update acc (S.slice input 0 split_index) in let f = repeat_blocks_f block_length (S.slice input split_index (S.length input)) repeat_f 1 in calc (==) { Lib.Sequence.repeat_blocks_multi #uint8 block_length input repeat_f acc; (==) { Lib.Sequence.Lemmas.repeat_blocks_multi_split block_length split_index input repeat_f acc } Lib.Sequence.repeat_blocks_multi #uint8 block_length (S.slice input split_index (S.length input)) repeat_f (Lib.Sequence.repeat_blocks_multi #uint8 block_length (S.slice input 0 split_index) repeat_f acc); (==) { update_multi_is_repeat_blocks_multi block_length update acc (S.slice input 0 split_index) } Lib.Sequence.repeat_blocks_multi #uint8 block_length (S.slice input split_index (S.length input)) repeat_f acc0; (==) { Lib.Sequence.lemma_repeat_blocks_multi block_length (S.slice input split_index (S.length input)) repeat_f acc0 } Lib.LoopCombinators.repeati 1 (repeat_blocks_f block_length (S.slice input split_index (S.length input)) repeat_f 1) acc0; (==) { Lib.LoopCombinators.unfold_repeati 1 (repeat_blocks_f block_length (S.slice input split_index (S.length input)) repeat_f 1) acc0 0 } f 0 (Lib.LoopCombinators.repeati 0 f acc0); (==) { Lib.LoopCombinators.eq_repeati0 0 f acc0 } f 0 acc0; (==) { } update acc0 (S.slice input split_index (S.length input)); (==) { update_multi_one block_length update acc0 (S.slice input split_index (S.length input)) } Lib.UpdateMulti.mk_update_multi block_length update acc0 (S.slice input split_index (S.length input)); (==) { Lib.UpdateMulti.update_multi_associative block_length update acc (S.slice input 0 split_index) (S.slice input split_index (S.length input)) } Lib.UpdateMulti.mk_update_multi block_length update acc (S.append (S.slice input 0 split_index) (S.slice input split_index (S.length input))); (==) { assert ( (S.append (S.slice input 0 split_index) (S.slice input split_index (S.length input))) `S.equal` input) } Lib.UpdateMulti.mk_update_multi block_length update acc input; }
{ "file_name": "lib/Lib.UpdateMulti.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 296, "start_col": 0, "start_line": 242 }
module Lib.UpdateMulti.Lemmas /// This first auxiliary lemma only manipulates the lengths of the sequences. #push-options "--z3cliopt smt.arith.nl=false" let split_at_last_lazy_nb_rem_spec (l : pos) (d n rest: nat) : Lemma (requires ( rest <= l /\ (rest = 0 ==> d = 0) /\ d = n * l + rest)) (ensures ((n, rest) = split_at_last_lazy_nb_rem l d)) = (* We call ``split_at_last_lazy_nb_rem`` at the beginning to have its * postcondition in the context (the return values are only used in the second * branch *) let n', rest' = split_at_last_lazy_nb_rem l d in if d = 0 then begin Math.Lemmas.nat_times_nat_is_nat n l; Math.Lemmas.int_times_int_equal_zero_lemma n l; assert(n = 0) end else begin assert(d > 0); (* In order to prove the equality between all the lengths, we use the unicity * of the modulo to prove that the rests are equal, then that the numbers * of blocks are equal. *) let blocks = n * l in let rest = d - blocks in let blocks' = n' * l in Math.Lemmas.cancel_mul_mod n l; assert(blocks % l = 0); assert(blocks' % l = 0); (* comes from the spec of [split_at_last_lazy_nb_rem] *) Math.Lemmas.euclidean_division_definition blocks l; (* First, prove that the lengths of the rests are equal modulo the size of * a block *) assert(rest' % l = d % l); (* comes from the spec of [split_at_last] *) assert(rest + n * l = d); Math.Lemmas.lemma_mod_plus rest n l; (* doesn't work inside a calc: typing problem with squash *) assert(d % l = rest % l); assert(rest % l = rest' % l); (* If both rests are stricly smaller than a block, we can directly apply * the modulo injectivity and the rest follows immediately *) if rest < l && rest' < l then begin Math.Lemmas.lemma_mod_injective l rest rest'; assert(rest = rest'); assert(n * l + rest = n' * l + rest'); assert(n * l = n' * l); Math.Lemmas.lemma_cancel_mul n n' l; assert(n = n') end (* Otherwise, case one: both rests are equal to block length (even easier) *) else if rest = l && rest' = l then Math.Lemmas.lemma_cancel_mul n n' l (* Last two cases: one of the rests is smaller than a block, and the other is * of the size of a block. Because of modulo properties, the smaller rest * must be equal to 0, which gives us that the data is actually of length 0: * contradiction. *) else begin assert((rest = l && rest' < l) \/ (rest < l && rest' = l)); let rest, rest' = if rest = l then rest, rest' else rest', rest in assert(rest = l && rest' < l); (* [rest % l = 0] *) assert(rest = 1 * l); Math.Lemmas.cancel_mul_mod 1 l; assert(rest % l = 0); (* [rest' = 0 ] *) Math.Lemmas.modulo_lemma rest' l; assert(rest' = 0); (* By the current hypotheses, if rest' = 0 then d = 0 (contradiction) *) assert(False) end end #pop-options /// This second lemma characterizes the sequences themselves. /// The proof strategy is to first prove that the blocks and rest sequences have /// the expected lengths, and the equality between the sequences is then trivial /// to get. #push-options "--z3cliopt smt.arith.nl=false" let split_at_last_lazy_spec (l : pos) (b blocks rest: S.seq uint8): Lemma (requires ( S.length blocks % l = 0 /\ S.length rest <= l /\ (S.length rest = 0 ==> S.length b = 0) /\ b `Seq.equal` Seq.append blocks rest)) (ensures ( (blocks, rest) == split_at_last_lazy l b)) = (* We need to introduce the variables with which to call [split_at_last_lazy_nb_rem_spec] *) let b_l = Seq.length b in let blocks_l = Seq.length blocks in let rest_l = Seq.length rest in let blocks', rest' = split_at_last_lazy l b in let n' = Seq.length blocks' / l in let n = blocks_l / l in Math.Lemmas.nat_over_pos_is_nat blocks_l l; assert(n >= 0); Math.Lemmas.euclidean_division_definition (S.length blocks) l; split_at_last_lazy_nb_rem_spec l b_l n rest_l; assert(((n <: nat), rest_l) = split_at_last_lazy_nb_rem l b_l); assert(n = n'); (* comes from the spec of [split_at_last_lazy] *) assert(rest_l = Seq.length rest'); (* We have the equalities between the sequence lengths, so the rest follows * naturally *) assert(blocks `Seq.equal` blocks'); assert(rest `Seq.equal` rest') #pop-options /// This is the reason why repeat_l is hoisted let repeat_l_input #a (block_length:pos { block_length < pow2 32 }) (update_last: (a -> s:S.seq uint8 { S.length s < block_length } -> a)) (input1 input2:S.seq uint8) (l: Lib.IntTypes.size_nat { l < block_length }) (s: Lib.Sequence.lseq uint8 l) (acc: a): Lemma (requires S.length input1 % block_length == S.length input2 % block_length) (ensures repeat_l block_length update_last input1 l s acc == repeat_l block_length update_last input2 l s acc) [ SMTPat (repeat_l block_length update_last input1 l s acc); SMTPat (repeat_l block_length update_last input2 l s acc) ] = () // NOTE: this proof is fragile but could be greatly simplified by using the // (more robust) proof immediately below. #push-options "--fuel 0 --ifuel 0 --z3rlimit 100 --split_queries no" let rec update_full_is_repeat_blocks #a block_length update update_last acc input input' = // Lib.UpdateMulti side let n_blocks = S.length input / block_length in let blocks, rest = S.split input (n_blocks * block_length) in // Lib.Sequence side let repeat_f = repeat_f block_length update in let repeat_l = repeat_l block_length update_last input' in let repeat_acc = Lib.LoopCombinators.repeati n_blocks (Lib.Sequence.repeat_blocks_f block_length input repeat_f n_blocks) acc in let last = Seq.slice input (n_blocks * block_length) (S.length input) in let repeat_final_acc = repeat_l (S.length input % block_length) last repeat_acc in Lib.Sequence.lemma_repeat_blocks #uint8 block_length input repeat_f repeat_l acc; assert (repeat_final_acc == Lib.Sequence.repeat_blocks #uint8 block_length input repeat_f repeat_l acc); // General, useful facts. Math.Lemmas.euclidean_division_definition (S.length input) block_length; S.lemma_eq_intro last rest; assert (S.length rest == S.length input % block_length); Math.Lemmas.multiple_modulo_lemma n_blocks block_length; assert (S.length blocks % block_length = 0); if S.length input < block_length then begin Lib.UpdateMulti.update_multi_zero block_length update acc; Math.Lemmas.small_mod (S.length input) block_length; S.lemma_eq_intro input rest; assert (update_full block_length update update_last acc input == update_last acc input); Lib.LoopCombinators.eq_repeati0 n_blocks (Lib.Sequence.repeat_blocks_f block_length input repeat_f n_blocks) acc; assert (repeat_acc == acc); assert (repeat_final_acc == update_last acc input); assert (repeat_final_acc == update_full block_length update update_last acc input) end else begin let head, tail = Lib.UpdateMulti.split_block block_length blocks 1 in assert (S.length head % block_length = 0); S.lemma_eq_intro (head `S.append` tail `S.append` rest) input; S.lemma_eq_intro (head `S.append` (tail `S.append` rest)) input; S.lemma_eq_intro (S.slice input 0 block_length) head; S.lemma_eq_intro (S.slice input block_length (S.length input)) (tail `S.append` rest); S.lemma_len_append head (tail `S.append` rest); S.lemma_len_append tail rest; calc (==) { S.length (tail `S.append` rest) / block_length; (==) { } (S.length input - S.length head) / block_length; (==) { } (S.length input + (- 1) * block_length) / block_length; (==) { Math.Lemmas.division_addition_lemma (S.length input) block_length (-1) } n_blocks - 1; }; (* These assertions make the lemma_eq_intro calls below work reliably. The _spinoff is so that they run each in a separate query, which helps for stability, and is apparently even faster. *) let as1 = fst (S.split (tail `S.append` rest) ((n_blocks - 1) * block_length)) in let as2 = snd (S.split (tail `S.append` rest) ((n_blocks - 1) * block_length)) in assert_spinoff (S.length as1 == S.length tail); assert_spinoff (S.length as2 == S.length rest); assert_spinoff (((n_blocks - 1) * block_length) <= S.length (tail `S.append` rest)); assert_spinoff (forall (i:nat{i < S.length as1}). S.index as1 i == S.index tail i); assert_spinoff (forall (i:nat{i < S.length as2}). S.index as2 i == S.index rest i); S.lemma_eq_intro (fst (S.split (tail `S.append` rest) ((n_blocks - 1) * block_length))) tail; S.lemma_eq_intro (snd (S.split (tail `S.append` rest) ((n_blocks - 1) * block_length))) rest; assert (S.length (tail `S.append` rest) % block_length == S.length input % block_length); norm_spec [zeta; iota; primops; delta_only [`%mk_update_multi]] (mk_update_multi block_length update acc (head `S.append` tail)); calc (==) { Lib.UpdateMulti.update_full block_length update update_last acc input; (==) { } update_last (mk_update_multi block_length update (update acc head) tail) rest; (==) { } Lib.UpdateMulti.update_full block_length update update_last (update acc head) (tail `S.append` rest); (==) { update_full_is_repeat_blocks #a block_length update update_last (update acc head) (tail `S.append` rest) input' } Lib.Sequence.repeat_blocks #uint8 block_length (tail `S.append` rest) repeat_f repeat_l (update acc head); (==) { } Lib.Sequence.repeat_blocks #uint8 block_length (tail `S.append` rest) repeat_f repeat_l (repeat_f head acc); (==) { Lib.LoopCombinators.eq_repeati0 1 (Lib.Sequence.repeat_blocks_f block_length head repeat_f 1) acc; Lib.LoopCombinators.unfold_repeati 1 (Lib.Sequence.repeat_blocks_f block_length head repeat_f 1) acc 0 } Lib.Sequence.repeat_blocks #uint8 block_length (tail `S.append` rest) repeat_f repeat_l (Lib.LoopCombinators.repeati 1 (Lib.Sequence.repeat_blocks_f block_length head repeat_f 1) acc); (==) { Lib.Sequence.lemma_repeat_blocks_multi block_length head repeat_f acc } Lib.Sequence.repeat_blocks #uint8 block_length (tail `S.append` rest) repeat_f repeat_l (Lib.Sequence.repeat_blocks_multi block_length head repeat_f acc); (==) { Lib.Sequence.Lemmas.repeat_blocks_split block_length block_length input repeat_f repeat_l acc } Lib.Sequence.repeat_blocks #uint8 block_length input repeat_f repeat_l acc; } end #pop-options #push-options "--fuel 2" let update_multi_one #a (block_length: pos) (update: update_t a block_length) (acc0: a) (input: S.seq uint8 { S.length input == block_length }): Lemma (ensures update acc0 input == Lib.UpdateMulti.mk_update_multi block_length update acc0 input) = () #pop-options
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.UpdateMulti.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Lib.UpdateMulti.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.UpdateMulti", "short_module": null }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.UpdateMulti", "short_module": null }, { "abbrev": false, "full_module": "Lib.UpdateMulti", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 300, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
block_length: Prims.pos{block_length < Prims.pow2 32} -> update: ( _: a -> s: FStar.Seq.Base.seq Lib.UpdateMulti.Lemmas.uint8 {FStar.Seq.Base.length s = block_length} -> a) -> acc: a -> input: FStar.Seq.Base.seq Lib.UpdateMulti.Lemmas.uint8 -> FStar.Pervasives.Lemma (requires FStar.Seq.Base.length input % block_length == 0) (ensures (let repeat_f = Lib.UpdateMulti.Lemmas.repeat_f block_length update in Lib.Sequence.repeat_blocks_multi block_length input repeat_f acc == Lib.UpdateMulti.mk_update_multi block_length update acc input)) (decreases FStar.Seq.Base.length input)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "Prims.pos", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "FStar.Seq.Base.seq", "Lib.UpdateMulti.Lemmas.uint8", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "Prims.l_and", "Prims.op_GreaterThan", "FStar.Seq.Base.length", "Lib.UpdateMulti.update_multi_zero", "Prims.unit", "Lib.LoopCombinators.eq_repeati0", "Lib.Sequence.repeat_blocks_f", "Lib.Sequence.lemma_repeat_blocks_multi", "Prims.bool", "FStar.Calc.calc_finish", "Prims.eq2", "Lib.Sequence.repeat_blocks_multi", "Lib.UpdateMulti.mk_update_multi", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "FStar.Calc.calc_step", "FStar.Seq.Base.append", "FStar.Seq.Base.slice", "Lib.LoopCombinators.repeati", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Lib.Sequence.Lemmas.repeat_blocks_multi_split", "Prims.squash", "Lib.UpdateMulti.Lemmas.update_multi_is_repeat_blocks_multi", "Lib.LoopCombinators.unfold_repeati", "Lib.UpdateMulti.Lemmas.update_multi_one", "Lib.UpdateMulti.update_multi_associative", "Prims._assert", "FStar.Seq.Base.equal", "Prims.nat", "FStar.Math.Lemmas.lemma_mod_plus", "Prims.op_Minus", "FStar.Math.Lemmas.modulo_lemma", "Prims.op_Subtraction", "Prims.op_LessThanOrEqual", "Lib.Sequence.seq", "Lib.Sequence.lseq", "Prims.op_Division", "Lib.Sequence.length", "Lib.UpdateMulti.Lemmas.repeat_f", "FStar.Math.Lemmas.nat_over_pos_is_nat", "FStar.Pervasives.Native.tuple2", "FStar.Seq.Properties.split", "FStar.Mul.op_Star" ]
[ "recursion" ]
false
false
true
false
false
let rec update_multi_is_repeat_blocks_multi #a block_length update acc input =
let n_blocks = S.length input / block_length in let blocks, rest = S.split input (n_blocks * block_length) in FStar.Math.Lemmas.nat_over_pos_is_nat (S.length input) block_length; let repeat_f = repeat_f block_length update in let repeat_blocks_f = Lib.Sequence.repeat_blocks_f in if S.length input = 0 then (Lib.Sequence.lemma_repeat_blocks_multi block_length input repeat_f acc; Lib.LoopCombinators.eq_repeati0 n_blocks (Lib.Sequence.repeat_blocks_f block_length input repeat_f n_blocks) acc; Lib.UpdateMulti.update_multi_zero block_length update acc) else let split_index = S.length input - block_length in FStar.Math.Lemmas.modulo_lemma 0 block_length; FStar.Math.Lemmas.lemma_mod_plus (S.length input) (- 1) block_length; Lib.Sequence.Lemmas.repeat_blocks_multi_split block_length split_index input repeat_f acc; let acc0 = Lib.UpdateMulti.mk_update_multi block_length update acc (S.slice input 0 split_index) in let f = repeat_blocks_f block_length (S.slice input split_index (S.length input)) repeat_f 1 in calc ( == ) { Lib.Sequence.repeat_blocks_multi #uint8 block_length input repeat_f acc; ( == ) { Lib.Sequence.Lemmas.repeat_blocks_multi_split block_length split_index input repeat_f acc } Lib.Sequence.repeat_blocks_multi #uint8 block_length (S.slice input split_index (S.length input)) repeat_f (Lib.Sequence.repeat_blocks_multi #uint8 block_length (S.slice input 0 split_index) repeat_f acc); ( == ) { update_multi_is_repeat_blocks_multi block_length update acc (S.slice input 0 split_index) } Lib.Sequence.repeat_blocks_multi #uint8 block_length (S.slice input split_index (S.length input)) repeat_f acc0; ( == ) { Lib.Sequence.lemma_repeat_blocks_multi block_length (S.slice input split_index (S.length input)) repeat_f acc0 } Lib.LoopCombinators.repeati 1 (repeat_blocks_f block_length (S.slice input split_index (S.length input)) repeat_f 1) acc0; ( == ) { Lib.LoopCombinators.unfold_repeati 1 (repeat_blocks_f block_length (S.slice input split_index (S.length input)) repeat_f 1) acc0 0 } f 0 (Lib.LoopCombinators.repeati 0 f acc0); ( == ) { Lib.LoopCombinators.eq_repeati0 0 f acc0 } f 0 acc0; ( == ) { () } update acc0 (S.slice input split_index (S.length input)); ( == ) { update_multi_one block_length update acc0 (S.slice input split_index (S.length input)) } Lib.UpdateMulti.mk_update_multi block_length update acc0 (S.slice input split_index (S.length input)); ( == ) { Lib.UpdateMulti.update_multi_associative block_length update acc (S.slice input 0 split_index) (S.slice input split_index (S.length input)) } Lib.UpdateMulti.mk_update_multi block_length update acc (S.append (S.slice input 0 split_index) (S.slice input split_index (S.length input))); ( == ) { assert ((S.append (S.slice input 0 split_index) (S.slice input split_index (S.length input))) `S.equal` input) } Lib.UpdateMulti.mk_update_multi block_length update acc input; }
false
Hacl.K256.Scalar.fst
Hacl.K256.Scalar.modq_before_final
val modq_before_final: t01:lbuffer uint64 2ul -> a:lbuffer uint64 (2ul *! qnlimb) -> out:qelem -> Stack (BB.carry U64) (requires fun h -> live h a /\ live h out /\ live h t01 /\ disjoint a out /\ disjoint a t01 /\ disjoint out t01 /\ as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\ as_seq h out == LSeq.create 4 (u64 0)) (ensures fun h0 c h1 -> modifies (loc out) h0 h1 /\ (c, as_seq h1 out) == mod_lseq_before_final (as_seq h0 a))
val modq_before_final: t01:lbuffer uint64 2ul -> a:lbuffer uint64 (2ul *! qnlimb) -> out:qelem -> Stack (BB.carry U64) (requires fun h -> live h a /\ live h out /\ live h t01 /\ disjoint a out /\ disjoint a t01 /\ disjoint out t01 /\ as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\ as_seq h out == LSeq.create 4 (u64 0)) (ensures fun h0 c h1 -> modifies (loc out) h0 h1 /\ (c, as_seq h1 out) == mod_lseq_before_final (as_seq h0 a))
let modq_before_final t01 a out = push_frame (); let m = create 7ul (u64 0) in let p = create 5ul (u64 0) in let c0 = mul_pow2_256_minus_q_add 4ul 7ul t01 (sub a 4ul 4ul) (sub a 0ul 4ul) m in let c1 = mul_pow2_256_minus_q_add 3ul 5ul t01 (sub m 4ul 3ul) (sub m 0ul 4ul) p in let c2 = mul_pow2_256_minus_q_add 1ul 4ul t01 (sub p 4ul 1ul) (sub p 0ul 4ul) out in pop_frame (); c2
{ "file_name": "code/k256/Hacl.K256.Scalar.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 286, "start_col": 0, "start_line": 278 }
module Hacl.K256.Scalar open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Spec.K256 module KL = Hacl.Spec.K256.Scalar.Lemmas module SG = Hacl.Spec.K256.GLV module SGL = Hacl.Spec.K256.GLV.Lemmas module BD = Hacl.Bignum.Definitions module BN = Hacl.Bignum module BB = Hacl.Bignum.Base module SN = Hacl.Spec.Bignum module SD = Hacl.Spec.Bignum.Definitions include Hacl.Spec.K256.Scalar #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@CInline] let bn_add : BN.bn_add_st U64 = BN.bn_add //inline_for_extraction noextract //let kn = BN.mk_runtime_bn U64 qnlimb let add4: BN.bn_add_eq_len_st U64 qnlimb = BN.bn_add_eq_len qnlimb let sub4: BN.bn_sub_eq_len_st U64 qnlimb = BN.bn_sub_eq_len qnlimb let add_mod4: BN.bn_add_mod_n_st U64 qnlimb = BN.bn_add_mod_n qnlimb let sub_mod4: BN.bn_sub_mod_n_st U64 qnlimb = BN.bn_sub_mod_n qnlimb let mul4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_mul_st U64 qnlimb a = BN.bn_mul qnlimb qnlimb a let sqr4 (a:BD.lbignum U64 qnlimb) : BN.bn_karatsuba_sqr_st U64 qnlimb a = BN.bn_sqr qnlimb a inline_for_extraction noextract instance kn: BN.bn U64 = { BN.len = qnlimb; BN.add = add4; BN.sub = sub4; BN.add_mod_n = add_mod4; BN.sub_mod_n = sub_mod4; BN.mul = mul4; BN.sqr = sqr4 } let make_u64_4 out (f0, f1, f2, f3) = out.(0ul) <- f0; out.(1ul) <- f1; out.(2ul) <- f2; out.(3ul) <- f3; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h out); assert (Seq.equal (as_seq h out) (LSeq.create4 f0 f1 f2 f3)) let make_order_k256 () = [@inline_let] let r = (u64 0xbfd25e8cd0364141, u64 0xbaaedce6af48a03b, u64 0xfffffffffffffffe, u64 0xffffffffffffffff) in assert_norm (qas_nat4 r = S.q); r let create_qelem () = SD.bn_eval_zeroes #U64 (v qnlimb) (v qnlimb); create qnlimb (u64 0) let create_one () = [@inline_let] let l = [u64 0x1; u64 0x0; u64 0x0; u64 0x0] in assert_norm (FStar.List.Tot.length l = 4); Seq.elim_of_list l; LSeq.eq_intro (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)) (Seq.seq_of_list l); KL.qas_nat4_is_qas_nat (LSeq.create4 (u64 0x1) (u64 0x0) (u64 0x0) (u64 0x0)); createL l [@CInline] let is_qelem_zero f = let h0 = ST.get () in SN.bn_is_zero_mask_lemma (as_seq h0 f); BN.bn_is_zero_mask qnlimb f [@CInline] let is_qelem_zero_vartime f = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let (f0,f1,f2,f3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in KL.is_qelem_zero_vartime4_lemma (f0,f1,f2,f3); is_qelem_zero_vartime4 (f0,f1,f2,f3) [@CInline] let is_qelem_eq_vartime f1 f2 = let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f1); KL.qas_nat4_is_qas_nat (as_seq h f2); let (a0,a1,a2,a3) = (f1.(0ul), f1.(1ul), f1.(2ul), f1.(3ul)) in let (b0,b1,b2,b3) = (f2.(0ul), f2.(1ul), f2.(2ul), f2.(3ul)) in KL.is_qelem_eq_vartime4_lemma (a0,a1,a2,a3) (b0,b1,b2,b3); is_qelem_eq_vartime4 (a0,a1,a2,a3) (b0,b1,b2,b3) let load_qelem f b = let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_from_bytes_be_lemma #U64 32 (as_seq h0 b); Hacl.Bignum.Convert.mk_bn_from_bytes_be true 32ul b f [@CInline] let load_qelem_check f b = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); load_qelem f b; let h0 = ST.get () in let is_zero = is_qelem_zero f in assert (v is_zero == (if qas_nat h0 f = 0 then ones_v U64 else 0)); let is_lt_q = BN.bn_lt_mask qnlimb f n in SN.bn_lt_mask_lemma (as_seq h0 f) (as_seq h0 n); assert (v is_lt_q == (if qas_nat h0 f < S.q then ones_v U64 else 0)); let m = logand (lognot is_zero) is_lt_q in lognot_lemma is_zero; logand_lemma (lognot is_zero) is_lt_q; pop_frame (); m let load_qelem_conditional res b = push_frame (); let is_b_valid = load_qelem_check res b in let oneq = create_one () in let h0 = ST.get () in Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res; let h1 = ST.get () in assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res)); pop_frame (); is_b_valid [@CInline] let load_qelem_vartime f b = load_qelem f b; let h = ST.get () in KL.qas_nat4_is_qas_nat (as_seq h f); let is_zero = is_qelem_zero_vartime f in let (a0,a1,a2,a3) = (f.(0ul), f.(1ul), f.(2ul), f.(3ul)) in let is_lt_q_b = is_qelem_lt_q_vartime4 (a0,a1,a2,a3) in KL.is_qelem_lt_q_vartime4_lemma (a0,a1,a2,a3); not is_zero && is_lt_q_b val modq_short: out:qelem -> a:qelem -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ qas_nat h1 out == qas_nat h0 a % S.q) [@CInline] let modq_short out a = push_frame (); let tmp = create_qelem () in [@inline_let] let (t0,t1,t2,t3) = make_pow2_256_minus_order_k256 () in make_u64_4 tmp (t0,t1,t2,t3); let h0 = ST.get () in let c = kn.BN.add a tmp out in let mask = u64 0 -. c in map2T qnlimb out (BB.mask_select mask) out a; KL.mod_short_lseq_lemma (as_seq h0 a); pop_frame () [@CInline] let load_qelem_modq f b = push_frame (); let tmp = create_qelem () in load_qelem f b; copy tmp f; modq_short f tmp; pop_frame () [@CInline] let store_qelem b f = let h0 = ST.get () in Hacl.Spec.Bignum.Convert.bn_to_bytes_be_lemma #U64 32 (as_seq h0 f); Hacl.Bignum.Convert.mk_bn_to_bytes_be true 32ul f b [@CInline] let qadd out f1 f2 = push_frame (); let n = create_qelem () in make_u64_4 n (make_order_k256 ()); let h0 = ST.get () in kn.BN.add_mod_n n f1 f2 out; SN.bn_add_mod_n_lemma (as_seq h0 n) (as_seq h0 f1) (as_seq h0 f2); pop_frame () val mul_pow2_256_minus_q_add: len:size_t -> resLen:size_t{2 + v len <= v resLen /\ 4 <= v resLen} -> t01:lbuffer uint64 2ul -> a:lbuffer uint64 len -> e:lbuffer uint64 4ul -> res:lbuffer uint64 resLen -> Stack (BB.carry U64) (requires fun h -> live h a /\ live h res /\ live h t01 /\ live h e /\ disjoint a res /\ disjoint a t01 /\ disjoint a e /\ disjoint res t01 /\ disjoint res e /\ disjoint t01 e /\ as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\ as_seq h res == LSeq.create (v resLen) (u64 0)) (ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\ (c, as_seq h1 res) == mul_pow2_256_minus_q_lseq_add (v len) (v resLen) (as_seq h0 a) (as_seq h0 e)) [@CInline] let mul_pow2_256_minus_q_add len resLen t01 a e res = push_frame (); let tmp = create (len +! 2ul) (u64 0) in BN.bn_mul len 2ul a t01 tmp; update_sub res 2ul len a; let _ = bn_add resLen res (len +! 2ul) tmp res in let c = bn_add resLen res 4ul e res in pop_frame (); c inline_for_extraction noextract val modq_before_final: t01:lbuffer uint64 2ul -> a:lbuffer uint64 (2ul *! qnlimb) -> out:qelem -> Stack (BB.carry U64) (requires fun h -> live h a /\ live h out /\ live h t01 /\ disjoint a out /\ disjoint a t01 /\ disjoint out t01 /\ as_seq h t01 == LSeq.create2 (u64 0x402da1732fc9bebf) (u64 0x4551231950b75fc4) /\ as_seq h out == LSeq.create 4 (u64 0)) (ensures fun h0 c h1 -> modifies (loc out) h0 h1 /\ (c, as_seq h1 out) == mod_lseq_before_final (as_seq h0 a))
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Scalar.Lemmas.fst.checked", "Hacl.Spec.K256.Scalar.fst.checked", "Hacl.Spec.K256.GLV.Lemmas.fst.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Convert.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Convert.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Hacl.K256.Scalar.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.Scalar", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV.Lemmas", "short_module": "SGL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Scalar.Lemmas", "short_module": "KL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.GLV", "short_module": "SG" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t01: Lib.Buffer.lbuffer Lib.IntTypes.uint64 2ul -> a: Lib.Buffer.lbuffer Lib.IntTypes.uint64 (2ul *! Hacl.K256.Scalar.qnlimb) -> out: Hacl.K256.Scalar.qelem -> FStar.HyperStack.ST.Stack (Hacl.Spec.Bignum.Base.carry Lib.IntTypes.U64)
FStar.HyperStack.ST.Stack
[]
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.K256.Scalar.qnlimb", "Hacl.K256.Scalar.qelem", "Hacl.Spec.Bignum.Base.carry", "Lib.IntTypes.U64", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Hacl.K256.Scalar.mul_pow2_256_minus_q_add", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.sub", "Lib.Buffer.create", "Lib.IntTypes.u64", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let modq_before_final t01 a out =
push_frame (); let m = create 7ul (u64 0) in let p = create 5ul (u64 0) in let c0 = mul_pow2_256_minus_q_add 4ul 7ul t01 (sub a 4ul 4ul) (sub a 0ul 4ul) m in let c1 = mul_pow2_256_minus_q_add 3ul 5ul t01 (sub m 4ul 3ul) (sub m 0ul 4ul) p in let c2 = mul_pow2_256_minus_q_add 1ul 4ul t01 (sub p 4ul 1ul) (sub p 0ul 4ul) out in pop_frame (); c2
false
Vale.AES.X64.GCMdecryptOpt.fsti
Vale.AES.X64.GCMdecryptOpt.va_quick_Gcm_blocks_decrypt_stdcall
val va_quick_Gcm_blocks_decrypt_stdcall (win: bool) (alg: algorithm) (auth_b: buffer128) (auth_bytes auth_num: nat64) (keys_b iv_b: buffer128) (iv: supported_iv_LE) (hkeys_b abytes_b in128x6_b out128x6_b: buffer128) (len128x6_num: nat64) (in128_b out128_b: buffer128) (len128_num: nat64) (inout_b: buffer128) (cipher_num: nat64) (scratch_b tag_b: buffer128) (key: (seq nat32)) : (va_quickCode unit (va_code_Gcm_blocks_decrypt_stdcall win alg))
val va_quick_Gcm_blocks_decrypt_stdcall (win: bool) (alg: algorithm) (auth_b: buffer128) (auth_bytes auth_num: nat64) (keys_b iv_b: buffer128) (iv: supported_iv_LE) (hkeys_b abytes_b in128x6_b out128x6_b: buffer128) (len128x6_num: nat64) (in128_b out128_b: buffer128) (len128_num: nat64) (inout_b: buffer128) (cipher_num: nat64) (scratch_b tag_b: buffer128) (key: (seq nat32)) : (va_quickCode unit (va_code_Gcm_blocks_decrypt_stdcall win alg))
let va_quick_Gcm_blocks_decrypt_stdcall (win:bool) (alg:algorithm) (auth_b:buffer128) (auth_bytes:nat64) (auth_num:nat64) (keys_b:buffer128) (iv_b:buffer128) (iv:supported_iv_LE) (hkeys_b:buffer128) (abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128) (len128x6_num:nat64) (in128_b:buffer128) (out128_b:buffer128) (len128_num:nat64) (inout_b:buffer128) (cipher_num:nat64) (scratch_b:buffer128) (tag_b:buffer128) (key:(seq nat32)) : (va_quickCode unit (va_code_Gcm_blocks_decrypt_stdcall win alg)) = (va_QProc (va_code_Gcm_blocks_decrypt_stdcall win alg) ([va_Mod_stackTaint; va_Mod_stack; va_Mod_flags; va_Mod_mem_layout; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_Gcm_blocks_decrypt_stdcall win alg auth_b auth_bytes auth_num keys_b iv_b iv hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b key) (va_wpProof_Gcm_blocks_decrypt_stdcall win alg auth_b auth_bytes auth_num keys_b iv_b iv hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b key))
{ "file_name": "obj/Vale.AES.X64.GCMdecryptOpt.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 36, "end_line": 855, "start_col": 0, "start_line": 836 }
module Vale.AES.X64.GCMdecryptOpt open Vale.Def.Prop_s open Vale.Def.Opaque_s open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.Arch.HeapImpl open Vale.AES.AES_s open Vale.AES.GCTR_s open Vale.AES.GCTR open Vale.AES.GCM open Vale.AES.GHash_s open Vale.AES.GHash open Vale.AES.GCM_s open Vale.AES.X64.AES open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.Poly1305.Math open Vale.AES.GCM_helpers open Vale.AES.X64.GHash open Vale.AES.X64.GCTR open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsStack open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.AES.X64.GF128_Mul open Vale.X64.Stack open Vale.X64.CPU_Features_s open Vale.Math.Poly2.Bits_s open Vale.AES.X64.AESopt open Vale.AES.X64.AESGCM open Vale.AES.X64.AESopt2 open Vale.Lib.Meta open Vale.AES.X64.GCMencryptOpt open Vale.AES.OptPublic let aes_reqs (alg:algorithm) (key:seq nat32) (round_keys:seq quad32) (keys_b:buffer128) (key_ptr:int) (heap0:vale_heap) (layout:vale_heap_layout) : prop0 = aesni_enabled /\ avx_enabled /\ (alg = AES_128 \/ alg = AES_256) /\ is_aes_key_LE alg key /\ length(round_keys) == nr(alg) + 1 /\ round_keys == key_to_round_keys_LE alg key /\ validSrcAddrs128 heap0 key_ptr keys_b (nr alg + 1) layout Secret /\ s128 heap0 keys_b == round_keys #reset-options "--z3rlimit 100 --max_ifuel 0" //-- Gcm_blocks_decrypt_stdcall val va_code_Gcm_blocks_decrypt_stdcall : win:bool -> alg:algorithm -> Tot va_code val va_codegen_success_Gcm_blocks_decrypt_stdcall : win:bool -> alg:algorithm -> Tot va_pbool let va_req_Gcm_blocks_decrypt_stdcall (va_b0:va_code) (va_s0:va_state) (win:bool) (alg:algorithm) (auth_b:buffer128) (auth_bytes:nat64) (auth_num:nat64) (keys_b:buffer128) (iv_b:buffer128) (iv:supported_iv_LE) (hkeys_b:buffer128) (abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128) (len128x6_num:nat64) (in128_b:buffer128) (out128_b:buffer128) (len128_num:nat64) (inout_b:buffer128) (cipher_num:nat64) (scratch_b:buffer128) (tag_b:buffer128) (key:(seq nat32)) : prop = (va_require_total va_b0 (va_code_Gcm_blocks_decrypt_stdcall win alg) va_s0 /\ va_get_ok va_s0 /\ (let (auth_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0 else va_get_reg64 rRdi va_s0) in let (auth_num_bytes:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let (auth_len:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR8 va_s0 else va_get_reg64 rRdx va_s0) in let (keys_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR9 va_s0 else va_get_reg64 rRcx va_s0) in let (iv_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 0) (va_get_stack va_s0) else va_get_reg64 rR8 va_s0) in let (xip:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 8) (va_get_stack va_s0) else va_get_reg64 rR9 va_s0) in let (abytes_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 16) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0)) in let (in128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) in let (out128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0)) in let (len128x6:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0)) in let (in128_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 48) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 32) (va_get_stack va_s0)) in let (out128_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0)) in let (len128:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0)) in let (inout_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 72) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 56) (va_get_stack va_s0)) in let (cipher_num_bytes:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0)) in let (scratch_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0)) in let (tag_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0)) in sse_enabled /\ movbe_enabled /\ va_get_reg64 rRsp va_s0 == Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\ Vale.X64.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 32) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 0) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 16) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 48) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 72) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ auth_len == auth_num /\ auth_num_bytes == auth_bytes /\ len128x6 == len128x6_num /\ len128 == len128_num /\ cipher_num_bytes == cipher_num /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) auth_ptr auth_b auth_len (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) abytes_ptr abytes_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) iv_ptr iv_b 1 (va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) in128x6_ptr in128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) in128_ptr in128_b len128 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) inout_ptr inout_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) scratch_ptr scratch_b 9 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) xip hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) tag_ptr tag_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 tag_b ([auth_b; abytes_b; iv_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b; scratch_b]) /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b; scratch_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b; in128_b; out128_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 auth_b ([keys_b; abytes_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 abytes_b ([keys_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b; auth_b; abytes_b; hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 in128x6_b ([keys_b; auth_b; abytes_b; hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; auth_b; abytes_b; hkeys_b; in128x6_b; out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 in128_b ([keys_b; auth_b; abytes_b; hkeys_b; in128x6_b; out128x6_b; inout_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b == out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b) /\ auth_ptr + 16 `op_Multiply` auth_len < pow2_64 /\ in128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\ in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b == auth_len /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\ cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\ xip + 32 < pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\ 12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) <= cipher_num_bytes /\ cipher_num_bytes < va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\ (va_mul_nat auth_len (128 `op_Division` 8) <= auth_num_bytes /\ auth_num_bytes < va_mul_nat auth_len (128 `op_Division` 8) + 128 `op_Division` 8) /\ aes_reqs alg key (Vale.X64.Decls.buffer128_as_seq (va_get_mem va_s0) keys_b) keys_b keys_ptr (va_get_mem va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\ Vale.AES.OptPublic.hkeys_reqs_pub (Vale.X64.Decls.s128 (va_get_mem va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\ (let h_LE = Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) in let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in iv_BE == Vale.AES.GCM_s.compute_iv_BE h_LE iv))) let va_ens_Gcm_blocks_decrypt_stdcall (va_b0:va_code) (va_s0:va_state) (win:bool) (alg:algorithm) (auth_b:buffer128) (auth_bytes:nat64) (auth_num:nat64) (keys_b:buffer128) (iv_b:buffer128) (iv:supported_iv_LE) (hkeys_b:buffer128) (abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128) (len128x6_num:nat64) (in128_b:buffer128) (out128_b:buffer128) (len128_num:nat64) (inout_b:buffer128) (cipher_num:nat64) (scratch_b:buffer128) (tag_b:buffer128) (key:(seq nat32)) (va_sM:va_state) (va_fM:va_fuel) : prop = (va_req_Gcm_blocks_decrypt_stdcall va_b0 va_s0 win alg auth_b auth_bytes auth_num keys_b iv_b iv hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b key /\ va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (auth_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0 else va_get_reg64 rRdi va_s0) in let (auth_num_bytes:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let (auth_len:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR8 va_s0 else va_get_reg64 rRdx va_s0) in let (keys_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR9 va_s0 else va_get_reg64 rRcx va_s0) in let (iv_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 0) (va_get_stack va_s0) else va_get_reg64 rR8 va_s0) in let (xip:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 8) (va_get_stack va_s0) else va_get_reg64 rR9 va_s0) in let (abytes_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 16) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0)) in let (in128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) in let (out128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0)) in let (len128x6:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0)) in let (in128_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 48) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 32) (va_get_stack va_s0)) in let (out128_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0)) in let (len128:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0)) in let (inout_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 72) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 56) (va_get_stack va_s0)) in let (cipher_num_bytes:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0)) in let (scratch_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0)) in let (tag_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0)) in Vale.X64.Decls.modifies_mem (Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 iv_b) (Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 scratch_b) (Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 out128x6_b) (Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 out128_b) (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 inout_b))))) (va_get_mem va_s0) (va_get_mem va_sM) /\ cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in let auth_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_s0) auth_b) (Vale.X64.Decls.s128 (va_get_mem va_s0) abytes_b) in let auth_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0 auth_num_bytes in let cipher_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_s0) in128x6_b) (Vale.X64.Decls.s128 (va_get_mem va_s0) in128_b)) (Vale.X64.Decls.s128 (va_get_mem va_s0) inout_b) in let cipher_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads) 0 cipher_num_bytes in let plain_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem va_sM) out128_b)) (Vale.X64.Decls.s128 (va_get_mem va_sM) inout_b) in let plain_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads) 0 cipher_num_bytes in let expected_tag = Vale.Def.Types_s.le_quad32_to_bytes (Vale.X64.Decls.buffer128_read tag_b 0 (va_get_mem va_s0)) in l_and (l_and (l_and (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.nat8 auth_bytes < pow2_32) (FStar.Seq.Base.length #Vale.Def.Types_s.nat8 cipher_bytes < pow2_32)) (Vale.AES.AES_common_s.is_aes_key alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key))) (plain_bytes == __proj__Mktuple2__item___1 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool (Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv cipher_bytes auth_bytes expected_tag))) (va_get_reg64 rRax va_sM = 0 == __proj__Mktuple2__item___2 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool (Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv cipher_bytes auth_bytes expected_tag)) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 /\ (win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\ (win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\ (win ==> va_get_reg64 rRdi va_sM == va_get_reg64 rRdi va_s0) /\ (win ==> va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0) /\ (win ==> va_get_reg64 rR12 va_sM == va_get_reg64 rR12 va_s0) /\ (win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13 va_s0) /\ (win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ (win ==> va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0) /\ (win ==> va_get_xmm 6 va_sM == va_get_xmm 6 va_s0) /\ (win ==> va_get_xmm 7 va_sM == va_get_xmm 7 va_s0) /\ (win ==> va_get_xmm 8 va_sM == va_get_xmm 8 va_s0) /\ (win ==> va_get_xmm 9 va_sM == va_get_xmm 9 va_s0) /\ (win ==> va_get_xmm 10 va_sM == va_get_xmm 10 va_s0) /\ (win ==> va_get_xmm 11 va_sM == va_get_xmm 11 va_s0) /\ (win ==> va_get_xmm 12 va_sM == va_get_xmm 12 va_s0) /\ (win ==> va_get_xmm 13 va_sM == va_get_xmm 13 va_s0) /\ (win ==> va_get_xmm 14 va_sM == va_get_xmm 14 va_s0) /\ (win ==> va_get_xmm 15 va_sM == va_get_xmm 15 va_s0) /\ (~win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\ (~win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\ (~win ==> va_get_reg64 rR12 va_sM == va_get_reg64 rR12 va_s0) /\ (~win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13 va_s0) /\ (~win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ (~win ==> va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0))) /\ va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_flags va_sM (va_update_mem_layout va_sM (va_update_mem_heaplet 6 va_sM (va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm 9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRbp va_sM (va_update_reg64 rRsp va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))))))))))))))))))))))))) val va_lemma_Gcm_blocks_decrypt_stdcall : va_b0:va_code -> va_s0:va_state -> win:bool -> alg:algorithm -> auth_b:buffer128 -> auth_bytes:nat64 -> auth_num:nat64 -> keys_b:buffer128 -> iv_b:buffer128 -> iv:supported_iv_LE -> hkeys_b:buffer128 -> abytes_b:buffer128 -> in128x6_b:buffer128 -> out128x6_b:buffer128 -> len128x6_num:nat64 -> in128_b:buffer128 -> out128_b:buffer128 -> len128_num:nat64 -> inout_b:buffer128 -> cipher_num:nat64 -> scratch_b:buffer128 -> tag_b:buffer128 -> key:(seq nat32) -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Gcm_blocks_decrypt_stdcall win alg) va_s0 /\ va_get_ok va_s0 /\ (let (auth_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0 else va_get_reg64 rRdi va_s0) in let (auth_num_bytes:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let (auth_len:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR8 va_s0 else va_get_reg64 rRdx va_s0) in let (keys_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR9 va_s0 else va_get_reg64 rRcx va_s0) in let (iv_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 0) (va_get_stack va_s0) else va_get_reg64 rR8 va_s0) in let (xip:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 8) (va_get_stack va_s0) else va_get_reg64 rR9 va_s0) in let (abytes_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 16) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0)) in let (in128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) in let (out128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0)) in let (len128x6:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0)) in let (in128_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 48) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 32) (va_get_stack va_s0)) in let (out128_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0)) in let (len128:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0)) in let (inout_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 72) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 56) (va_get_stack va_s0)) in let (cipher_num_bytes:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0)) in let (scratch_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0)) in let (tag_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0)) in sse_enabled /\ movbe_enabled /\ va_get_reg64 rRsp va_s0 == Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\ Vale.X64.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 32) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 0) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 16) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 48) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 72) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ auth_len == auth_num /\ auth_num_bytes == auth_bytes /\ len128x6 == len128x6_num /\ len128 == len128_num /\ cipher_num_bytes == cipher_num /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) auth_ptr auth_b auth_len (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) abytes_ptr abytes_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) iv_ptr iv_b 1 (va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) in128x6_ptr in128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) in128_ptr in128_b len128 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) inout_ptr inout_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) scratch_ptr scratch_b 9 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) xip hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) tag_ptr tag_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 tag_b ([auth_b; abytes_b; iv_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b; scratch_b]) /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b; scratch_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b; in128_b; out128_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 auth_b ([keys_b; abytes_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 abytes_b ([keys_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b; auth_b; abytes_b; hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 in128x6_b ([keys_b; auth_b; abytes_b; hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; auth_b; abytes_b; hkeys_b; in128x6_b; out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 in128_b ([keys_b; auth_b; abytes_b; hkeys_b; in128x6_b; out128x6_b; inout_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b == out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b) /\ auth_ptr + 16 `op_Multiply` auth_len < pow2_64 /\ in128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\ in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b == auth_len /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\ cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\ xip + 32 < pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\ 12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) <= cipher_num_bytes /\ cipher_num_bytes < va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\ (va_mul_nat auth_len (128 `op_Division` 8) <= auth_num_bytes /\ auth_num_bytes < va_mul_nat auth_len (128 `op_Division` 8) + 128 `op_Division` 8) /\ aes_reqs alg key (Vale.X64.Decls.buffer128_as_seq (va_get_mem va_s0) keys_b) keys_b keys_ptr (va_get_mem va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\ Vale.AES.OptPublic.hkeys_reqs_pub (Vale.X64.Decls.s128 (va_get_mem va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\ (let h_LE = Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) in let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in iv_BE == Vale.AES.GCM_s.compute_iv_BE h_LE iv)))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (auth_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0 else va_get_reg64 rRdi va_s0) in let (auth_num_bytes:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let (auth_len:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR8 va_s0 else va_get_reg64 rRdx va_s0) in let (keys_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR9 va_s0 else va_get_reg64 rRcx va_s0) in let (iv_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 0) (va_get_stack va_s0) else va_get_reg64 rR8 va_s0) in let (xip:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 8) (va_get_stack va_s0) else va_get_reg64 rR9 va_s0) in let (abytes_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 16) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0)) in let (in128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) in let (out128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0)) in let (len128x6:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0)) in let (in128_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 48) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 32) (va_get_stack va_s0)) in let (out128_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0)) in let (len128:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0)) in let (inout_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 72) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 56) (va_get_stack va_s0)) in let (cipher_num_bytes:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0)) in let (scratch_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0)) in let (tag_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0)) in Vale.X64.Decls.modifies_mem (Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 iv_b) (Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 scratch_b) (Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 out128x6_b) (Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 out128_b) (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 inout_b))))) (va_get_mem va_s0) (va_get_mem va_sM) /\ cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in let auth_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_s0) auth_b) (Vale.X64.Decls.s128 (va_get_mem va_s0) abytes_b) in let auth_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0 auth_num_bytes in let cipher_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_s0) in128x6_b) (Vale.X64.Decls.s128 (va_get_mem va_s0) in128_b)) (Vale.X64.Decls.s128 (va_get_mem va_s0) inout_b) in let cipher_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads) 0 cipher_num_bytes in let plain_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem va_sM) out128_b)) (Vale.X64.Decls.s128 (va_get_mem va_sM) inout_b) in let plain_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads) 0 cipher_num_bytes in let expected_tag = Vale.Def.Types_s.le_quad32_to_bytes (Vale.X64.Decls.buffer128_read tag_b 0 (va_get_mem va_s0)) in l_and (l_and (l_and (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.nat8 auth_bytes < pow2_32) (FStar.Seq.Base.length #Vale.Def.Types_s.nat8 cipher_bytes < pow2_32)) (Vale.AES.AES_common_s.is_aes_key alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key))) (plain_bytes == __proj__Mktuple2__item___1 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool (Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv cipher_bytes auth_bytes expected_tag))) (va_get_reg64 rRax va_sM = 0 == __proj__Mktuple2__item___2 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool (Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv cipher_bytes auth_bytes expected_tag)) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 /\ (win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\ (win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\ (win ==> va_get_reg64 rRdi va_sM == va_get_reg64 rRdi va_s0) /\ (win ==> va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0) /\ (win ==> va_get_reg64 rR12 va_sM == va_get_reg64 rR12 va_s0) /\ (win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13 va_s0) /\ (win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ (win ==> va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0) /\ (win ==> va_get_xmm 6 va_sM == va_get_xmm 6 va_s0) /\ (win ==> va_get_xmm 7 va_sM == va_get_xmm 7 va_s0) /\ (win ==> va_get_xmm 8 va_sM == va_get_xmm 8 va_s0) /\ (win ==> va_get_xmm 9 va_sM == va_get_xmm 9 va_s0) /\ (win ==> va_get_xmm 10 va_sM == va_get_xmm 10 va_s0) /\ (win ==> va_get_xmm 11 va_sM == va_get_xmm 11 va_s0) /\ (win ==> va_get_xmm 12 va_sM == va_get_xmm 12 va_s0) /\ (win ==> va_get_xmm 13 va_sM == va_get_xmm 13 va_s0) /\ (win ==> va_get_xmm 14 va_sM == va_get_xmm 14 va_s0) /\ (win ==> va_get_xmm 15 va_sM == va_get_xmm 15 va_s0) /\ (~win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\ (~win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\ (~win ==> va_get_reg64 rR12 va_sM == va_get_reg64 rR12 va_s0) /\ (~win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13 va_s0) /\ (~win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ (~win ==> va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0))) /\ va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_flags va_sM (va_update_mem_layout va_sM (va_update_mem_heaplet 6 va_sM (va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm 9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRbp va_sM (va_update_reg64 rRsp va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))))))))))))))))))))))))))))))))))) [@ va_qattr] let va_wp_Gcm_blocks_decrypt_stdcall (win:bool) (alg:algorithm) (auth_b:buffer128) (auth_bytes:nat64) (auth_num:nat64) (keys_b:buffer128) (iv_b:buffer128) (iv:supported_iv_LE) (hkeys_b:buffer128) (abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128) (len128x6_num:nat64) (in128_b:buffer128) (out128_b:buffer128) (len128_num:nat64) (inout_b:buffer128) (cipher_num:nat64) (scratch_b:buffer128) (tag_b:buffer128) (key:(seq nat32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (let (auth_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (auth_num_bytes:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (auth_len:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rR8 va_s0) (fun _ -> va_get_reg64 rRdx va_s0) in let (keys_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rR9 va_s0) (fun _ -> va_get_reg64 rRcx va_s0) in let (iv_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 0) (va_get_stack va_s0)) (fun _ -> va_get_reg64 rR8 va_s0) in let (xip:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 8) (va_get_stack va_s0)) (fun _ -> va_get_reg64 rR9 va_s0) in let (abytes_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 16) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0)) in let (in128x6_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) in let (out128x6_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0)) in let (len128x6:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0)) in let (in128_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 48) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 32) (va_get_stack va_s0)) in let (out128_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0)) in let (len128:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0)) in let (inout_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 72) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 56) (va_get_stack va_s0)) in let (cipher_num_bytes:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0)) in let (scratch_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0)) in let (tag_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0)) in sse_enabled /\ movbe_enabled /\ va_get_reg64 rRsp va_s0 == Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\ Vale.X64.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 32) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 0) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 16) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 48) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 72) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ auth_len == auth_num /\ auth_num_bytes == auth_bytes /\ len128x6 == len128x6_num /\ len128 == len128_num /\ cipher_num_bytes == cipher_num /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) auth_ptr auth_b auth_len (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) abytes_ptr abytes_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) iv_ptr iv_b 1 (va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) in128x6_ptr in128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) in128_ptr in128_b len128 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) inout_ptr inout_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) scratch_ptr scratch_b 9 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) xip hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) tag_ptr tag_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 tag_b ([auth_b; abytes_b; iv_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b; scratch_b]) /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b; scratch_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b; in128_b; out128_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 auth_b ([keys_b; abytes_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 abytes_b ([keys_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b; auth_b; abytes_b; hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 in128x6_b ([keys_b; auth_b; abytes_b; hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; auth_b; abytes_b; hkeys_b; in128x6_b; out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 in128_b ([keys_b; auth_b; abytes_b; hkeys_b; in128x6_b; out128x6_b; inout_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b == out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b) /\ auth_ptr + 16 `op_Multiply` auth_len < pow2_64 /\ in128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\ in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b == auth_len /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\ cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\ xip + 32 < pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\ 12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) <= cipher_num_bytes /\ cipher_num_bytes < va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\ (va_mul_nat auth_len (128 `op_Division` 8) <= auth_num_bytes /\ auth_num_bytes < va_mul_nat auth_len (128 `op_Division` 8) + 128 `op_Division` 8) /\ aes_reqs alg key (Vale.X64.Decls.buffer128_as_seq (va_get_mem va_s0) keys_b) keys_b keys_ptr (va_get_mem va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\ Vale.AES.OptPublic.hkeys_reqs_pub (Vale.X64.Decls.s128 (va_get_mem va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\ (let h_LE = Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) in let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in iv_BE == Vale.AES.GCM_s.compute_iv_BE h_LE iv)) /\ (forall (va_x_mem:vale_heap) (va_x_rax:nat64) (va_x_rbx:nat64) (va_x_rcx:nat64) (va_x_rdx:nat64) (va_x_rdi:nat64) (va_x_rsi:nat64) (va_x_rsp:nat64) (va_x_rbp:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64) (va_x_r11:nat64) (va_x_r12:nat64) (va_x_r13:nat64) (va_x_r14:nat64) (va_x_r15:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32) (va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm9:quad32) (va_x_xmm10:quad32) (va_x_xmm11:quad32) (va_x_xmm12:quad32) (va_x_xmm13:quad32) (va_x_xmm14:quad32) (va_x_xmm15:quad32) (va_x_heap1:vale_heap) (va_x_heap2:vale_heap) (va_x_heap3:vale_heap) (va_x_heap5:vale_heap) (va_x_heap6:vale_heap) (va_x_memLayout:vale_heap_layout) (va_x_efl:Vale.X64.Flags.t) (va_x_stack:vale_stack) (va_x_stackTaint:memtaint) . let va_sM = va_upd_stackTaint va_x_stackTaint (va_upd_stack va_x_stack (va_upd_flags va_x_efl (va_upd_mem_layout va_x_memLayout (va_upd_mem_heaplet 6 va_x_heap6 (va_upd_mem_heaplet 5 va_x_heap5 (va_upd_mem_heaplet 3 va_x_heap3 (va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 15 va_x_xmm15 (va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12 (va_upd_xmm 11 va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR15 va_x_r15 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13 (va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rR10 va_x_r10 (va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRbp va_x_rbp (va_upd_reg64 rRsp va_x_rsp (va_upd_reg64 rRsi va_x_rsi (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRcx va_x_rcx (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem va_s0))))))))))))))))))))))))))))))))))))))))) in va_get_ok va_sM /\ (let (auth_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let (auth_num_bytes:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (auth_len:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rR8 va_s0) (fun _ -> va_get_reg64 rRdx va_s0) in let (keys_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rR9 va_s0) (fun _ -> va_get_reg64 rRcx va_s0) in let (iv_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 0) (va_get_stack va_s0)) (fun _ -> va_get_reg64 rR8 va_s0) in let (xip:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 8) (va_get_stack va_s0)) (fun _ -> va_get_reg64 rR9 va_s0) in let (abytes_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 16) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0)) in let (in128x6_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) in let (out128x6_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0)) in let (len128x6:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0)) in let (in128_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 48) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 32) (va_get_stack va_s0)) in let (out128_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0)) in let (len128:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0)) in let (inout_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 72) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 56) (va_get_stack va_s0)) in let (cipher_num_bytes:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0)) in let (scratch_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0)) in let (tag_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0)) in Vale.X64.Decls.modifies_mem (Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 iv_b) (Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 scratch_b) (Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 out128x6_b) (Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 out128_b) (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 inout_b))))) (va_get_mem va_s0) (va_get_mem va_sM) /\ cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in let auth_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_s0) auth_b) (Vale.X64.Decls.s128 (va_get_mem va_s0) abytes_b) in let auth_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0 auth_num_bytes in let cipher_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_s0) in128x6_b) (Vale.X64.Decls.s128 (va_get_mem va_s0) in128_b)) (Vale.X64.Decls.s128 (va_get_mem va_s0) inout_b) in let cipher_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads) 0 cipher_num_bytes in let plain_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem va_sM) out128_b)) (Vale.X64.Decls.s128 (va_get_mem va_sM) inout_b) in let plain_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads) 0 cipher_num_bytes in let expected_tag = Vale.Def.Types_s.le_quad32_to_bytes (Vale.X64.Decls.buffer128_read tag_b 0 (va_get_mem va_s0)) in l_and (l_and (l_and (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.nat8 auth_bytes < pow2_32) (FStar.Seq.Base.length #Vale.Def.Types_s.nat8 cipher_bytes < pow2_32)) (Vale.AES.AES_common_s.is_aes_key alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key))) (plain_bytes == __proj__Mktuple2__item___1 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool (Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv cipher_bytes auth_bytes expected_tag))) (va_get_reg64 rRax va_sM = 0 == __proj__Mktuple2__item___2 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool (Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv cipher_bytes auth_bytes expected_tag)) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 /\ (win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\ (win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\ (win ==> va_get_reg64 rRdi va_sM == va_get_reg64 rRdi va_s0) /\ (win ==> va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0) /\ (win ==> va_get_reg64 rR12 va_sM == va_get_reg64 rR12 va_s0) /\ (win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13 va_s0) /\ (win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ (win ==> va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0) /\ (win ==> va_get_xmm 6 va_sM == va_get_xmm 6 va_s0) /\ (win ==> va_get_xmm 7 va_sM == va_get_xmm 7 va_s0) /\ (win ==> va_get_xmm 8 va_sM == va_get_xmm 8 va_s0) /\ (win ==> va_get_xmm 9 va_sM == va_get_xmm 9 va_s0) /\ (win ==> va_get_xmm 10 va_sM == va_get_xmm 10 va_s0) /\ (win ==> va_get_xmm 11 va_sM == va_get_xmm 11 va_s0) /\ (win ==> va_get_xmm 12 va_sM == va_get_xmm 12 va_s0) /\ (win ==> va_get_xmm 13 va_sM == va_get_xmm 13 va_s0) /\ (win ==> va_get_xmm 14 va_sM == va_get_xmm 14 va_s0) /\ (win ==> va_get_xmm 15 va_sM == va_get_xmm 15 va_s0) /\ (~win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\ (~win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\ (~win ==> va_get_reg64 rR12 va_sM == va_get_reg64 rR12 va_s0) /\ (~win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13 va_s0) /\ (~win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ (~win ==> va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0))) ==> va_k va_sM (()))) val va_wpProof_Gcm_blocks_decrypt_stdcall : win:bool -> alg:algorithm -> auth_b:buffer128 -> auth_bytes:nat64 -> auth_num:nat64 -> keys_b:buffer128 -> iv_b:buffer128 -> iv:supported_iv_LE -> hkeys_b:buffer128 -> abytes_b:buffer128 -> in128x6_b:buffer128 -> out128x6_b:buffer128 -> len128x6_num:nat64 -> in128_b:buffer128 -> out128_b:buffer128 -> len128_num:nat64 -> inout_b:buffer128 -> cipher_num:nat64 -> scratch_b:buffer128 -> tag_b:buffer128 -> key:(seq nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Gcm_blocks_decrypt_stdcall win alg auth_b auth_bytes auth_num keys_b iv_b iv hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b key va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks_decrypt_stdcall win alg) ([va_Mod_stackTaint; va_Mod_stack; va_Mod_flags; va_Mod_mem_layout; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_i.fsti.checked", "Vale.X64.Stack.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsStack.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Poly1305.Math.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Lib.Meta.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.AES.X64.GHash.fsti.checked", "Vale.AES.X64.GF128_Mul.fsti.checked", "Vale.AES.X64.GCTR.fsti.checked", "Vale.AES.X64.GCMencryptOpt.fsti.checked", "Vale.AES.X64.AESopt2.fsti.checked", "Vale.AES.X64.AESopt.fsti.checked", "Vale.AES.X64.AESGCM.fsti.checked", "Vale.AES.X64.AES.fsti.checked", "Vale.AES.OptPublic.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCTR.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.GCM.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.AES.X64.GCMdecryptOpt.fsti" }
[ { "abbrev": false, "full_module": "Vale.Lib.Basic", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.OptPublic", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCMencryptOpt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt2", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESGCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.OptPublic", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCMencryptOpt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt2", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESGCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
win: Prims.bool -> alg: Vale.AES.AES_common_s.algorithm -> auth_b: Vale.X64.Memory.buffer128 -> auth_bytes: Vale.X64.Memory.nat64 -> auth_num: Vale.X64.Memory.nat64 -> keys_b: Vale.X64.Memory.buffer128 -> iv_b: Vale.X64.Memory.buffer128 -> iv: Vale.AES.GCM_s.supported_iv_LE -> hkeys_b: Vale.X64.Memory.buffer128 -> abytes_b: Vale.X64.Memory.buffer128 -> in128x6_b: Vale.X64.Memory.buffer128 -> out128x6_b: Vale.X64.Memory.buffer128 -> len128x6_num: Vale.X64.Memory.nat64 -> in128_b: Vale.X64.Memory.buffer128 -> out128_b: Vale.X64.Memory.buffer128 -> len128_num: Vale.X64.Memory.nat64 -> inout_b: Vale.X64.Memory.buffer128 -> cipher_num: Vale.X64.Memory.nat64 -> scratch_b: Vale.X64.Memory.buffer128 -> tag_b: Vale.X64.Memory.buffer128 -> key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.AES.X64.GCMdecryptOpt.va_code_Gcm_blocks_decrypt_stdcall win alg)
Prims.Tot
[ "total" ]
[]
[ "Prims.bool", "Vale.AES.AES_common_s.algorithm", "Vale.X64.Memory.buffer128", "Vale.X64.Memory.nat64", "Vale.AES.GCM_s.supported_iv_LE", "FStar.Seq.Base.seq", "Vale.X64.Memory.nat32", "Vale.X64.QuickCode.va_QProc", "Prims.unit", "Vale.AES.X64.GCMdecryptOpt.va_code_Gcm_blocks_decrypt_stdcall", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_stackTaint", "Vale.X64.QuickCode.va_Mod_stack", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_Mod_mem_layout", "Vale.X64.QuickCode.va_Mod_mem_heaplet", "Vale.X64.QuickCode.va_Mod_xmm", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rR15", "Vale.X64.Machine_s.rR14", "Vale.X64.Machine_s.rR13", "Vale.X64.Machine_s.rR12", "Vale.X64.Machine_s.rR11", "Vale.X64.Machine_s.rR10", "Vale.X64.Machine_s.rR9", "Vale.X64.Machine_s.rR8", "Vale.X64.Machine_s.rRbp", "Vale.X64.Machine_s.rRsp", "Vale.X64.Machine_s.rRsi", "Vale.X64.Machine_s.rRdi", "Vale.X64.Machine_s.rRdx", "Vale.X64.Machine_s.rRcx", "Vale.X64.Machine_s.rRbx", "Vale.X64.Machine_s.rRax", "Vale.X64.QuickCode.va_Mod_mem", "Prims.Nil", "Vale.AES.X64.GCMdecryptOpt.va_wp_Gcm_blocks_decrypt_stdcall", "Vale.AES.X64.GCMdecryptOpt.va_wpProof_Gcm_blocks_decrypt_stdcall", "Vale.X64.QuickCode.va_quickCode" ]
[]
false
false
false
false
false
let va_quick_Gcm_blocks_decrypt_stdcall (win: bool) (alg: algorithm) (auth_b: buffer128) (auth_bytes auth_num: nat64) (keys_b iv_b: buffer128) (iv: supported_iv_LE) (hkeys_b abytes_b in128x6_b out128x6_b: buffer128) (len128x6_num: nat64) (in128_b out128_b: buffer128) (len128_num: nat64) (inout_b: buffer128) (cipher_num: nat64) (scratch_b tag_b: buffer128) (key: (seq nat32)) : (va_quickCode unit (va_code_Gcm_blocks_decrypt_stdcall win alg)) =
(va_QProc (va_code_Gcm_blocks_decrypt_stdcall win alg) ([ va_Mod_stackTaint; va_Mod_stack; va_Mod_flags; va_Mod_mem_layout; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem ]) (va_wp_Gcm_blocks_decrypt_stdcall win alg auth_b auth_bytes auth_num keys_b iv_b iv hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b key) (va_wpProof_Gcm_blocks_decrypt_stdcall win alg auth_b auth_bytes auth_num keys_b iv_b iv hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b key))
false
Vale.AES.X64.GCMdecryptOpt.fsti
Vale.AES.X64.GCMdecryptOpt.va_ens_Gcm_blocks_decrypt_stdcall
val va_ens_Gcm_blocks_decrypt_stdcall (va_b0: va_code) (va_s0: va_state) (win: bool) (alg: algorithm) (auth_b: buffer128) (auth_bytes auth_num: nat64) (keys_b iv_b: buffer128) (iv: supported_iv_LE) (hkeys_b abytes_b in128x6_b out128x6_b: buffer128) (len128x6_num: nat64) (in128_b out128_b: buffer128) (len128_num: nat64) (inout_b: buffer128) (cipher_num: nat64) (scratch_b tag_b: buffer128) (key: (seq nat32)) (va_sM: va_state) (va_fM: va_fuel) : prop
val va_ens_Gcm_blocks_decrypt_stdcall (va_b0: va_code) (va_s0: va_state) (win: bool) (alg: algorithm) (auth_b: buffer128) (auth_bytes auth_num: nat64) (keys_b iv_b: buffer128) (iv: supported_iv_LE) (hkeys_b abytes_b in128x6_b out128x6_b: buffer128) (len128x6_num: nat64) (in128_b out128_b: buffer128) (len128_num: nat64) (inout_b: buffer128) (cipher_num: nat64) (scratch_b tag_b: buffer128) (key: (seq nat32)) (va_sM: va_state) (va_fM: va_fuel) : prop
let va_ens_Gcm_blocks_decrypt_stdcall (va_b0:va_code) (va_s0:va_state) (win:bool) (alg:algorithm) (auth_b:buffer128) (auth_bytes:nat64) (auth_num:nat64) (keys_b:buffer128) (iv_b:buffer128) (iv:supported_iv_LE) (hkeys_b:buffer128) (abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128) (len128x6_num:nat64) (in128_b:buffer128) (out128_b:buffer128) (len128_num:nat64) (inout_b:buffer128) (cipher_num:nat64) (scratch_b:buffer128) (tag_b:buffer128) (key:(seq nat32)) (va_sM:va_state) (va_fM:va_fuel) : prop = (va_req_Gcm_blocks_decrypt_stdcall va_b0 va_s0 win alg auth_b auth_bytes auth_num keys_b iv_b iv hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b key /\ va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (auth_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0 else va_get_reg64 rRdi va_s0) in let (auth_num_bytes:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let (auth_len:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR8 va_s0 else va_get_reg64 rRdx va_s0) in let (keys_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR9 va_s0 else va_get_reg64 rRcx va_s0) in let (iv_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 0) (va_get_stack va_s0) else va_get_reg64 rR8 va_s0) in let (xip:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 8) (va_get_stack va_s0) else va_get_reg64 rR9 va_s0) in let (abytes_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 16) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0)) in let (in128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) in let (out128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0)) in let (len128x6:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0)) in let (in128_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 48) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 32) (va_get_stack va_s0)) in let (out128_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0)) in let (len128:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0)) in let (inout_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 72) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 56) (va_get_stack va_s0)) in let (cipher_num_bytes:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0)) in let (scratch_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0)) in let (tag_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0)) in Vale.X64.Decls.modifies_mem (Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 iv_b) (Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 scratch_b) (Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 out128x6_b) (Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 out128_b) (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 inout_b))))) (va_get_mem va_s0) (va_get_mem va_sM) /\ cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in let auth_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_s0) auth_b) (Vale.X64.Decls.s128 (va_get_mem va_s0) abytes_b) in let auth_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0 auth_num_bytes in let cipher_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_s0) in128x6_b) (Vale.X64.Decls.s128 (va_get_mem va_s0) in128_b)) (Vale.X64.Decls.s128 (va_get_mem va_s0) inout_b) in let cipher_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads) 0 cipher_num_bytes in let plain_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem va_sM) out128_b)) (Vale.X64.Decls.s128 (va_get_mem va_sM) inout_b) in let plain_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads) 0 cipher_num_bytes in let expected_tag = Vale.Def.Types_s.le_quad32_to_bytes (Vale.X64.Decls.buffer128_read tag_b 0 (va_get_mem va_s0)) in l_and (l_and (l_and (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.nat8 auth_bytes < pow2_32) (FStar.Seq.Base.length #Vale.Def.Types_s.nat8 cipher_bytes < pow2_32)) (Vale.AES.AES_common_s.is_aes_key alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key))) (plain_bytes == __proj__Mktuple2__item___1 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool (Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv cipher_bytes auth_bytes expected_tag))) (va_get_reg64 rRax va_sM = 0 == __proj__Mktuple2__item___2 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool (Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv cipher_bytes auth_bytes expected_tag)) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 /\ (win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\ (win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\ (win ==> va_get_reg64 rRdi va_sM == va_get_reg64 rRdi va_s0) /\ (win ==> va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0) /\ (win ==> va_get_reg64 rR12 va_sM == va_get_reg64 rR12 va_s0) /\ (win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13 va_s0) /\ (win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ (win ==> va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0) /\ (win ==> va_get_xmm 6 va_sM == va_get_xmm 6 va_s0) /\ (win ==> va_get_xmm 7 va_sM == va_get_xmm 7 va_s0) /\ (win ==> va_get_xmm 8 va_sM == va_get_xmm 8 va_s0) /\ (win ==> va_get_xmm 9 va_sM == va_get_xmm 9 va_s0) /\ (win ==> va_get_xmm 10 va_sM == va_get_xmm 10 va_s0) /\ (win ==> va_get_xmm 11 va_sM == va_get_xmm 11 va_s0) /\ (win ==> va_get_xmm 12 va_sM == va_get_xmm 12 va_s0) /\ (win ==> va_get_xmm 13 va_sM == va_get_xmm 13 va_s0) /\ (win ==> va_get_xmm 14 va_sM == va_get_xmm 14 va_s0) /\ (win ==> va_get_xmm 15 va_sM == va_get_xmm 15 va_s0) /\ (~win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\ (~win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\ (~win ==> va_get_reg64 rR12 va_sM == va_get_reg64 rR12 va_s0) /\ (~win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13 va_s0) /\ (~win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ (~win ==> va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0))) /\ va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_flags va_sM (va_update_mem_layout va_sM (va_update_mem_heaplet 6 va_sM (va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm 9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRbp va_sM (va_update_reg64 rRsp va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))))))))))))))))))))))))))))))))))
{ "file_name": "obj/Vale.AES.X64.GCMdecryptOpt.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 94, "end_line": 311, "start_col": 0, "start_line": 204 }
module Vale.AES.X64.GCMdecryptOpt open Vale.Def.Prop_s open Vale.Def.Opaque_s open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.Arch.HeapImpl open Vale.AES.AES_s open Vale.AES.GCTR_s open Vale.AES.GCTR open Vale.AES.GCM open Vale.AES.GHash_s open Vale.AES.GHash open Vale.AES.GCM_s open Vale.AES.X64.AES open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.Poly1305.Math open Vale.AES.GCM_helpers open Vale.AES.X64.GHash open Vale.AES.X64.GCTR open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsStack open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.AES.X64.GF128_Mul open Vale.X64.Stack open Vale.X64.CPU_Features_s open Vale.Math.Poly2.Bits_s open Vale.AES.X64.AESopt open Vale.AES.X64.AESGCM open Vale.AES.X64.AESopt2 open Vale.Lib.Meta open Vale.AES.X64.GCMencryptOpt open Vale.AES.OptPublic let aes_reqs (alg:algorithm) (key:seq nat32) (round_keys:seq quad32) (keys_b:buffer128) (key_ptr:int) (heap0:vale_heap) (layout:vale_heap_layout) : prop0 = aesni_enabled /\ avx_enabled /\ (alg = AES_128 \/ alg = AES_256) /\ is_aes_key_LE alg key /\ length(round_keys) == nr(alg) + 1 /\ round_keys == key_to_round_keys_LE alg key /\ validSrcAddrs128 heap0 key_ptr keys_b (nr alg + 1) layout Secret /\ s128 heap0 keys_b == round_keys #reset-options "--z3rlimit 100 --max_ifuel 0" //-- Gcm_blocks_decrypt_stdcall val va_code_Gcm_blocks_decrypt_stdcall : win:bool -> alg:algorithm -> Tot va_code val va_codegen_success_Gcm_blocks_decrypt_stdcall : win:bool -> alg:algorithm -> Tot va_pbool let va_req_Gcm_blocks_decrypt_stdcall (va_b0:va_code) (va_s0:va_state) (win:bool) (alg:algorithm) (auth_b:buffer128) (auth_bytes:nat64) (auth_num:nat64) (keys_b:buffer128) (iv_b:buffer128) (iv:supported_iv_LE) (hkeys_b:buffer128) (abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128) (len128x6_num:nat64) (in128_b:buffer128) (out128_b:buffer128) (len128_num:nat64) (inout_b:buffer128) (cipher_num:nat64) (scratch_b:buffer128) (tag_b:buffer128) (key:(seq nat32)) : prop = (va_require_total va_b0 (va_code_Gcm_blocks_decrypt_stdcall win alg) va_s0 /\ va_get_ok va_s0 /\ (let (auth_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRcx va_s0 else va_get_reg64 rRdi va_s0) in let (auth_num_bytes:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let (auth_len:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR8 va_s0 else va_get_reg64 rRdx va_s0) in let (keys_ptr:(va_int_range 0 18446744073709551615)) = (if win then va_get_reg64 rR9 va_s0 else va_get_reg64 rRcx va_s0) in let (iv_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 0) (va_get_stack va_s0) else va_get_reg64 rR8 va_s0) in let (xip:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 8) (va_get_stack va_s0) else va_get_reg64 rR9 va_s0) in let (abytes_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 16) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0)) in let (in128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) in let (out128x6_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0)) in let (len128x6:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0)) in let (in128_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 48) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 32) (va_get_stack va_s0)) in let (out128_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0)) in let (len128:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0)) in let (inout_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 72) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 56) (va_get_stack va_s0)) in let (cipher_num_bytes:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0)) in let (scratch_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0)) in let (tag_ptr:(va_int_range 0 18446744073709551615)) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0)) in sse_enabled /\ movbe_enabled /\ va_get_reg64 rRsp va_s0 == Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\ Vale.X64.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 32) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (~win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 0) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 16) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 48) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 72) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ (win ==> Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) Public (va_get_stackTaint va_s0)) /\ auth_len == auth_num /\ auth_num_bytes == auth_bytes /\ len128x6 == len128x6_num /\ len128 == len128_num /\ cipher_num_bytes == cipher_num /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) auth_ptr auth_b auth_len (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) abytes_ptr abytes_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) iv_ptr iv_b 1 (va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) in128x6_ptr in128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) in128_ptr in128_b len128 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) inout_ptr inout_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) scratch_ptr scratch_b 9 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem va_s0) xip hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem va_s0) tag_ptr tag_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 tag_b ([auth_b; abytes_b; iv_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b; scratch_b]) /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b; scratch_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; auth_b; abytes_b; in128x6_b; out128x6_b; in128_b; out128_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 auth_b ([keys_b; abytes_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 abytes_b ([keys_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b; auth_b; abytes_b; hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 in128x6_b ([keys_b; auth_b; abytes_b; hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; auth_b; abytes_b; hkeys_b; in128x6_b; out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 in128_b ([keys_b; auth_b; abytes_b; hkeys_b; in128x6_b; out128x6_b; inout_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b == out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b) /\ auth_ptr + 16 `op_Multiply` auth_len < pow2_64 /\ in128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\ in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b == auth_len /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\ cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\ xip + 32 < pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\ 12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) <= cipher_num_bytes /\ cipher_num_bytes < va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\ (va_mul_nat auth_len (128 `op_Division` 8) <= auth_num_bytes /\ auth_num_bytes < va_mul_nat auth_len (128 `op_Division` 8) + 128 `op_Division` 8) /\ aes_reqs alg key (Vale.X64.Decls.buffer128_as_seq (va_get_mem va_s0) keys_b) keys_b keys_ptr (va_get_mem va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\ Vale.AES.OptPublic.hkeys_reqs_pub (Vale.X64.Decls.s128 (va_get_mem va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\ (let h_LE = Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) in let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in iv_BE ==
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_i.fsti.checked", "Vale.X64.Stack.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsStack.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Poly1305.Math.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Lib.Meta.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.AES.X64.GHash.fsti.checked", "Vale.AES.X64.GF128_Mul.fsti.checked", "Vale.AES.X64.GCTR.fsti.checked", "Vale.AES.X64.GCMencryptOpt.fsti.checked", "Vale.AES.X64.AESopt2.fsti.checked", "Vale.AES.X64.AESopt.fsti.checked", "Vale.AES.X64.AESGCM.fsti.checked", "Vale.AES.X64.AES.fsti.checked", "Vale.AES.OptPublic.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCTR.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.GCM.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.AES.X64.GCMdecryptOpt.fsti" }
[ { "abbrev": false, "full_module": "Vale.Lib.Basic", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.OptPublic", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCMencryptOpt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt2", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESGCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.OptPublic", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCMencryptOpt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt2", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESGCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> win: Prims.bool -> alg: Vale.AES.AES_common_s.algorithm -> auth_b: Vale.X64.Memory.buffer128 -> auth_bytes: Vale.X64.Memory.nat64 -> auth_num: Vale.X64.Memory.nat64 -> keys_b: Vale.X64.Memory.buffer128 -> iv_b: Vale.X64.Memory.buffer128 -> iv: Vale.AES.GCM_s.supported_iv_LE -> hkeys_b: Vale.X64.Memory.buffer128 -> abytes_b: Vale.X64.Memory.buffer128 -> in128x6_b: Vale.X64.Memory.buffer128 -> out128x6_b: Vale.X64.Memory.buffer128 -> len128x6_num: Vale.X64.Memory.nat64 -> in128_b: Vale.X64.Memory.buffer128 -> out128_b: Vale.X64.Memory.buffer128 -> len128_num: Vale.X64.Memory.nat64 -> inout_b: Vale.X64.Memory.buffer128 -> cipher_num: Vale.X64.Memory.nat64 -> scratch_b: Vale.X64.Memory.buffer128 -> tag_b: Vale.X64.Memory.buffer128 -> key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 -> va_sM: Vale.X64.Decls.va_state -> va_fM: Vale.X64.Decls.va_fuel -> Prims.prop
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Prims.bool", "Vale.AES.AES_common_s.algorithm", "Vale.X64.Memory.buffer128", "Vale.X64.Memory.nat64", "Vale.AES.GCM_s.supported_iv_LE", "FStar.Seq.Base.seq", "Vale.X64.Memory.nat32", "Vale.X64.Decls.va_fuel", "Prims.l_and", "Vale.AES.X64.GCMdecryptOpt.va_req_Gcm_blocks_decrypt_stdcall", "Vale.X64.Decls.va_ensure_total", "Prims.b2t", "Vale.X64.Decls.va_get_ok", "Vale.X64.Decls.modifies_mem", "Vale.X64.Decls.loc_union", "Vale.X64.Decls.loc_buffer", "Vale.X64.Memory.vuint128", "Vale.X64.Decls.va_get_mem", "Prims.op_LessThan", "Vale.X64.Machine_s.pow2_32", "FStar.Seq.Base.length", "Vale.Def.Types_s.nat8", "Vale.AES.AES_common_s.is_aes_key", "Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE", "Prims.eq2", "FStar.Pervasives.Native.__proj__Mktuple2__item___1", "Vale.AES.GCM_s.gcm_decrypt_LE", "Prims.op_Equality", "Prims.int", "Vale.X64.Decls.va_get_reg64", "Vale.X64.Machine_s.rRax", "FStar.Pervasives.Native.__proj__Mktuple2__item___2", "Vale.Def.Types_s.nat64", "Vale.X64.Machine_s.rRsp", "Prims.l_imp", "Vale.X64.Machine_s.rRbx", "Vale.X64.Machine_s.rRbp", "Vale.X64.Machine_s.rRdi", "Vale.X64.Machine_s.rRsi", "Vale.X64.Machine_s.rR12", "Vale.X64.Machine_s.rR13", "Vale.X64.Machine_s.rR14", "Vale.X64.Machine_s.rR15", "Vale.X64.Decls.quad32", "Vale.X64.Decls.va_get_xmm", "Prims.l_not", "Vale.Def.Words_s.nat8", "Vale.Def.Types_s.le_quad32_to_bytes", "Vale.X64.Decls.buffer128_read", "FStar.Seq.Base.slice", "Vale.Def.Types_s.le_seq_quad32_to_bytes", "Vale.Def.Types_s.quad32", "FStar.Seq.Base.append", "Vale.X64.Decls.s128", "Vale.X64.Decls.va_int_range", "Vale.X64.Stack_i.load_stack64", "Prims.op_Addition", "Vale.X64.Decls.va_get_stack", "Vale.X64.Machine_s.rR9", "Vale.X64.Machine_s.rR8", "Vale.X64.Machine_s.rRcx", "Vale.X64.Machine_s.rRdx", "Vale.X64.Decls.va_state_eq", "Vale.X64.Decls.va_update_stackTaint", "Vale.X64.Decls.va_update_stack", "Vale.X64.Decls.va_update_flags", "Vale.X64.Decls.va_update_mem_layout", "Vale.X64.Decls.va_update_mem_heaplet", "Vale.X64.Decls.va_update_xmm", "Vale.X64.Decls.va_update_reg64", "Vale.X64.Machine_s.rR11", "Vale.X64.Machine_s.rR10", "Vale.X64.Decls.va_update_ok", "Vale.X64.Decls.va_update_mem", "Prims.prop" ]
[]
false
false
false
true
true
let va_ens_Gcm_blocks_decrypt_stdcall (va_b0: va_code) (va_s0: va_state) (win: bool) (alg: algorithm) (auth_b: buffer128) (auth_bytes auth_num: nat64) (keys_b iv_b: buffer128) (iv: supported_iv_LE) (hkeys_b abytes_b in128x6_b out128x6_b: buffer128) (len128x6_num: nat64) (in128_b out128_b: buffer128) (len128_num: nat64) (inout_b: buffer128) (cipher_num: nat64) (scratch_b tag_b: buffer128) (key: (seq nat32)) (va_sM: va_state) (va_fM: va_fuel) : prop =
(va_req_Gcm_blocks_decrypt_stdcall va_b0 va_s0 win alg auth_b auth_bytes auth_num keys_b iv_b iv hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b key /\ va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let auth_ptr:(va_int_range 0 18446744073709551615) = (if win then va_get_reg64 rRcx va_s0 else va_get_reg64 rRdi va_s0) in let auth_num_bytes:(va_int_range 0 18446744073709551615) = (if win then va_get_reg64 rRdx va_s0 else va_get_reg64 rRsi va_s0) in let auth_len:(va_int_range 0 18446744073709551615) = (if win then va_get_reg64 rR8 va_s0 else va_get_reg64 rRdx va_s0) in let keys_ptr:(va_int_range 0 18446744073709551615) = (if win then va_get_reg64 rR9 va_s0 else va_get_reg64 rRcx va_s0) in let iv_ptr:(va_int_range 0 18446744073709551615) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 0) (va_get_stack va_s0) else va_get_reg64 rR8 va_s0) in let xip:(va_int_range 0 18446744073709551615) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 32 + 8 + 8) (va_get_stack va_s0) else va_get_reg64 rR9 va_s0) in let abytes_ptr:(va_int_range 0 18446744073709551615) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 16) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0)) in let in128x6_ptr:(va_int_range 0 18446744073709551615) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) in let out128x6_ptr:(va_int_range 0 18446744073709551615) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0)) in let len128x6:(va_int_range 0 18446744073709551615) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0)) in let in128_ptr:(va_int_range 0 18446744073709551615) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 48) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 32) (va_get_stack va_s0)) in let out128_ptr:(va_int_range 0 18446744073709551615) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0)) in let len128:(va_int_range 0 18446744073709551615) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0)) in let inout_ptr:(va_int_range 0 18446744073709551615) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 72) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 56) (va_get_stack va_s0)) in let cipher_num_bytes:(va_int_range 0 18446744073709551615) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0)) in let scratch_ptr:(va_int_range 0 18446744073709551615) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0)) in let tag_ptr:(va_int_range 0 18446744073709551615) = (if win then Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0) else Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0)) in Vale.X64.Decls.modifies_mem (Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 iv_b) (Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 scratch_b) (Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 out128x6_b) (Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 out128_b) (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128 inout_b))))) (va_get_mem va_s0) (va_get_mem va_sM) /\ cipher_num_bytes < pow2_32 /\ auth_num_bytes < pow2_32 /\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in let auth_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_s0) auth_b) (Vale.X64.Decls.s128 (va_get_mem va_s0) abytes_b) in let auth_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0 auth_num_bytes in let cipher_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_s0) in128x6_b) (Vale.X64.Decls.s128 (va_get_mem va_s0) in128_b)) (Vale.X64.Decls.s128 (va_get_mem va_s0) inout_b) in let cipher_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads) 0 cipher_num_bytes in let plain_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem va_sM) out128_b)) (Vale.X64.Decls.s128 (va_get_mem va_sM) inout_b) in let plain_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads) 0 cipher_num_bytes in let expected_tag = Vale.Def.Types_s.le_quad32_to_bytes (Vale.X64.Decls.buffer128_read tag_b 0 (va_get_mem va_s0)) in l_and (l_and (l_and (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.nat8 auth_bytes < pow2_32) (FStar.Seq.Base.length #Vale.Def.Types_s.nat8 cipher_bytes < pow2_32)) (Vale.AES.AES_common_s.is_aes_key alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key))) (plain_bytes == __proj__Mktuple2__item___1 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool (Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv cipher_bytes auth_bytes expected_tag))) (va_get_reg64 rRax va_sM = 0 == __proj__Mktuple2__item___2 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool (Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv cipher_bytes auth_bytes expected_tag)) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 /\ (win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\ (win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\ (win ==> va_get_reg64 rRdi va_sM == va_get_reg64 rRdi va_s0) /\ (win ==> va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0) /\ (win ==> va_get_reg64 rR12 va_sM == va_get_reg64 rR12 va_s0) /\ (win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13 va_s0) /\ (win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ (win ==> va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0) /\ (win ==> va_get_xmm 6 va_sM == va_get_xmm 6 va_s0) /\ (win ==> va_get_xmm 7 va_sM == va_get_xmm 7 va_s0) /\ (win ==> va_get_xmm 8 va_sM == va_get_xmm 8 va_s0) /\ (win ==> va_get_xmm 9 va_sM == va_get_xmm 9 va_s0) /\ (win ==> va_get_xmm 10 va_sM == va_get_xmm 10 va_s0) /\ (win ==> va_get_xmm 11 va_sM == va_get_xmm 11 va_s0) /\ (win ==> va_get_xmm 12 va_sM == va_get_xmm 12 va_s0) /\ (win ==> va_get_xmm 13 va_sM == va_get_xmm 13 va_s0) /\ (win ==> va_get_xmm 14 va_sM == va_get_xmm 14 va_s0) /\ (win ==> va_get_xmm 15 va_sM == va_get_xmm 15 va_s0) /\ (~win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\ (~win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\ (~win ==> va_get_reg64 rR12 va_sM == va_get_reg64 rR12 va_s0) /\ (~win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13 va_s0) /\ (~win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ (~win ==> va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0))) /\ va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_flags va_sM (va_update_mem_layout va_sM (va_update_mem_heaplet 6 va_sM (va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm 9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM ( va_update_xmm 0 va_sM ( va_update_reg64 rR15 va_sM ( va_update_reg64 rR14 va_sM ( va_update_reg64 rR13 va_sM ( va_update_reg64 rR12 va_sM ( va_update_reg64 rR11 va_sM ( va_update_reg64 rR10 va_sM ( va_update_reg64 rR9 va_sM ( va_update_reg64 rR8 va_sM ( va_update_reg64 rRbp va_sM ( va_update_reg64 rRsp va_sM ( va_update_reg64 rRsi va_sM ( va_update_reg64 rRdi va_sM ( va_update_reg64 rRdx va_sM ( va_update_reg64 rRcx va_sM ( va_update_reg64 rRbx va_sM ( va_update_reg64 rRax va_sM ( va_update_ok va_sM ( va_update_mem va_sM va_s0 ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )) )))))))))))) )))))))))))
false
MerkleTree.Low.Datastructures.fst
MerkleTree.Low.Datastructures.hash_region_of
val hash_region_of: #hsz:hash_size_t -> v:hash #hsz -> GTot HH.rid
val hash_region_of: #hsz:hash_size_t -> v:hash #hsz -> GTot HH.rid
let hash_region_of #_ v = B.frameOf v
{ "file_name": "src/MerkleTree.Low.Datastructures.fst", "git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6", "git_url": "https://github.com/hacl-star/merkle-tree.git", "project_name": "merkle-tree" }
{ "end_col": 37, "end_line": 52, "start_col": 0, "start_line": 52 }
module MerkleTree.Low.Datastructures open FStar.All open FStar.Integers open FStar.Mul open LowStar.Buffer open LowStar.BufferOps open LowStar.Vector open LowStar.Regional open LowStar.RVector open LowStar.Regional.Instances module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module MHS = FStar.Monotonic.HyperStack module HH = FStar.Monotonic.HyperHeap module B = LowStar.Buffer module CB = LowStar.ConstBuffer module V = LowStar.Vector module RV = LowStar.RVector module RVI = LowStar.Regional.Instances module S = FStar.Seq module EHS = EverCrypt.Hash module U32 = FStar.UInt32 module MTH = MerkleTree.New.High open EverCrypt.Helpers open Lib.IntTypes #set-options "--z3rlimit 10 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0" type hash_size_t = n:uint32_t{n > 0ul} type hash (#hsz:hash_size_t) = b:B.buffer uint8 { B.len b = hsz \/ B.g_is_null b } // We cannot use `Low.RVector.Instances`, where we have some general // typeclass instances of `regional`, e.g., if `rg:regional a` then // `regional (rvector rg)`. In FStar we can use this, but KaRaMeL currently // cannot deal with this and gives a number of errors. // So we temporarily instantiate some `regional`s manually below, which is // extractable to C by KaRaMeL. /// Some instantiations of `regional` used in Merkle tree /// 1. `hash` is regional private noextract
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "MerkleTree.New.High.fst.checked", "LowStar.Vector.fst.checked", "LowStar.RVector.fst.checked", "LowStar.Regional.Instances.fst.checked", "LowStar.Regional.fst.checked", "LowStar.ConstBuffer.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Monotonic.HyperStack.fsti.checked", "FStar.Monotonic.HyperHeap.fsti.checked", "FStar.Map.fsti.checked", "FStar.Integers.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.All.fst.checked", "EverCrypt.Helpers.fsti.checked", "EverCrypt.Hash.fsti.checked" ], "interface_file": false, "source_file": "MerkleTree.Low.Datastructures.fst" }
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "EverCrypt.Helpers", "short_module": null }, { "abbrev": true, "full_module": "MerkleTree.New.High", "short_module": "MTH" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "EverCrypt.Hash", "short_module": "EHS" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Regional.Instances", "short_module": "RVI" }, { "abbrev": true, "full_module": "LowStar.RVector", "short_module": "RV" }, { "abbrev": true, "full_module": "LowStar.Vector", "short_module": "V" }, { "abbrev": true, "full_module": "LowStar.ConstBuffer", "short_module": "CB" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperHeap", "short_module": "HH" }, { "abbrev": true, "full_module": "FStar.Monotonic.HyperStack", "short_module": "MHS" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowStar.Regional.Instances", "short_module": null }, { "abbrev": false, "full_module": "LowStar.RVector", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Regional", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Vector", "short_module": null }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Integers", "short_module": null }, { "abbrev": false, "full_module": "FStar.All", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree.Low", "short_module": null }, { "abbrev": false, "full_module": "MerkleTree.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
v: MerkleTree.Low.Datastructures.hash -> Prims.GTot FStar.Monotonic.HyperHeap.rid
Prims.GTot
[ "sometrivial" ]
[]
[ "MerkleTree.Low.Datastructures.hash_size_t", "MerkleTree.Low.Datastructures.hash", "LowStar.Monotonic.Buffer.frameOf", "Lib.IntTypes.uint8", "LowStar.Buffer.trivial_preorder", "FStar.Monotonic.HyperHeap.rid" ]
[]
false
false
false
false
false
let hash_region_of #_ v =
B.frameOf v
false
Hacl.Impl.K256.PointDouble.fst
Hacl.Impl.K256.PointDouble.calc_z3
val calc_z3 (y1 z1 z3 yy tmp:felem) : Stack unit (requires fun h -> live h y1 /\ live h z1 /\ live h z3 /\ live h yy /\ live h tmp /\ disjoint y1 z1 /\ disjoint y1 z3 /\ disjoint y1 yy /\ disjoint y1 tmp /\ eq_or_disjoint z1 z3 /\ disjoint z1 yy /\ disjoint z1 tmp /\ disjoint z3 yy /\ disjoint z3 tmp /\ disjoint yy tmp /\ inv_lazy_reduced2 h y1 /\ inv_lazy_reduced2 h z1 /\ inv_lazy_reduced2 h yy) (ensures fun h0 _ h1 -> modifies (loc tmp |+| loc z3) h0 h1 /\ feval h1 z3 = S.fmul (S.fmul (S.fmul (feval h0 yy) (feval h0 y1)) (feval h0 z1)) 8 /\ inv_lazy_reduced2 h1 z3)
val calc_z3 (y1 z1 z3 yy tmp:felem) : Stack unit (requires fun h -> live h y1 /\ live h z1 /\ live h z3 /\ live h yy /\ live h tmp /\ disjoint y1 z1 /\ disjoint y1 z3 /\ disjoint y1 yy /\ disjoint y1 tmp /\ eq_or_disjoint z1 z3 /\ disjoint z1 yy /\ disjoint z1 tmp /\ disjoint z3 yy /\ disjoint z3 tmp /\ disjoint yy tmp /\ inv_lazy_reduced2 h y1 /\ inv_lazy_reduced2 h z1 /\ inv_lazy_reduced2 h yy) (ensures fun h0 _ h1 -> modifies (loc tmp |+| loc z3) h0 h1 /\ feval h1 z3 = S.fmul (S.fmul (S.fmul (feval h0 yy) (feval h0 y1)) (feval h0 z1)) 8 /\ inv_lazy_reduced2 h1 z3)
let calc_z3 y1 z1 z3 yy tmp = fmul tmp yy y1; //tmp = yy*y fmul z3 tmp z1; //z3 = tmp*z = yy*y*z let h1 = ST.get () in //assert (inv_lazy_reduced2 h1 x3); //assert (inv_lazy_reduced2 h1 tmp); //assert (inv_lazy_reduced2 h1 z3); fmul_8_normalize_weak z3 z3
{ "file_name": "code/k256/Hacl.Impl.K256.PointDouble.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 29, "end_line": 42, "start_col": 0, "start_line": 34 }
module Hacl.Impl.K256.PointDouble open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module S = Spec.K256 module BL = Hacl.Spec.K256.Field52.Lemmas open Hacl.K256.Field open Hacl.Impl.K256.Point #set-options "--z3rlimit 300 --fuel 0 --ifuel 0" inline_for_extraction noextract val calc_z3 (y1 z1 z3 yy tmp:felem) : Stack unit (requires fun h -> live h y1 /\ live h z1 /\ live h z3 /\ live h yy /\ live h tmp /\ disjoint y1 z1 /\ disjoint y1 z3 /\ disjoint y1 yy /\ disjoint y1 tmp /\ eq_or_disjoint z1 z3 /\ disjoint z1 yy /\ disjoint z1 tmp /\ disjoint z3 yy /\ disjoint z3 tmp /\ disjoint yy tmp /\ inv_lazy_reduced2 h y1 /\ inv_lazy_reduced2 h z1 /\ inv_lazy_reduced2 h yy) (ensures fun h0 _ h1 -> modifies (loc tmp |+| loc z3) h0 h1 /\ feval h1 z3 = S.fmul (S.fmul (S.fmul (feval h0 yy) (feval h0 y1)) (feval h0 z1)) 8 /\ inv_lazy_reduced2 h1 z3)
{ "checked_file": "/", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Field52.Lemmas.fsti.checked", "Hacl.K256.Field.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.K256.PointDouble.fst" }
[ { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.K256.Field", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.K256.Field52.Lemmas", "short_module": "BL" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 300, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
y1: Hacl.K256.Field.felem -> z1: Hacl.K256.Field.felem -> z3: Hacl.K256.Field.felem -> yy: Hacl.K256.Field.felem -> tmp: Hacl.K256.Field.felem -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.K256.Field.felem", "Hacl.K256.Field.fmul_8_normalize_weak", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.K256.Field.fmul" ]
[]
false
true
false
false
false
let calc_z3 y1 z1 z3 yy tmp =
fmul tmp yy y1; fmul z3 tmp z1; let h1 = ST.get () in fmul_8_normalize_weak z3 z3
false
Vale.Math.Poly2_s.fst
Vale.Math.Poly2_s.degree
val degree (p:poly) : int
val degree (p:poly) : int
let degree p = D.degree p
{ "file_name": "vale/specs/math/Vale.Math.Poly2_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 25, "end_line": 6, "start_col": 0, "start_line": 6 }
module Vale.Math.Poly2_s open FStar.Mul open FStar.Seq
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "Vale.Math.Poly2_s.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Vale.Math.Poly2.Defs_s", "short_module": "D" }, { "abbrev": false, "full_module": "Vale.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Vale.Math.Poly2_s.poly -> Prims.int
Prims.Tot
[ "total" ]
[]
[ "Vale.Math.Poly2_s.poly", "Vale.Math.Poly2.Defs_s.degree", "Prims.int" ]
[]
false
false
false
true
false
let degree p =
D.degree p
false