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
listlengths
0
2
mutual_with
listlengths
0
11
ideal_premises
listlengths
0
236
proof_features
listlengths
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.Math.Bits.fst
Vale.Math.Bits.lemma_i2b_mul
val lemma_i2b_mul (#n:pos) (a b:uint_t n) : Lemma (b_i2b #n (mul_mod #n a b) == b_mul #n (b_i2b a) b)
val lemma_i2b_mul (#n:pos) (a b:uint_t n) : Lemma (b_i2b #n (mul_mod #n a b) == b_mul #n (b_i2b a) b)
let lemma_i2b_mul #n a b = int2bv_mul #n #a #b #(bvmul #n (int2bv #n a) b) (); assert_norm (b_i2b #n (mul_mod #n a b) == b_mul #n (b_i2b a) b)
{ "file_name": "vale/code/lib/math/Vale.Math.Bits.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 65, "end_line": 44, "start_col": 0, "start_line": 42 }
module Vale.Math.Bits open FStar.Mul let lemma_pow2_le m n = FStar.Math.Lemmas.pow2_le_compat n m let lemma_i2b_eq #n a b = assert_norm (b_i2b a == b_i2b b ==> int2bv a == int2bv b); int2bv_lemma_2 #n a b let lemma_i2b_uext #n m a = Vale.Lib.Bv_s.int2bv_uext #n #m a (uext #n #m a); assert_norm (b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a)) let lemma_i2b_and #n a b = int2bv_logand #n #a #b #(bvand #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b)) let lemma_i2b_or #n a b = int2bv_logor #n #a #b #(bvor #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (logor #n a b) == b_or #n (b_i2b a) (b_i2b b)) let lemma_i2b_xor #n a b = int2bv_logxor #n #a #b #(bvxor #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (logxor #n a b) == b_xor #n (b_i2b a) (b_i2b b)) let lemma_i2b_shl #n a b = int2bv_shl #n #a #b #(bvshl #n (int2bv #n a) b) (); assert_norm (b_i2b #n (shift_left #n a b) == b_shl #n (b_i2b a) b) let lemma_i2b_shr #n a b = int2bv_shr #n #a #b #(bvshr #n (int2bv #n a) b) (); assert_norm (b_i2b #n (shift_right #n a b) == b_shr #n (b_i2b a) b) let lemma_i2b_add #n a b = int2bv_add #n #a #b #(bvadd #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (add_mod #n a b) == b_add #n (b_i2b a) (b_i2b b)) let lemma_i2b_sub #n a b = int2bv_sub #n #a #b #(bvsub #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (sub_mod #n a b) == b_sub #n (b_i2b a) (b_i2b b))
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Bv_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Math.Bits.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.BV", "short_module": null }, { "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
a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n -> FStar.Pervasives.Lemma (ensures Vale.Math.Bits.b_i2b (FStar.UInt.mul_mod a b) == Vale.Math.Bits.b_mul (Vale.Math.Bits.b_i2b a) b)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.pos", "FStar.UInt.uint_t", "FStar.Pervasives.assert_norm", "Prims.eq2", "FStar.BV.bv_t", "Vale.Math.Bits.b_i2b", "FStar.UInt.mul_mod", "Vale.Math.Bits.b_mul", "Prims.unit", "FStar.BV.int2bv_mul", "FStar.BV.bvmul", "FStar.BV.int2bv" ]
[]
true
false
true
false
false
let lemma_i2b_mul #n a b =
int2bv_mul #n #a #b #(bvmul #n (int2bv #n a) b) (); assert_norm (b_i2b #n (mul_mod #n a b) == b_mul #n (b_i2b a) b)
false
Vale.Math.Bits.fst
Vale.Math.Bits.lemma_i2b_div
val lemma_i2b_div (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Lemma (b_i2b #n (udiv #n a b) == b_div #n (b_i2b a) b)
val lemma_i2b_div (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Lemma (b_i2b #n (udiv #n a b) == b_div #n (b_i2b a) b)
let lemma_i2b_div #n a b = int2bv_div #n #a #b #(bvdiv #n (int2bv #n a) b) (); assert_norm (b_i2b #n (udiv #n a b) == b_div #n (b_i2b a) b)
{ "file_name": "vale/code/lib/math/Vale.Math.Bits.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 62, "end_line": 48, "start_col": 0, "start_line": 46 }
module Vale.Math.Bits open FStar.Mul let lemma_pow2_le m n = FStar.Math.Lemmas.pow2_le_compat n m let lemma_i2b_eq #n a b = assert_norm (b_i2b a == b_i2b b ==> int2bv a == int2bv b); int2bv_lemma_2 #n a b let lemma_i2b_uext #n m a = Vale.Lib.Bv_s.int2bv_uext #n #m a (uext #n #m a); assert_norm (b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a)) let lemma_i2b_and #n a b = int2bv_logand #n #a #b #(bvand #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b)) let lemma_i2b_or #n a b = int2bv_logor #n #a #b #(bvor #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (logor #n a b) == b_or #n (b_i2b a) (b_i2b b)) let lemma_i2b_xor #n a b = int2bv_logxor #n #a #b #(bvxor #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (logxor #n a b) == b_xor #n (b_i2b a) (b_i2b b)) let lemma_i2b_shl #n a b = int2bv_shl #n #a #b #(bvshl #n (int2bv #n a) b) (); assert_norm (b_i2b #n (shift_left #n a b) == b_shl #n (b_i2b a) b) let lemma_i2b_shr #n a b = int2bv_shr #n #a #b #(bvshr #n (int2bv #n a) b) (); assert_norm (b_i2b #n (shift_right #n a b) == b_shr #n (b_i2b a) b) let lemma_i2b_add #n a b = int2bv_add #n #a #b #(bvadd #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (add_mod #n a b) == b_add #n (b_i2b a) (b_i2b b)) let lemma_i2b_sub #n a b = int2bv_sub #n #a #b #(bvsub #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (sub_mod #n a b) == b_sub #n (b_i2b a) (b_i2b b)) let lemma_i2b_mul #n a b = int2bv_mul #n #a #b #(bvmul #n (int2bv #n a) b) (); assert_norm (b_i2b #n (mul_mod #n a b) == b_mul #n (b_i2b a) b)
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Bv_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Math.Bits.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.BV", "short_module": null }, { "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
a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n {b <> 0} -> FStar.Pervasives.Lemma (ensures Vale.Math.Bits.b_i2b (FStar.UInt.udiv a b) == Vale.Math.Bits.b_div (Vale.Math.Bits.b_i2b a) b)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.pos", "FStar.UInt.uint_t", "Prims.b2t", "Prims.op_disEquality", "Prims.int", "FStar.Pervasives.assert_norm", "Prims.eq2", "FStar.BV.bv_t", "Vale.Math.Bits.b_i2b", "FStar.UInt.udiv", "Vale.Math.Bits.b_div", "Prims.unit", "FStar.BV.int2bv_div", "FStar.BV.bvdiv", "FStar.BV.int2bv" ]
[]
true
false
true
false
false
let lemma_i2b_div #n a b =
int2bv_div #n #a #b #(bvdiv #n (int2bv #n a) b) (); assert_norm (b_i2b #n (udiv #n a b) == b_div #n (b_i2b a) b)
false
Vale.Math.Bits.fst
Vale.Math.Bits.add_hide
val add_hide (#n:pos) (a b:uint_t n) : Pure (uint_t n) (requires True) (ensures fun x -> a + b < pow2 n ==> x == a + b)
val add_hide (#n:pos) (a b:uint_t n) : Pure (uint_t n) (requires True) (ensures fun x -> a + b < pow2 n ==> x == a + b)
let add_hide #n a b = if a + b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a + b) (pow2 n); add_mod a b
{ "file_name": "vale/code/lib/math/Vale.Math.Bits.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 13, "end_line": 58, "start_col": 0, "start_line": 56 }
module Vale.Math.Bits open FStar.Mul let lemma_pow2_le m n = FStar.Math.Lemmas.pow2_le_compat n m let lemma_i2b_eq #n a b = assert_norm (b_i2b a == b_i2b b ==> int2bv a == int2bv b); int2bv_lemma_2 #n a b let lemma_i2b_uext #n m a = Vale.Lib.Bv_s.int2bv_uext #n #m a (uext #n #m a); assert_norm (b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a)) let lemma_i2b_and #n a b = int2bv_logand #n #a #b #(bvand #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b)) let lemma_i2b_or #n a b = int2bv_logor #n #a #b #(bvor #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (logor #n a b) == b_or #n (b_i2b a) (b_i2b b)) let lemma_i2b_xor #n a b = int2bv_logxor #n #a #b #(bvxor #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (logxor #n a b) == b_xor #n (b_i2b a) (b_i2b b)) let lemma_i2b_shl #n a b = int2bv_shl #n #a #b #(bvshl #n (int2bv #n a) b) (); assert_norm (b_i2b #n (shift_left #n a b) == b_shl #n (b_i2b a) b) let lemma_i2b_shr #n a b = int2bv_shr #n #a #b #(bvshr #n (int2bv #n a) b) (); assert_norm (b_i2b #n (shift_right #n a b) == b_shr #n (b_i2b a) b) let lemma_i2b_add #n a b = int2bv_add #n #a #b #(bvadd #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (add_mod #n a b) == b_add #n (b_i2b a) (b_i2b b)) let lemma_i2b_sub #n a b = int2bv_sub #n #a #b #(bvsub #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (sub_mod #n a b) == b_sub #n (b_i2b a) (b_i2b b)) let lemma_i2b_mul #n a b = int2bv_mul #n #a #b #(bvmul #n (int2bv #n a) b) (); assert_norm (b_i2b #n (mul_mod #n a b) == b_mul #n (b_i2b a) b) let lemma_i2b_div #n a b = int2bv_div #n #a #b #(bvdiv #n (int2bv #n a) b) (); assert_norm (b_i2b #n (udiv #n a b) == b_div #n (b_i2b a) b) let lemma_i2b_mod #n a b = int2bv_mod #n #a #b #(bvmod #n (int2bv #n a) b) (); assert_norm (bvmod #n (int2bv a) b == b_mod #n (b_i2b a) b); assert_norm (int2bv #n (mod #n a b) == b_i2b #n (mod #n a b)); ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Bv_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Math.Bits.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.BV", "short_module": null }, { "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
a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n -> Prims.Pure (FStar.UInt.uint_t n)
Prims.Pure
[]
[]
[ "Prims.pos", "FStar.UInt.uint_t", "FStar.UInt.add_mod", "Prims.unit", "Prims.op_LessThan", "Prims.op_Addition", "Prims.pow2", "FStar.Math.Lemmas.modulo_lemma", "Prims.bool" ]
[]
false
false
false
false
false
let add_hide #n a b =
if a + b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a + b) (pow2 n); add_mod a b
false
Vale.Math.Bits.fst
Vale.Math.Bits.lemma_i2b_equal
val lemma_i2b_equal (#n:pos) (x y:uint_t n) : Lemma (requires lemmas_i2b_all ==> b_i2b x == b_i2b y) (ensures x == y)
val lemma_i2b_equal (#n:pos) (x y:uint_t n) : Lemma (requires lemmas_i2b_all ==> b_i2b x == b_i2b y) (ensures x == y)
let lemma_i2b_equal #n x y = lemma_i2b_all (); lemma_i2b_eq x y
{ "file_name": "vale/code/lib/math/Vale.Math.Bits.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 18, "end_line": 89, "start_col": 0, "start_line": 87 }
module Vale.Math.Bits open FStar.Mul let lemma_pow2_le m n = FStar.Math.Lemmas.pow2_le_compat n m let lemma_i2b_eq #n a b = assert_norm (b_i2b a == b_i2b b ==> int2bv a == int2bv b); int2bv_lemma_2 #n a b let lemma_i2b_uext #n m a = Vale.Lib.Bv_s.int2bv_uext #n #m a (uext #n #m a); assert_norm (b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a)) let lemma_i2b_and #n a b = int2bv_logand #n #a #b #(bvand #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b)) let lemma_i2b_or #n a b = int2bv_logor #n #a #b #(bvor #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (logor #n a b) == b_or #n (b_i2b a) (b_i2b b)) let lemma_i2b_xor #n a b = int2bv_logxor #n #a #b #(bvxor #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (logxor #n a b) == b_xor #n (b_i2b a) (b_i2b b)) let lemma_i2b_shl #n a b = int2bv_shl #n #a #b #(bvshl #n (int2bv #n a) b) (); assert_norm (b_i2b #n (shift_left #n a b) == b_shl #n (b_i2b a) b) let lemma_i2b_shr #n a b = int2bv_shr #n #a #b #(bvshr #n (int2bv #n a) b) (); assert_norm (b_i2b #n (shift_right #n a b) == b_shr #n (b_i2b a) b) let lemma_i2b_add #n a b = int2bv_add #n #a #b #(bvadd #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (add_mod #n a b) == b_add #n (b_i2b a) (b_i2b b)) let lemma_i2b_sub #n a b = int2bv_sub #n #a #b #(bvsub #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (sub_mod #n a b) == b_sub #n (b_i2b a) (b_i2b b)) let lemma_i2b_mul #n a b = int2bv_mul #n #a #b #(bvmul #n (int2bv #n a) b) (); assert_norm (b_i2b #n (mul_mod #n a b) == b_mul #n (b_i2b a) b) let lemma_i2b_div #n a b = int2bv_div #n #a #b #(bvdiv #n (int2bv #n a) b) (); assert_norm (b_i2b #n (udiv #n a b) == b_div #n (b_i2b a) b) let lemma_i2b_mod #n a b = int2bv_mod #n #a #b #(bvmod #n (int2bv #n a) b) (); assert_norm (bvmod #n (int2bv a) b == b_mod #n (b_i2b a) b); assert_norm (int2bv #n (mod #n a b) == b_i2b #n (mod #n a b)); () let add_hide #n a b = if a + b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a + b) (pow2 n); add_mod a b let sub_hide #n a b = if 0 <= a - b then FStar.Math.Lemmas.modulo_lemma (a - b) (pow2 n); sub_mod a b let mul_hide #n a b = FStar.Math.Lemmas.nat_times_nat_is_nat a b; if a * b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a * b) (pow2 n); assert_norm (mul_mod a b == (a * b) % pow2 n); mul_mod a b let lemma_i2b_all () = FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_uext #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_and #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_or #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_xor #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_shl #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_shr #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_add #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_sub #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_mul #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_div #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_mod #n a b); () let lemma_i2b_with_all n p = lemma_i2b_all ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Bv_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Math.Bits.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.BV", "short_module": null }, { "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
x: FStar.UInt.uint_t n -> y: FStar.UInt.uint_t n -> FStar.Pervasives.Lemma (requires Vale.Math.Bits.lemmas_i2b_all ==> Vale.Math.Bits.b_i2b x == Vale.Math.Bits.b_i2b y) (ensures x == y)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.pos", "FStar.UInt.uint_t", "Vale.Math.Bits.lemma_i2b_eq", "Prims.unit", "Vale.Math.Bits.lemma_i2b_all" ]
[]
true
false
true
false
false
let lemma_i2b_equal #n x y =
lemma_i2b_all (); lemma_i2b_eq x y
false
Vale.Math.Bits.fst
Vale.Math.Bits.lemma_i2b_with_all
val lemma_i2b_with_all (n:pos) (p:Type0) : Lemma (requires lemmas_i2b_all ==> p) (ensures p)
val lemma_i2b_with_all (n:pos) (p:Type0) : Lemma (requires lemmas_i2b_all ==> p) (ensures p)
let lemma_i2b_with_all n p = lemma_i2b_all ()
{ "file_name": "vale/code/lib/math/Vale.Math.Bits.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 18, "end_line": 85, "start_col": 0, "start_line": 84 }
module Vale.Math.Bits open FStar.Mul let lemma_pow2_le m n = FStar.Math.Lemmas.pow2_le_compat n m let lemma_i2b_eq #n a b = assert_norm (b_i2b a == b_i2b b ==> int2bv a == int2bv b); int2bv_lemma_2 #n a b let lemma_i2b_uext #n m a = Vale.Lib.Bv_s.int2bv_uext #n #m a (uext #n #m a); assert_norm (b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a)) let lemma_i2b_and #n a b = int2bv_logand #n #a #b #(bvand #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b)) let lemma_i2b_or #n a b = int2bv_logor #n #a #b #(bvor #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (logor #n a b) == b_or #n (b_i2b a) (b_i2b b)) let lemma_i2b_xor #n a b = int2bv_logxor #n #a #b #(bvxor #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (logxor #n a b) == b_xor #n (b_i2b a) (b_i2b b)) let lemma_i2b_shl #n a b = int2bv_shl #n #a #b #(bvshl #n (int2bv #n a) b) (); assert_norm (b_i2b #n (shift_left #n a b) == b_shl #n (b_i2b a) b) let lemma_i2b_shr #n a b = int2bv_shr #n #a #b #(bvshr #n (int2bv #n a) b) (); assert_norm (b_i2b #n (shift_right #n a b) == b_shr #n (b_i2b a) b) let lemma_i2b_add #n a b = int2bv_add #n #a #b #(bvadd #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (add_mod #n a b) == b_add #n (b_i2b a) (b_i2b b)) let lemma_i2b_sub #n a b = int2bv_sub #n #a #b #(bvsub #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (sub_mod #n a b) == b_sub #n (b_i2b a) (b_i2b b)) let lemma_i2b_mul #n a b = int2bv_mul #n #a #b #(bvmul #n (int2bv #n a) b) (); assert_norm (b_i2b #n (mul_mod #n a b) == b_mul #n (b_i2b a) b) let lemma_i2b_div #n a b = int2bv_div #n #a #b #(bvdiv #n (int2bv #n a) b) (); assert_norm (b_i2b #n (udiv #n a b) == b_div #n (b_i2b a) b) let lemma_i2b_mod #n a b = int2bv_mod #n #a #b #(bvmod #n (int2bv #n a) b) (); assert_norm (bvmod #n (int2bv a) b == b_mod #n (b_i2b a) b); assert_norm (int2bv #n (mod #n a b) == b_i2b #n (mod #n a b)); () let add_hide #n a b = if a + b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a + b) (pow2 n); add_mod a b let sub_hide #n a b = if 0 <= a - b then FStar.Math.Lemmas.modulo_lemma (a - b) (pow2 n); sub_mod a b let mul_hide #n a b = FStar.Math.Lemmas.nat_times_nat_is_nat a b; if a * b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a * b) (pow2 n); assert_norm (mul_mod a b == (a * b) % pow2 n); mul_mod a b let lemma_i2b_all () = FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_uext #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_and #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_or #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_xor #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_shl #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_shr #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_add #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_sub #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_mul #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_div #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_mod #n a b); ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Bv_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Math.Bits.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.BV", "short_module": null }, { "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
n: Prims.pos -> p: Type0 -> FStar.Pervasives.Lemma (requires Vale.Math.Bits.lemmas_i2b_all ==> p) (ensures p)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.pos", "Vale.Math.Bits.lemma_i2b_all", "Prims.unit" ]
[]
true
false
true
false
false
let lemma_i2b_with_all n p =
lemma_i2b_all ()
false
Vale.Math.Bits.fst
Vale.Math.Bits.lemma_to_is_bv8
val lemma_to_is_bv8 (a:uint_t 32) : Lemma (requires a < 0x100) (ensures is_bv8 (b_i2b a))
val lemma_to_is_bv8 (a:uint_t 32) : Lemma (requires a < 0x100) (ensures is_bv8 (b_i2b a))
let lemma_to_is_bv8 a = int2bv_lemma_ult_1 a 0x100; lemma_to_is_bv8_bv (int2bv a); assert_norm (b_i2b a == int2bv a)
{ "file_name": "vale/code/lib/math/Vale.Math.Bits.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 35, "end_line": 115, "start_col": 0, "start_line": 112 }
module Vale.Math.Bits open FStar.Mul let lemma_pow2_le m n = FStar.Math.Lemmas.pow2_le_compat n m let lemma_i2b_eq #n a b = assert_norm (b_i2b a == b_i2b b ==> int2bv a == int2bv b); int2bv_lemma_2 #n a b let lemma_i2b_uext #n m a = Vale.Lib.Bv_s.int2bv_uext #n #m a (uext #n #m a); assert_norm (b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a)) let lemma_i2b_and #n a b = int2bv_logand #n #a #b #(bvand #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b)) let lemma_i2b_or #n a b = int2bv_logor #n #a #b #(bvor #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (logor #n a b) == b_or #n (b_i2b a) (b_i2b b)) let lemma_i2b_xor #n a b = int2bv_logxor #n #a #b #(bvxor #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (logxor #n a b) == b_xor #n (b_i2b a) (b_i2b b)) let lemma_i2b_shl #n a b = int2bv_shl #n #a #b #(bvshl #n (int2bv #n a) b) (); assert_norm (b_i2b #n (shift_left #n a b) == b_shl #n (b_i2b a) b) let lemma_i2b_shr #n a b = int2bv_shr #n #a #b #(bvshr #n (int2bv #n a) b) (); assert_norm (b_i2b #n (shift_right #n a b) == b_shr #n (b_i2b a) b) let lemma_i2b_add #n a b = int2bv_add #n #a #b #(bvadd #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (add_mod #n a b) == b_add #n (b_i2b a) (b_i2b b)) let lemma_i2b_sub #n a b = int2bv_sub #n #a #b #(bvsub #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (sub_mod #n a b) == b_sub #n (b_i2b a) (b_i2b b)) let lemma_i2b_mul #n a b = int2bv_mul #n #a #b #(bvmul #n (int2bv #n a) b) (); assert_norm (b_i2b #n (mul_mod #n a b) == b_mul #n (b_i2b a) b) let lemma_i2b_div #n a b = int2bv_div #n #a #b #(bvdiv #n (int2bv #n a) b) (); assert_norm (b_i2b #n (udiv #n a b) == b_div #n (b_i2b a) b) let lemma_i2b_mod #n a b = int2bv_mod #n #a #b #(bvmod #n (int2bv #n a) b) (); assert_norm (bvmod #n (int2bv a) b == b_mod #n (b_i2b a) b); assert_norm (int2bv #n (mod #n a b) == b_i2b #n (mod #n a b)); () let add_hide #n a b = if a + b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a + b) (pow2 n); add_mod a b let sub_hide #n a b = if 0 <= a - b then FStar.Math.Lemmas.modulo_lemma (a - b) (pow2 n); sub_mod a b let mul_hide #n a b = FStar.Math.Lemmas.nat_times_nat_is_nat a b; if a * b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a * b) (pow2 n); assert_norm (mul_mod a b == (a * b) % pow2 n); mul_mod a b let lemma_i2b_all () = FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_uext #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_and #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_or #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_xor #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_shl #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_shr #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_add #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_sub #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_mul #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_div #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_mod #n a b); () let lemma_i2b_with_all n p = lemma_i2b_all () let lemma_i2b_equal #n x y = lemma_i2b_all (); lemma_i2b_eq x y #reset-options "--initial_fuel 0 --max_fuel 0" let lemma_bveq #n a b = let ia = bv2int a in let ib = bv2int b in int2bv_logxor #n #ia #ib #(bvxor a b) (); int2bv_logxor #n #ia #ia #(bvxor a a) (); assert (int2bv #n (logxor #n ia ib) == int2bv #n (logxor #n ia ia)); assert (bv2int (int2bv #n (logxor #n ia ib)) == logxor #n ia ib); assert (bv2int (int2bv #n (logxor #n ia ia)) == logxor #n ia ia); assert (logxor #n ia ib == logxor #n ia ia); logxor_self ia; logxor_neq_nonzero ia ib; () let lemma_to_is_bv8_bv (a:bv_t 32) : Lemma (requires bvult a (int2bv 0x100)) (ensures is_bv8 a) = lemma_bveq a (bvand a (int2bv 0xff)); assert_norm (is_bv8 a)
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Bv_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Math.Bits.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.BV", "short_module": null }, { "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": 0, "initial_ifuel": 0, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: FStar.UInt.uint_t 32 -> FStar.Pervasives.Lemma (requires a < 0x100) (ensures Vale.Math.Bits.is_bv8 (Vale.Math.Bits.b_i2b a))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.UInt.uint_t", "FStar.Pervasives.assert_norm", "Prims.eq2", "FStar.BV.bv_t", "Vale.Math.Bits.b_i2b", "FStar.BV.int2bv", "Prims.unit", "Vale.Math.Bits.lemma_to_is_bv8_bv", "FStar.BV.int2bv_lemma_ult_1" ]
[]
true
false
true
false
false
let lemma_to_is_bv8 a =
int2bv_lemma_ult_1 a 0x100; lemma_to_is_bv8_bv (int2bv a); assert_norm (b_i2b a == int2bv a)
false
Vale.Math.Bits.fst
Vale.Math.Bits.lemma_to_is_bv8_bv
val lemma_to_is_bv8_bv (a: bv_t 32) : Lemma (requires bvult a (int2bv 0x100)) (ensures is_bv8 a)
val lemma_to_is_bv8_bv (a: bv_t 32) : Lemma (requires bvult a (int2bv 0x100)) (ensures is_bv8 a)
let lemma_to_is_bv8_bv (a:bv_t 32) : Lemma (requires bvult a (int2bv 0x100)) (ensures is_bv8 a) = lemma_bveq a (bvand a (int2bv 0xff)); assert_norm (is_bv8 a)
{ "file_name": "vale/code/lib/math/Vale.Math.Bits.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 24, "end_line": 110, "start_col": 0, "start_line": 105 }
module Vale.Math.Bits open FStar.Mul let lemma_pow2_le m n = FStar.Math.Lemmas.pow2_le_compat n m let lemma_i2b_eq #n a b = assert_norm (b_i2b a == b_i2b b ==> int2bv a == int2bv b); int2bv_lemma_2 #n a b let lemma_i2b_uext #n m a = Vale.Lib.Bv_s.int2bv_uext #n #m a (uext #n #m a); assert_norm (b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a)) let lemma_i2b_and #n a b = int2bv_logand #n #a #b #(bvand #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b)) let lemma_i2b_or #n a b = int2bv_logor #n #a #b #(bvor #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (logor #n a b) == b_or #n (b_i2b a) (b_i2b b)) let lemma_i2b_xor #n a b = int2bv_logxor #n #a #b #(bvxor #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (logxor #n a b) == b_xor #n (b_i2b a) (b_i2b b)) let lemma_i2b_shl #n a b = int2bv_shl #n #a #b #(bvshl #n (int2bv #n a) b) (); assert_norm (b_i2b #n (shift_left #n a b) == b_shl #n (b_i2b a) b) let lemma_i2b_shr #n a b = int2bv_shr #n #a #b #(bvshr #n (int2bv #n a) b) (); assert_norm (b_i2b #n (shift_right #n a b) == b_shr #n (b_i2b a) b) let lemma_i2b_add #n a b = int2bv_add #n #a #b #(bvadd #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (add_mod #n a b) == b_add #n (b_i2b a) (b_i2b b)) let lemma_i2b_sub #n a b = int2bv_sub #n #a #b #(bvsub #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (sub_mod #n a b) == b_sub #n (b_i2b a) (b_i2b b)) let lemma_i2b_mul #n a b = int2bv_mul #n #a #b #(bvmul #n (int2bv #n a) b) (); assert_norm (b_i2b #n (mul_mod #n a b) == b_mul #n (b_i2b a) b) let lemma_i2b_div #n a b = int2bv_div #n #a #b #(bvdiv #n (int2bv #n a) b) (); assert_norm (b_i2b #n (udiv #n a b) == b_div #n (b_i2b a) b) let lemma_i2b_mod #n a b = int2bv_mod #n #a #b #(bvmod #n (int2bv #n a) b) (); assert_norm (bvmod #n (int2bv a) b == b_mod #n (b_i2b a) b); assert_norm (int2bv #n (mod #n a b) == b_i2b #n (mod #n a b)); () let add_hide #n a b = if a + b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a + b) (pow2 n); add_mod a b let sub_hide #n a b = if 0 <= a - b then FStar.Math.Lemmas.modulo_lemma (a - b) (pow2 n); sub_mod a b let mul_hide #n a b = FStar.Math.Lemmas.nat_times_nat_is_nat a b; if a * b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a * b) (pow2 n); assert_norm (mul_mod a b == (a * b) % pow2 n); mul_mod a b let lemma_i2b_all () = FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_uext #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_and #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_or #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_xor #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_shl #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_shr #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_add #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_sub #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_mul #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_div #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_mod #n a b); () let lemma_i2b_with_all n p = lemma_i2b_all () let lemma_i2b_equal #n x y = lemma_i2b_all (); lemma_i2b_eq x y #reset-options "--initial_fuel 0 --max_fuel 0" let lemma_bveq #n a b = let ia = bv2int a in let ib = bv2int b in int2bv_logxor #n #ia #ib #(bvxor a b) (); int2bv_logxor #n #ia #ia #(bvxor a a) (); assert (int2bv #n (logxor #n ia ib) == int2bv #n (logxor #n ia ia)); assert (bv2int (int2bv #n (logxor #n ia ib)) == logxor #n ia ib); assert (bv2int (int2bv #n (logxor #n ia ia)) == logxor #n ia ia); assert (logxor #n ia ib == logxor #n ia ia); logxor_self ia; logxor_neq_nonzero ia ib; ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Bv_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Math.Bits.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.BV", "short_module": null }, { "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": 0, "initial_ifuel": 0, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: FStar.BV.bv_t 32 -> FStar.Pervasives.Lemma (requires FStar.BV.bvult a (FStar.BV.int2bv 0x100)) (ensures Vale.Math.Bits.is_bv8 a)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.BV.bv_t", "FStar.Pervasives.assert_norm", "Vale.Math.Bits.is_bv8", "Prims.unit", "Vale.Math.Bits.lemma_bveq", "FStar.BV.bvand", "FStar.BV.int2bv", "Prims.b2t", "FStar.BV.bvult", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let lemma_to_is_bv8_bv (a: bv_t 32) : Lemma (requires bvult a (int2bv 0x100)) (ensures is_bv8 a) =
lemma_bveq a (bvand a (int2bv 0xff)); assert_norm (is_bv8 a)
false
Pulse.Readback.fst
Pulse.Readback.readback_comp
val readback_comp (t:R.term) : option (c:comp{ elab_comp c == t})
val readback_comp (t:R.term) : option (c:comp{ elab_comp c == t})
let readback_comp (t:R.term) : option (c:comp { elab_comp c == t }) = let ropt = try_readback_st_comp t readback_ty in match ropt with | Some c -> // debug_log (fun _ -> T.print (Printf.sprintf "readback_comp: %s as\n%s\n" (T.term_to_string t) (P.comp_to_string c))); ropt | _ -> let? t' = readback_ty t in Some (C_Tot t' <: c:comp{ elab_comp c == t })
{ "file_name": "lib/steel/pulse/Pulse.Readback.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 49, "end_line": 268, "start_col": 0, "start_line": 258 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Readback module R = FStar.Reflection.V2 open Pulse.Syntax.Base open Pulse.Reflection.Util module RU = Pulse.RuntimeUtils module T = FStar.Tactics module P = Pulse.Syntax.Printer let debug_log (f: unit -> T.Tac unit) : T.Tac unit = if RU.debug_at_level_no_module "readback" then f() let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x let readback_observability (t:R.term) : option (obs:observability { elab_observability obs == t }) = let open R in match inspect_ln t with | R.Tv_FVar fv -> let fv_lid = inspect_fv fv in if fv_lid = observable_lid then Some Observable else if fv_lid = unobservable_lid then Some Unobservable else if fv_lid = neutral_lid then Some Neutral else None | _ -> None #push-options "--z3rlimit_factor 20" // TODO: FIXME: may be mark as opaque_to_smt let try_readback_st_comp (t:R.term) (readback_ty:(t':R.term -> option (ty:term { elab_term ty == t' }))) : option (c:comp{elab_comp c == t}) = let open R in let hd, args = collect_app_ln t in match inspect_ln hd with | Tv_UInst fv [u] -> let fv_lid = inspect_fv fv in if fv_lid = stt_lid then match args with | [res; pre; post] -> (match inspect_ln (fst post) with | Tv_Abs b body -> let { qual=aq; attrs=attrs; sort=sort } = inspect_binder b in assume (fv == stt_fv); assume (aq == Q_Explicit /\ attrs == [] /\ sort == fst res /\ snd res == Q_Explicit /\ snd pre == Q_Explicit /\ snd post == Q_Explicit); assume (t == mk_stt_comp u (fst res) (fst pre) (mk_abs (fst res) R.Q_Explicit body)); let? res' = readback_ty (fst res) in let? pre' = readback_ty (fst pre) in let? post' = readback_ty body in let c = C_ST {u; res=res'; pre=pre';post=post'} in Some (c <: c:Pulse.Syntax.Base.comp{ elab_comp c == t }) | _ -> None) | _ -> None else if fv_lid = stt_atomic_lid then match args with | [res; obs; opened; pre; post] -> (match inspect_ln (fst post) with | Tv_Abs b body -> let { qual=aq; attrs=attrs } = inspect_binder b in let? res' = readback_ty (fst res) in let? obs' = readback_observability (fst obs) in let? opened' = readback_ty (fst opened) in let? pre' = readback_ty (fst pre) in let? post' = readback_ty body in assume (t == mk_stt_atomic_comp (fst obs) u (fst res) (fst opened) (fst pre) (mk_abs (fst res) R.Q_Explicit body)); let c = C_STAtomic opened' obs' ({u; res=res'; pre=pre';post=post'}) in Some (c <: c:Pulse.Syntax.Base.comp { elab_comp c == t }) | _ -> None) | _ -> None else if fv_lid = stt_ghost_lid then match args with | [res; pre; post] -> (match inspect_ln (fst post) with | Tv_Abs b body -> let { qual=aq; attrs=attrs } = inspect_binder b in let? res' = readback_ty (fst res) in let? pre' = readback_ty (fst pre) in let? post' = readback_ty body in assume (t == mk_stt_ghost_comp u (fst res) (fst pre) (mk_abs (fst res) R.Q_Explicit body)); let c = C_STGhost ({u; res=res'; pre=pre';post=post'}) in Some (c <: c:Pulse.Syntax.Base.comp { elab_comp c == t }) | _ -> None) | _ -> None else None | _ -> None #pop-options let readback_qual = function | R.Q_Implicit -> Some Implicit | _ -> None // WARNING WARNING WARNING: THIS DEFINITION MAKES THE CONTEXT INCONSISTENT // #push-options "--admit_smt_queries true" // let collect_app_refined (t:R.term) : res:(R.term & list R.argv){fst res << t /\ (forall a. L.memP a (snd res) ==> a << t)} = // R.collect_app_ln t // #pop-options // let readback_ty_ascribed (t:R.term { let t = R.inspect_ln t in // R.Tv_AscribedT? t || R.Tv_AscribedC? t }) // : option (ty:term { elab_term ty == t }) = // match R.inspect_ln t with // // // // The following is dropping the ascription, which is not ideal // // However, if we don't, then ascriptions start to come in the way of // // R.term_eq used to decide equality of tm_fstar terms, // // which then results in framing failures // // // // At least in the examples it came up, the ascription was a redundant // // ascription on F* Tm_Match // // I tried an F* patch that did not add the ascription, if it was already // // ascribed, but that failed a couple of proofs in HACL* : ( // // // | R.Tv_AscribedT t _ _ _ // | R.Tv_AscribedC t _ _ _ -> Some (tm_fstar t (R.range_of_term t)) // #pop-options let rec readback_ty (t:R.term) : option (ty:term { elab_term ty == t }) = let open R in let open Pulse.Syntax.Base in let w (res:term') = with_range res (RU.range_of_term t) in let return (res:term' { elab_term (w res) == t}) : option (ty:term { elab_term ty == t}) = Some (w res) in match inspect_ln t with | Tv_FVar fv -> let fv_lid = inspect_fv fv in if fv_lid = vprop_lid then return Tm_VProp else if fv_lid = emp_lid then return Tm_Emp else if fv_lid = inames_lid then return Tm_Inames else if fv_lid = emp_inames_lid then return Tm_EmpInames else return (Tm_FStar t) | Tv_App hd (a, q) -> admit(); //this case doesn't work because it is using collect_app_ln, etc. let aux () = match q with | R.Q_Meta _ -> None | _ -> return (Tm_FStar t) in let head, args = collect_app_ln t in begin match inspect_ln head, args with | Tv_FVar fv, [a1; a2] -> if inspect_fv fv = star_lid then ( let t1 : R.term = fst a1 in let t2 : R.term = fst a2 in assume (t1 << t); assume (t2 << t); let? t1 = readback_ty t1 in let? t2 = readback_ty t2 in return (Tm_Star t1 t2) ) else aux () | Tv_UInst fv [u], [a1; a2] -> if inspect_fv fv = exists_lid || inspect_fv fv = forall_lid then ( let t1 : R.term = fst a1 in let t2 : R.term = fst a2 in let? ty = readback_ty t1 in let? (ppname, range, p) = match inspect_ln t2 with | Tv_Abs b body -> let? p = readback_ty body in let bview = inspect_binder b in Some (bview.ppname, RU.binder_range b, p) <: option (ppname_t & range & term) | _ -> None in // TODO: FIXME: provide error from this function? let b = mk_binder_ppname ty (mk_ppname ppname range) in if inspect_fv fv = exists_lid then return (Tm_ExistsSL u b p) else return (Tm_ForallSL u b p) ) else aux () | Tv_FVar fv, [a] -> if inspect_fv fv = pure_lid then ( let t1 : R.term = fst a in let? t1 = readback_ty t1 in return (Tm_Pure t1) ) else if inspect_fv fv = inv_lid then ( let t1 : R.term = fst a in let? t1 = readback_ty t1 in return (Tm_Inv t1) ) else aux () | _ -> aux () end | Tv_Refine _ _ | Tv_Arrow _ _ | Tv_Type _ | Tv_Const _ | Tv_Let _ _ _ _ _ | Tv_Var _ | Tv_BVar _ | Tv_UInst _ _ | Tv_Match _ _ _ | Tv_Abs _ _ -> return (Tm_FStar t) | Tv_AscribedT t _ _ _ | Tv_AscribedC t _ _ _ -> //this case doesn't work because it is unascribing admit(); readback_ty t | Tv_Uvar _ _ -> None // TODO: FIXME: T.fail "readback_ty: unexpected Tv_Uvar" | Tv_Unknown -> return Tm_Unknown | Tv_Unsupp -> None
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Readback.fst" }
[ { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse", "short_module": null }, { "abbrev": false, "full_module": "Pulse", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
t: FStar.Stubs.Reflection.Types.term -> FStar.Pervasives.Native.option (c: Pulse.Syntax.Base.comp{Pulse.Elaborate.Pure.elab_comp c == t})
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "Pulse.Syntax.Base.comp", "Prims.eq2", "Pulse.Elaborate.Pure.elab_comp", "FStar.Pervasives.Native.option", "Pulse.Readback.op_let_Question", "Pulse.Syntax.Base.term", "Pulse.Elaborate.Pure.elab_term", "Pulse.Readback.readback_ty", "FStar.Pervasives.Native.Some", "Pulse.Syntax.Base.C_Tot", "Pulse.Readback.try_readback_st_comp" ]
[]
false
false
false
false
false
let readback_comp (t: R.term) : option (c: comp{elab_comp c == t}) =
let ropt = try_readback_st_comp t readback_ty in match ropt with | Some c -> ropt | _ -> let? t' = readback_ty t in Some (C_Tot t' <: c: comp{elab_comp c == t})
false
Vale.Math.Bits.fst
Vale.Math.Bits.lemma_i2b_all
val lemma_i2b_all (_:unit) : Lemma lemmas_i2b_all
val lemma_i2b_all (_:unit) : Lemma lemmas_i2b_all
let lemma_i2b_all () = FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_uext #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_and #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_or #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_xor #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_shl #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_shr #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_add #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_sub #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_mul #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_div #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_mod #n a b); ()
{ "file_name": "vale/code/lib/math/Vale.Math.Bits.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 82, "start_col": 0, "start_line": 70 }
module Vale.Math.Bits open FStar.Mul let lemma_pow2_le m n = FStar.Math.Lemmas.pow2_le_compat n m let lemma_i2b_eq #n a b = assert_norm (b_i2b a == b_i2b b ==> int2bv a == int2bv b); int2bv_lemma_2 #n a b let lemma_i2b_uext #n m a = Vale.Lib.Bv_s.int2bv_uext #n #m a (uext #n #m a); assert_norm (b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a)) let lemma_i2b_and #n a b = int2bv_logand #n #a #b #(bvand #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b)) let lemma_i2b_or #n a b = int2bv_logor #n #a #b #(bvor #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (logor #n a b) == b_or #n (b_i2b a) (b_i2b b)) let lemma_i2b_xor #n a b = int2bv_logxor #n #a #b #(bvxor #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (logxor #n a b) == b_xor #n (b_i2b a) (b_i2b b)) let lemma_i2b_shl #n a b = int2bv_shl #n #a #b #(bvshl #n (int2bv #n a) b) (); assert_norm (b_i2b #n (shift_left #n a b) == b_shl #n (b_i2b a) b) let lemma_i2b_shr #n a b = int2bv_shr #n #a #b #(bvshr #n (int2bv #n a) b) (); assert_norm (b_i2b #n (shift_right #n a b) == b_shr #n (b_i2b a) b) let lemma_i2b_add #n a b = int2bv_add #n #a #b #(bvadd #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (add_mod #n a b) == b_add #n (b_i2b a) (b_i2b b)) let lemma_i2b_sub #n a b = int2bv_sub #n #a #b #(bvsub #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (sub_mod #n a b) == b_sub #n (b_i2b a) (b_i2b b)) let lemma_i2b_mul #n a b = int2bv_mul #n #a #b #(bvmul #n (int2bv #n a) b) (); assert_norm (b_i2b #n (mul_mod #n a b) == b_mul #n (b_i2b a) b) let lemma_i2b_div #n a b = int2bv_div #n #a #b #(bvdiv #n (int2bv #n a) b) (); assert_norm (b_i2b #n (udiv #n a b) == b_div #n (b_i2b a) b) let lemma_i2b_mod #n a b = int2bv_mod #n #a #b #(bvmod #n (int2bv #n a) b) (); assert_norm (bvmod #n (int2bv a) b == b_mod #n (b_i2b a) b); assert_norm (int2bv #n (mod #n a b) == b_i2b #n (mod #n a b)); () let add_hide #n a b = if a + b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a + b) (pow2 n); add_mod a b let sub_hide #n a b = if 0 <= a - b then FStar.Math.Lemmas.modulo_lemma (a - b) (pow2 n); sub_mod a b let mul_hide #n a b = FStar.Math.Lemmas.nat_times_nat_is_nat a b; if a * b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a * b) (pow2 n); assert_norm (mul_mod a b == (a * b) % pow2 n); mul_mod a b
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Bv_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Math.Bits.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.BV", "short_module": null }, { "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
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.Math.Bits.lemmas_i2b_all)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "FStar.Classical.forall_intro_3", "Prims.pos", "FStar.UInt.uint_t", "Prims.b2t", "Prims.op_disEquality", "Prims.int", "Prims.eq2", "FStar.BV.bv_t", "Vale.Math.Bits.b_i2b", "FStar.UInt.mod", "Vale.Math.Bits.b_mod", "Vale.Math.Bits.lemma_i2b_mod", "FStar.UInt.udiv", "Vale.Math.Bits.b_div", "Vale.Math.Bits.lemma_i2b_div", "FStar.UInt.mul_mod", "Vale.Math.Bits.b_mul", "Vale.Math.Bits.lemma_i2b_mul", "FStar.UInt.sub_mod", "Vale.Math.Bits.b_sub", "Vale.Math.Bits.lemma_i2b_sub", "FStar.UInt.add_mod", "Vale.Math.Bits.b_add", "Vale.Math.Bits.lemma_i2b_add", "FStar.UInt.shift_right", "Vale.Math.Bits.b_shr", "Vale.Math.Bits.lemma_i2b_shr", "FStar.UInt.shift_left", "Vale.Math.Bits.b_shl", "Vale.Math.Bits.lemma_i2b_shl", "FStar.UInt.logxor", "Vale.Math.Bits.b_xor", "Vale.Math.Bits.lemma_i2b_xor", "FStar.UInt.logor", "Vale.Math.Bits.b_or", "Vale.Math.Bits.lemma_i2b_or", "FStar.UInt.logand", "Vale.Math.Bits.b_and", "Vale.Math.Bits.lemma_i2b_and", "Prims.op_Addition", "Vale.Math.Bits.uext", "Vale.Math.Bits.b_uext", "Vale.Math.Bits.lemma_i2b_uext" ]
[]
false
false
true
false
false
let lemma_i2b_all () =
FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_uext #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_and #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_or #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_xor #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_shl #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_shr #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_add #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_sub #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_mul #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_div #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_mod #n a b); ()
false
Vale.Math.Bits.fst
Vale.Math.Bits.lemma_bveq
val lemma_bveq (#n:pos) (a b:bv_t n) : Lemma (requires bveq #n a b) (ensures a == b)
val lemma_bveq (#n:pos) (a b:bv_t n) : Lemma (requires bveq #n a b) (ensures a == b)
let lemma_bveq #n a b = let ia = bv2int a in let ib = bv2int b in int2bv_logxor #n #ia #ib #(bvxor a b) (); int2bv_logxor #n #ia #ia #(bvxor a a) (); assert (int2bv #n (logxor #n ia ib) == int2bv #n (logxor #n ia ia)); assert (bv2int (int2bv #n (logxor #n ia ib)) == logxor #n ia ib); assert (bv2int (int2bv #n (logxor #n ia ia)) == logxor #n ia ia); assert (logxor #n ia ib == logxor #n ia ia); logxor_self ia; logxor_neq_nonzero ia ib; ()
{ "file_name": "vale/code/lib/math/Vale.Math.Bits.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 103, "start_col": 0, "start_line": 92 }
module Vale.Math.Bits open FStar.Mul let lemma_pow2_le m n = FStar.Math.Lemmas.pow2_le_compat n m let lemma_i2b_eq #n a b = assert_norm (b_i2b a == b_i2b b ==> int2bv a == int2bv b); int2bv_lemma_2 #n a b let lemma_i2b_uext #n m a = Vale.Lib.Bv_s.int2bv_uext #n #m a (uext #n #m a); assert_norm (b_i2b (uext #n #m a) == b_uext #n #m (b_i2b #n a)) let lemma_i2b_and #n a b = int2bv_logand #n #a #b #(bvand #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (logand #n a b) == b_and #n (b_i2b a) (b_i2b b)) let lemma_i2b_or #n a b = int2bv_logor #n #a #b #(bvor #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (logor #n a b) == b_or #n (b_i2b a) (b_i2b b)) let lemma_i2b_xor #n a b = int2bv_logxor #n #a #b #(bvxor #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (logxor #n a b) == b_xor #n (b_i2b a) (b_i2b b)) let lemma_i2b_shl #n a b = int2bv_shl #n #a #b #(bvshl #n (int2bv #n a) b) (); assert_norm (b_i2b #n (shift_left #n a b) == b_shl #n (b_i2b a) b) let lemma_i2b_shr #n a b = int2bv_shr #n #a #b #(bvshr #n (int2bv #n a) b) (); assert_norm (b_i2b #n (shift_right #n a b) == b_shr #n (b_i2b a) b) let lemma_i2b_add #n a b = int2bv_add #n #a #b #(bvadd #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (add_mod #n a b) == b_add #n (b_i2b a) (b_i2b b)) let lemma_i2b_sub #n a b = int2bv_sub #n #a #b #(bvsub #n (int2bv #n a) (int2bv #n b)) (); assert_norm (b_i2b #n (sub_mod #n a b) == b_sub #n (b_i2b a) (b_i2b b)) let lemma_i2b_mul #n a b = int2bv_mul #n #a #b #(bvmul #n (int2bv #n a) b) (); assert_norm (b_i2b #n (mul_mod #n a b) == b_mul #n (b_i2b a) b) let lemma_i2b_div #n a b = int2bv_div #n #a #b #(bvdiv #n (int2bv #n a) b) (); assert_norm (b_i2b #n (udiv #n a b) == b_div #n (b_i2b a) b) let lemma_i2b_mod #n a b = int2bv_mod #n #a #b #(bvmod #n (int2bv #n a) b) (); assert_norm (bvmod #n (int2bv a) b == b_mod #n (b_i2b a) b); assert_norm (int2bv #n (mod #n a b) == b_i2b #n (mod #n a b)); () let add_hide #n a b = if a + b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a + b) (pow2 n); add_mod a b let sub_hide #n a b = if 0 <= a - b then FStar.Math.Lemmas.modulo_lemma (a - b) (pow2 n); sub_mod a b let mul_hide #n a b = FStar.Math.Lemmas.nat_times_nat_is_nat a b; if a * b < pow2 n then FStar.Math.Lemmas.modulo_lemma (a * b) (pow2 n); assert_norm (mul_mod a b == (a * b) % pow2 n); mul_mod a b let lemma_i2b_all () = FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_uext #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_and #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_or #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_xor #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_shl #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_shr #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_add #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_sub #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_mul #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_div #n a b); FStar.Classical.forall_intro_3 (fun n a b -> lemma_i2b_mod #n a b); () let lemma_i2b_with_all n p = lemma_i2b_all () let lemma_i2b_equal #n x y = lemma_i2b_all (); lemma_i2b_eq x y
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Bv_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.Math.Bits.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "FStar.BV", "short_module": null }, { "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": 0, "initial_ifuel": 0, "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": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: FStar.BV.bv_t n -> b: FStar.BV.bv_t n -> FStar.Pervasives.Lemma (requires Vale.Math.Bits.bveq a b) (ensures a == b)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.pos", "FStar.BV.bv_t", "Prims.unit", "FStar.UInt.logxor_neq_nonzero", "FStar.UInt.logxor_self", "Prims._assert", "Prims.eq2", "FStar.UInt.uint_t", "FStar.UInt.logxor", "FStar.BV.bv2int", "FStar.BV.int2bv", "FStar.BV.int2bv_logxor", "FStar.BV.bvxor" ]
[]
true
false
true
false
false
let lemma_bveq #n a b =
let ia = bv2int a in let ib = bv2int b in int2bv_logxor #n #ia #ib #(bvxor a b) (); int2bv_logxor #n #ia #ia #(bvxor a a) (); assert (int2bv #n (logxor #n ia ib) == int2bv #n (logxor #n ia ia)); assert (bv2int (int2bv #n (logxor #n ia ib)) == logxor #n ia ib); assert (bv2int (int2bv #n (logxor #n ia ia)) == logxor #n ia ia); assert (logxor #n ia ib == logxor #n ia ia); logxor_self ia; logxor_neq_nonzero ia ib; ()
false
Pulse.Readback.fst
Pulse.Readback.readback_observability
val readback_observability (t: R.term) : option (obs: observability{elab_observability obs == t})
val readback_observability (t: R.term) : option (obs: observability{elab_observability obs == t})
let readback_observability (t:R.term) : option (obs:observability { elab_observability obs == t }) = let open R in match inspect_ln t with | R.Tv_FVar fv -> let fv_lid = inspect_fv fv in if fv_lid = observable_lid then Some Observable else if fv_lid = unobservable_lid then Some Unobservable else if fv_lid = neutral_lid then Some Neutral else None | _ -> None
{ "file_name": "lib/steel/pulse/Pulse.Readback.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 13, "end_line": 44, "start_col": 0, "start_line": 31 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Readback module R = FStar.Reflection.V2 open Pulse.Syntax.Base open Pulse.Reflection.Util module RU = Pulse.RuntimeUtils module T = FStar.Tactics module P = Pulse.Syntax.Printer let debug_log (f: unit -> T.Tac unit) : T.Tac unit = if RU.debug_at_level_no_module "readback" then f() let (let?) (f:option 'a) (g:'a -> option 'b) : option 'b = match f with | None -> None | Some x -> g x
{ "checked_file": "/", "dependencies": [ "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.Base.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Reflection.Util.fst.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Readback.fst" }
[ { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Base", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": false, "full_module": "Pulse", "short_module": null }, { "abbrev": false, "full_module": "Pulse", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
t: FStar.Stubs.Reflection.Types.term -> FStar.Pervasives.Native.option (obs: Pulse.Syntax.Base.observability{Pulse.Elaborate.Pure.elab_observability obs == t})
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V2.Builtins.inspect_ln", "FStar.Stubs.Reflection.Types.fv", "Prims.op_Equality", "Prims.list", "Prims.string", "Pulse.Reflection.Util.observable_lid", "FStar.Pervasives.Native.Some", "Pulse.Syntax.Base.observability", "Prims.eq2", "Pulse.Elaborate.Pure.elab_observability", "Pulse.Syntax.Base.Observable", "Prims.bool", "Pulse.Reflection.Util.unobservable_lid", "Pulse.Syntax.Base.Unobservable", "Pulse.Reflection.Util.neutral_lid", "Pulse.Syntax.Base.Neutral", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option", "FStar.Stubs.Reflection.Types.name", "FStar.Stubs.Reflection.V2.Builtins.inspect_fv", "FStar.Stubs.Reflection.V2.Data.term_view" ]
[]
false
false
false
false
false
let readback_observability (t: R.term) : option (obs: observability{elab_observability obs == t}) =
let open R in match inspect_ln t with | R.Tv_FVar fv -> let fv_lid = inspect_fv fv in if fv_lid = observable_lid then Some Observable else if fv_lid = unobservable_lid then Some Unobservable else if fv_lid = neutral_lid then Some Neutral else None | _ -> None
false
Hacl.Impl.Curve25519.Lemmas.fst
Hacl.Impl.Curve25519.Lemmas.lemma_nat_from_uints64_le_4
val lemma_nat_from_uints64_le_4: b:lseq uint64 4 -> Lemma (nat_from_intseq_le b == v b.[0] + v b.[1] * pow2 64 + v b.[2] * pow2 64 * pow2 64 + v b.[3] * pow2 64 * pow2 64 * pow2 64)
val lemma_nat_from_uints64_le_4: b:lseq uint64 4 -> Lemma (nat_from_intseq_le b == v b.[0] + v b.[1] * pow2 64 + v b.[2] * pow2 64 * pow2 64 + v b.[3] * pow2 64 * pow2 64 * pow2 64)
let lemma_nat_from_uints64_le_4 b = let res = nat_from_intseq_le b in nat_from_intseq_le_slice_lemma b 1; nat_from_intseq_le_lemma0 (Seq.slice b 0 1); assert (res == v b.[0] + pow2 64 * (nat_from_intseq_le (Seq.slice b 1 4))); nat_from_intseq_le_slice_lemma #U64 #SEC #3 (Seq.slice b 1 4) 1; nat_from_intseq_le_lemma0 (Seq.slice b 1 2); assert (nat_from_intseq_le (Seq.slice b 1 4) == v b.[1] + pow2 64 * (nat_from_intseq_le (Seq.slice b 2 4))); nat_from_intseq_le_slice_lemma #U64 #SEC #2 (Seq.slice b 2 4) 1; nat_from_intseq_le_lemma0 (Seq.slice b 2 3); assert (nat_from_intseq_le (Seq.slice b 2 4) == v b.[2] + pow2 64 * (nat_from_intseq_le (Seq.slice b 3 4))); nat_from_intseq_le_lemma0 (Seq.slice b 3 4); assert (res == v b.[0] + pow2 64 * (v b.[1] + pow2 64 * (v b.[2] + pow2 64 * v b.[3])))
{ "file_name": "code/curve25519/Hacl.Impl.Curve25519.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 89, "end_line": 29, "start_col": 0, "start_line": 14 }
module Hacl.Impl.Curve25519.Lemmas open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val lemma_nat_from_uints64_le_4: b:lseq uint64 4 -> Lemma (nat_from_intseq_le b == v b.[0] + v b.[1] * pow2 64 + v b.[2] * pow2 64 * pow2 64 + v b.[3] * pow2 64 * pow2 64 * pow2 64)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Curve25519.Lemmas.fst" }
[ { "abbrev": false, "full_module": "Lib.ByteSequence", "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.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 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.Sequence.lseq Lib.IntTypes.uint64 4 -> FStar.Pervasives.Lemma (ensures Lib.ByteSequence.nat_from_intseq_le b == Lib.IntTypes.v b.[ 0 ] + Lib.IntTypes.v b.[ 1 ] * Prims.pow2 64 + (Lib.IntTypes.v b.[ 2 ] * Prims.pow2 64) * Prims.pow2 64 + ((Lib.IntTypes.v b.[ 3 ] * Prims.pow2 64) * Prims.pow2 64) * Prims.pow2 64)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Lib.Sequence.lseq", "Lib.IntTypes.uint64", "Prims._assert", "Prims.eq2", "Prims.int", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.Sequence.op_String_Access", "FStar.Mul.op_Star", "Prims.pow2", "Prims.unit", "Lib.ByteSequence.nat_from_intseq_le_lemma0", "FStar.Seq.Base.slice", "Lib.ByteSequence.nat_from_intseq_le", "Lib.ByteSequence.nat_from_intseq_le_slice_lemma", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Multiply", "Lib.Sequence.length", "Lib.IntTypes.int_t" ]
[]
true
false
true
false
false
let lemma_nat_from_uints64_le_4 b =
let res = nat_from_intseq_le b in nat_from_intseq_le_slice_lemma b 1; nat_from_intseq_le_lemma0 (Seq.slice b 0 1); assert (res == v b.[ 0 ] + pow2 64 * (nat_from_intseq_le (Seq.slice b 1 4))); nat_from_intseq_le_slice_lemma #U64 #SEC #3 (Seq.slice b 1 4) 1; nat_from_intseq_le_lemma0 (Seq.slice b 1 2); assert (nat_from_intseq_le (Seq.slice b 1 4) == v b.[ 1 ] + pow2 64 * (nat_from_intseq_le (Seq.slice b 2 4))); nat_from_intseq_le_slice_lemma #U64 #SEC #2 (Seq.slice b 2 4) 1; nat_from_intseq_le_lemma0 (Seq.slice b 2 3); assert (nat_from_intseq_le (Seq.slice b 2 4) == v b.[ 2 ] + pow2 64 * (nat_from_intseq_le (Seq.slice b 3 4))); nat_from_intseq_le_lemma0 (Seq.slice b 3 4); assert (res == v b.[ 0 ] + pow2 64 * (v b.[ 1 ] + pow2 64 * (v b.[ 2 ] + pow2 64 * v b.[ 3 ])))
false
LowParse.SLow.Bytes.fst
LowParse.SLow.Bytes.serialize32_flbytes
val serialize32_flbytes (sz: nat{sz < 4294967296}) : Tot (serializer32 (serialize_flbytes sz))
val serialize32_flbytes (sz: nat{sz < 4294967296}) : Tot (serializer32 (serialize_flbytes sz))
let serialize32_flbytes (sz: nat { sz < 4294967296 } ) : Tot (serializer32 (serialize_flbytes sz)) = fun (input: B32.lbytes sz) -> B32.hide_reveal input; (input <: (res: bytes32 { serializer32_correct (serialize_flbytes sz) input res } ))
{ "file_name": "src/lowparse/LowParse.SLow.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 88, "end_line": 43, "start_col": 0, "start_line": 38 }
module LowParse.SLow.Bytes include LowParse.Spec.Bytes include LowParse.SLow.VLData include LowParse.SLow.VLGen module B32 = FStar.Bytes module Seq = FStar.Seq module U32 = FStar.UInt32 inline_for_extraction let parse32_flbytes_gen (sz: nat { sz < 4294967296 } ) (x: B32.lbytes sz) : Tot (y: B32.lbytes sz { y == parse_flbytes_gen sz (B32.reveal x) } ) = B32.hide_reveal x; x #set-options "--z3rlimit 32" inline_for_extraction let parse32_flbytes (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) : Tot ( lt_pow2_32 sz; parser32 (parse_flbytes sz) ) = lt_pow2_32 sz; make_total_constant_size_parser32 sz sz' #(B32.lbytes sz) (parse_flbytes_gen sz) () (parse32_flbytes_gen sz)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.SLow.VLGen.fst.checked", "LowParse.SLow.VLData.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Bytes.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.SLow.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 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": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
sz: Prims.nat{sz < 4294967296} -> LowParse.SLow.Base.serializer32 (LowParse.Spec.Bytes.serialize_flbytes sz)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "FStar.Bytes.lbytes", "LowParse.SLow.Base.bytes32", "LowParse.SLow.Base.serializer32_correct", "LowParse.Spec.Base.total_constant_size_parser_kind", "LowParse.Spec.Bytes.parse_flbytes", "LowParse.Spec.Bytes.serialize_flbytes", "Prims.unit", "FStar.Bytes.hide_reveal", "LowParse.SLow.Base.serializer32" ]
[]
false
false
false
false
false
let serialize32_flbytes (sz: nat{sz < 4294967296}) : Tot (serializer32 (serialize_flbytes sz)) =
fun (input: B32.lbytes sz) -> B32.hide_reveal input; (input <: (res: bytes32{serializer32_correct (serialize_flbytes sz) input res}))
false
LowParse.SLow.Bytes.fst
LowParse.SLow.Bytes.serialize32_all_bytes
val serialize32_all_bytes:serializer32 serialize_all_bytes
val serialize32_all_bytes:serializer32 serialize_all_bytes
let serialize32_all_bytes : serializer32 serialize_all_bytes = fun (input: B32.bytes) -> (input <: (res: bytes32 { serializer32_correct serialize_all_bytes input res } ))
{ "file_name": "src/lowparse/LowParse.SLow.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 83, "end_line": 56, "start_col": 0, "start_line": 53 }
module LowParse.SLow.Bytes include LowParse.Spec.Bytes include LowParse.SLow.VLData include LowParse.SLow.VLGen module B32 = FStar.Bytes module Seq = FStar.Seq module U32 = FStar.UInt32 inline_for_extraction let parse32_flbytes_gen (sz: nat { sz < 4294967296 } ) (x: B32.lbytes sz) : Tot (y: B32.lbytes sz { y == parse_flbytes_gen sz (B32.reveal x) } ) = B32.hide_reveal x; x #set-options "--z3rlimit 32" inline_for_extraction let parse32_flbytes (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) : Tot ( lt_pow2_32 sz; parser32 (parse_flbytes sz) ) = lt_pow2_32 sz; make_total_constant_size_parser32 sz sz' #(B32.lbytes sz) (parse_flbytes_gen sz) () (parse32_flbytes_gen sz) inline_for_extraction let serialize32_flbytes (sz: nat { sz < 4294967296 } ) : Tot (serializer32 (serialize_flbytes sz)) = fun (input: B32.lbytes sz) -> B32.hide_reveal input; (input <: (res: bytes32 { serializer32_correct (serialize_flbytes sz) input res } )) inline_for_extraction let parse32_all_bytes : parser32 parse_all_bytes = fun (input: B32.bytes) -> let res = Some (input, B32.len input) in (res <: (res: option (bytes32 * U32.t) { parser32_correct parse_all_bytes input res } ))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.SLow.VLGen.fst.checked", "LowParse.SLow.VLData.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Bytes.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.SLow.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 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": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
LowParse.SLow.Base.serializer32 LowParse.Spec.Bytes.serialize_all_bytes
Prims.Tot
[ "total" ]
[]
[ "FStar.Bytes.bytes", "LowParse.SLow.Base.bytes32", "LowParse.SLow.Base.serializer32_correct", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.Bytes.parse_all_bytes", "LowParse.Spec.Bytes.serialize_all_bytes" ]
[]
false
false
false
true
false
let serialize32_all_bytes:serializer32 serialize_all_bytes =
fun (input: B32.bytes) -> (input <: (res: bytes32{serializer32_correct serialize_all_bytes input res}))
false
Pulse.Typing.Printer.fst
Pulse.Typing.Printer.print_st_typing
val print_st_typing (#g #t #c: _) (d: st_typing g t c) : T.Tac string
val print_st_typing (#g #t #c: _) (d: st_typing g t c) : T.Tac string
let rec print_st_typing #g #t #c (d:st_typing g t c) : T.Tac string = match d with | T_Abs g x q b u body c tt body_typing -> Printf.sprintf "(T_Abs ... %s)" (print_st_typing body_typing) | T_STApp _ _ _ _ _ _ _ _ -> "T_STApp" | T_Return _ _ _ _ _ _ _ _ _ _ _ -> "T_Return" | T_Lift _ _ _ _ d _ -> Printf.sprintf "(T_Lift %s)" (print_st_typing d) | T_Bind g e1 e2 c1 c2 b x c d1 _ d2 _ -> Printf.sprintf "(T_Bind %s %s)" (print_st_typing d1) (print_st_typing d2) | T_Frame g e c frame _ body -> Printf.sprintf "(T_Frame %s %s)" (Pulse.Syntax.Printer.term_to_string frame) (print_st_typing body) | T_If _ _ _ _ _ _ _ _ _ _ -> "T_If" | T_Match _ _ _ _ _ _ _ _ _ _ _ -> "T_Match" | T_Equiv g e c c' d eq -> Printf.sprintf "(T_Equiv %s)" (print_st_typing d) // Printf.sprintf "(T_Equiv \n\t{%s}\n\t{%s}\n\t %s)" // (Pulse.Syntax.Printer.comp_to_string c) // (Pulse.Syntax.Printer.comp_to_string c') // (print_st_typing d) | T_IntroPure _ _ _ _ -> "T_IntroPure" | T_Rewrite _ _ _ _ _ -> "T_Rewrite" | _ -> "<UNK>"
{ "file_name": "lib/steel/pulse/Pulse.Typing.Printer.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 18, "end_line": 65, "start_col": 0, "start_line": 24 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Typing.Printer module T = FStar.Tactics open Pulse.Syntax.Printer open Pulse.Typing
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Pulse.Typing.Printer.fst" }
[ { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax.Printer", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
d: Pulse.Typing.st_typing g t c -> FStar.Tactics.Effect.Tac Prims.string
FStar.Tactics.Effect.Tac
[]
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.st_term", "Pulse.Syntax.Base.comp", "Pulse.Typing.st_typing", "Pulse.Syntax.Base.var", "Prims.b2t", "FStar.Pervasives.Native.uu___is_None", "Pulse.Syntax.Base.typ", "Pulse.Typing.Env.lookup", "FStar.Pervasives.Native.option", "Pulse.Syntax.Base.qualifier", "Pulse.Syntax.Base.binder", "Pulse.Syntax.Base.universe", "Prims.l_not", "FStar.Set.mem", "Pulse.Syntax.Naming.freevars_st", "Pulse.Typing.tot_typing", "Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ty", "Pulse.Syntax.Pure.tm_type", "Pulse.Typing.Env.push_binding", "Pulse.Syntax.Base.ppname_default", "Pulse.Syntax.Naming.open_st_term_nv", "FStar.Pervasives.Native.Mktuple2", "Pulse.Syntax.Base.ppname", "Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ppname", "FStar.Printf.sprintf", "Prims.string", "Pulse.Typing.Printer.print_st_typing", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.comp_st", "Pulse.Syntax.Pure.tm_arrow", "Pulse.Syntax.Base.as_binder", "Pulse.Syntax.Base.ctag", "Prims.bool", "Prims.l_and", "Pulse.Syntax.Naming.freevars", "Pulse.Typing.universe_of", "Pulse.Typing.typing", "Pulse.Typing.eff_of_ctag", "Pulse.Syntax.Naming.open_term", "Pulse.Syntax.Base.tm_vprop", "Pulse.Typing.lift_comp", "Prims.eq2", "Pulse.Syntax.Base.comp_res", "Pulse.Syntax.Base.comp_u", "Pulse.Typing.bind_comp", "Pulse.Syntax.Printer.term_to_string", "FStar.Set.union", "Pulse.Typing.tm_bool", "Pulse.Typing.mk_eq2", "Pulse.Syntax.Pure.u0", "Pulse.Typing.tm_true", "Pulse.Typing.tm_false", "Pulse.Typing.my_erased", "Pulse.Typing.comp_typing_u", "Prims.list", "FStar.Pervasives.Native.tuple2", "Pulse.Syntax.Base.pattern", "Pulse.Typing.brs_typing", "Pulse.Typing.pats_complete", "FStar.List.Tot.Base.map", "FStar.Stubs.Reflection.V2.Data.pattern", "Pulse.Elaborate.Pure.elab_pat", "Pulse.Typing.st_equiv", "Pulse.Typing.tm_prop", "Pulse.Typing.prop_validity", "Pulse.Syntax.Base.vprop", "Pulse.Typing.vprop_equiv" ]
[ "recursion" ]
false
true
false
false
false
let rec print_st_typing #g #t #c (d: st_typing g t c) : T.Tac string =
match d with | T_Abs g x q b u body c tt body_typing -> Printf.sprintf "(T_Abs ... %s)" (print_st_typing body_typing) | T_STApp _ _ _ _ _ _ _ _ -> "T_STApp" | T_Return _ _ _ _ _ _ _ _ _ _ _ -> "T_Return" | T_Lift _ _ _ _ d _ -> Printf.sprintf "(T_Lift %s)" (print_st_typing d) | T_Bind g e1 e2 c1 c2 b x c d1 _ d2 _ -> Printf.sprintf "(T_Bind %s %s)" (print_st_typing d1) (print_st_typing d2) | T_Frame g e c frame _ body -> Printf.sprintf "(T_Frame %s %s)" (Pulse.Syntax.Printer.term_to_string frame) (print_st_typing body) | T_If _ _ _ _ _ _ _ _ _ _ -> "T_If" | T_Match _ _ _ _ _ _ _ _ _ _ _ -> "T_Match" | T_Equiv g e c c' d eq -> Printf.sprintf "(T_Equiv %s)" (print_st_typing d) | T_IntroPure _ _ _ _ -> "T_IntroPure" | T_Rewrite _ _ _ _ _ -> "T_Rewrite" | _ -> "<UNK>"
false
Vale.AES.PPC64LE.GF128_Init.fsti
Vale.AES.PPC64LE.GF128_Init.va_ens_Keyhash_init
val va_ens_Keyhash_init (va_b0: va_code) (va_s0: va_state) (alg: algorithm) (key: (seq nat32)) (roundkeys_b hkeys_b: buffer128) (va_sM: va_state) (va_fM: va_fuel) : prop
val va_ens_Keyhash_init (va_b0: va_code) (va_s0: va_state) (alg: algorithm) (key: (seq nat32)) (roundkeys_b hkeys_b: buffer128) (va_sM: va_state) (va_fM: va_fuel) : prop
let va_ens_Keyhash_init (va_b0:va_code) (va_s0:va_state) (alg:algorithm) (key:(seq nat32)) (roundkeys_b:buffer128) (hkeys_b:buffer128) (va_sM:va_state) (va_fM:va_fuel) : prop = (va_req_Keyhash_init va_b0 va_s0 alg key roundkeys_b hkeys_b /\ va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.PPC64LE.Decls.modifies_buffer128 hkeys_b (va_get_mem va_s0) (va_get_mem va_sM) /\ Vale.AES.OptPublic_BE.hkeys_reqs_pub (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem va_sM) hkeys_b)) (Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)) /\ va_state_eq va_sM (va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_mem_layout va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))
{ "file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 63, "end_line": 57, "start_col": 0, "start_line": 47 }
module Vale.AES.PPC64LE.GF128_Init open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open FStar.Seq open Vale.Arch.Types open Vale.Arch.HeapImpl open Vale.Math.Poly2_s open Vale.Math.Poly2 open Vale.Math.Poly2.Bits_s open Vale.Math.Poly2.Bits open Vale.Math.Poly2.Lemmas open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.AES.GHash_BE open Vale.AES.AES_BE_s open Vale.AES.AES256_helpers_BE open Vale.AES.PPC64LE.AES open Vale.PPC64LE.Machine_s open Vale.PPC64LE.Memory open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.InsBasic open Vale.PPC64LE.InsMem open Vale.PPC64LE.InsVector open Vale.PPC64LE.QuickCode open Vale.PPC64LE.QuickCodes open Vale.AES.PPC64LE.PolyOps open Vale.AES.PPC64LE.GF128_Mul open Vale.AES.OptPublic_BE //-- Keyhash_init val va_code_Keyhash_init : alg:algorithm -> Tot va_code val va_codegen_success_Keyhash_init : alg:algorithm -> Tot va_pbool let va_req_Keyhash_init (va_b0:va_code) (va_s0:va_state) (alg:algorithm) (key:(seq nat32)) (roundkeys_b:buffer128) (hkeys_b:buffer128) : prop = (va_require_total va_b0 (va_code_Keyhash_init alg) va_s0 /\ va_get_ok va_s0 /\ Vale.PPC64LE.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (alg = AES_128 \/ alg = AES_256) /\ Vale.PPC64LE.Decls.buffers_disjoint128 roundkeys_b hkeys_b /\ Vale.AES.AES_BE_s.is_aes_key_word alg key /\ Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.buffer128_as_seq (va_get_mem va_s0) roundkeys_b) == Vale.AES.AES_BE_s.key_to_round_keys_word alg key /\ Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem va_s0) (va_get_reg 4 va_s0) roundkeys_b (Vale.AES.AES_common_s.nr alg + 1) (va_get_mem_layout va_s0) Secret /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem va_s0)
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.QuickCodes.fsti.checked", "Vale.PPC64LE.QuickCode.fst.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.InsVector.fsti.checked", "Vale.PPC64LE.InsMem.fsti.checked", "Vale.PPC64LE.InsBasic.fsti.checked", "Vale.PPC64LE.Decls.fsti.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Lemmas.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Math.Poly2.Bits.fsti.checked", "Vale.Math.Poly2.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.AES.PPC64LE.PolyOps.fsti.checked", "Vale.AES.PPC64LE.GF128_Mul.fsti.checked", "Vale.AES.PPC64LE.AES.fsti.checked", "Vale.AES.OptPublic_BE.fsti.checked", "Vale.AES.GHash_BE.fsti.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "Vale.AES.AES_BE_s.fst.checked", "Vale.AES.AES256_helpers_BE.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.AES.PPC64LE.GF128_Init.fsti" }
[ { "abbrev": false, "full_module": "Vale.AES.OptPublic_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE.PolyOps", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES256_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_BE", "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.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_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": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
va_b0: Vale.PPC64LE.Decls.va_code -> va_s0: Vale.PPC64LE.Decls.va_state -> alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.PPC64LE.Memory.nat32 -> roundkeys_b: Vale.PPC64LE.Memory.buffer128 -> hkeys_b: Vale.PPC64LE.Memory.buffer128 -> va_sM: Vale.PPC64LE.Decls.va_state -> va_fM: Vale.PPC64LE.Decls.va_fuel -> Prims.prop
Prims.Tot
[ "total" ]
[]
[ "Vale.PPC64LE.Decls.va_code", "Vale.PPC64LE.Decls.va_state", "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.PPC64LE.Memory.nat32", "Vale.PPC64LE.Memory.buffer128", "Vale.PPC64LE.Decls.va_fuel", "Prims.l_and", "Vale.AES.PPC64LE.GF128_Init.va_req_Keyhash_init", "Vale.PPC64LE.Decls.va_ensure_total", "Prims.b2t", "Vale.PPC64LE.Decls.va_get_ok", "Vale.PPC64LE.Decls.modifies_buffer128", "Vale.PPC64LE.Decls.va_get_mem", "Vale.AES.OptPublic_BE.hkeys_reqs_pub", "Vale.Arch.Types.reverse_bytes_quad32_seq", "Vale.PPC64LE.Decls.s128", "Vale.AES.AES_BE_s.aes_encrypt_word", "Vale.Def.Words_s.Mkfour", "Vale.Def.Types_s.nat32", "Vale.PPC64LE.Decls.va_state_eq", "Vale.PPC64LE.Decls.va_update_vec", "Vale.PPC64LE.Decls.va_update_reg", "Vale.PPC64LE.Decls.va_update_mem_layout", "Vale.PPC64LE.Decls.va_update_mem_heaplet", "Vale.PPC64LE.Decls.va_update_ok", "Vale.PPC64LE.Decls.va_update_mem", "Prims.prop" ]
[]
false
false
false
true
true
let va_ens_Keyhash_init (va_b0: va_code) (va_s0: va_state) (alg: algorithm) (key: (seq nat32)) (roundkeys_b hkeys_b: buffer128) (va_sM: va_state) (va_fM: va_fuel) : prop =
(va_req_Keyhash_init va_b0 va_s0 alg key roundkeys_b hkeys_b /\ va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.PPC64LE.Decls.modifies_buffer128 hkeys_b (va_get_mem va_s0) (va_get_mem va_sM) /\ Vale.AES.OptPublic_BE.hkeys_reqs_pub (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem va_sM) hkeys_b)) (Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)) /\ va_state_eq va_sM (va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_mem_layout va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))) )))
false
LowParse.SLow.Bytes.fst
LowParse.SLow.Bytes.parse32_flbytes_gen
val parse32_flbytes_gen (sz: nat{sz < 4294967296}) (x: B32.lbytes sz) : Tot (y: B32.lbytes sz {y == parse_flbytes_gen sz (B32.reveal x)})
val parse32_flbytes_gen (sz: nat{sz < 4294967296}) (x: B32.lbytes sz) : Tot (y: B32.lbytes sz {y == parse_flbytes_gen sz (B32.reveal x)})
let parse32_flbytes_gen (sz: nat { sz < 4294967296 } ) (x: B32.lbytes sz) : Tot (y: B32.lbytes sz { y == parse_flbytes_gen sz (B32.reveal x) } ) = B32.hide_reveal x; x
{ "file_name": "src/lowparse/LowParse.SLow.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 3, "end_line": 16, "start_col": 0, "start_line": 11 }
module LowParse.SLow.Bytes include LowParse.Spec.Bytes include LowParse.SLow.VLData include LowParse.SLow.VLGen module B32 = FStar.Bytes module Seq = FStar.Seq module U32 = FStar.UInt32
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.SLow.VLGen.fst.checked", "LowParse.SLow.VLData.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Bytes.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.SLow.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
sz: Prims.nat{sz < 4294967296} -> x: FStar.Bytes.lbytes sz -> y: FStar.Bytes.lbytes sz {y == LowParse.Spec.Bytes.parse_flbytes_gen sz (FStar.Bytes.reveal x)}
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "FStar.Bytes.lbytes", "Prims.unit", "FStar.Bytes.hide_reveal", "Prims.eq2", "LowParse.Spec.Bytes.parse_flbytes_gen", "FStar.Bytes.reveal" ]
[]
false
false
false
false
false
let parse32_flbytes_gen (sz: nat{sz < 4294967296}) (x: B32.lbytes sz) : Tot (y: B32.lbytes sz {y == parse_flbytes_gen sz (B32.reveal x)}) =
B32.hide_reveal x; x
false
LowParse.SLow.Bytes.fst
LowParse.SLow.Bytes.parse32_bounded_vlbytes
val parse32_bounded_vlbytes (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (max32: U32.t{U32.v max32 == max}) : Tot (parser32 (parse_bounded_vlbytes min max))
val parse32_bounded_vlbytes (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (max32: U32.t{U32.v max32 == max}) : Tot (parser32 (parse_bounded_vlbytes min max))
let parse32_bounded_vlbytes (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (max32: U32.t { U32.v max32 == max } ) : Tot (parser32 (parse_bounded_vlbytes min max)) = parse32_bounded_vlbytes' min min32 max max32 (log256' max)
{ "file_name": "src/lowparse/LowParse.SLow.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 60, "end_line": 80, "start_col": 0, "start_line": 74 }
module LowParse.SLow.Bytes include LowParse.Spec.Bytes include LowParse.SLow.VLData include LowParse.SLow.VLGen module B32 = FStar.Bytes module Seq = FStar.Seq module U32 = FStar.UInt32 inline_for_extraction let parse32_flbytes_gen (sz: nat { sz < 4294967296 } ) (x: B32.lbytes sz) : Tot (y: B32.lbytes sz { y == parse_flbytes_gen sz (B32.reveal x) } ) = B32.hide_reveal x; x #set-options "--z3rlimit 32" inline_for_extraction let parse32_flbytes (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) : Tot ( lt_pow2_32 sz; parser32 (parse_flbytes sz) ) = lt_pow2_32 sz; make_total_constant_size_parser32 sz sz' #(B32.lbytes sz) (parse_flbytes_gen sz) () (parse32_flbytes_gen sz) inline_for_extraction let serialize32_flbytes (sz: nat { sz < 4294967296 } ) : Tot (serializer32 (serialize_flbytes sz)) = fun (input: B32.lbytes sz) -> B32.hide_reveal input; (input <: (res: bytes32 { serializer32_correct (serialize_flbytes sz) input res } )) inline_for_extraction let parse32_all_bytes : parser32 parse_all_bytes = fun (input: B32.bytes) -> let res = Some (input, B32.len input) in (res <: (res: option (bytes32 * U32.t) { parser32_correct parse_all_bytes input res } )) inline_for_extraction let serialize32_all_bytes : serializer32 serialize_all_bytes = fun (input: B32.bytes) -> (input <: (res: bytes32 { serializer32_correct serialize_all_bytes input res } )) inline_for_extraction let parse32_bounded_vlbytes' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (parser32 (parse_bounded_vlbytes' min max l)) = parse32_synth _ (synth_bounded_vlbytes min max) (fun (x: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) -> (x <: parse_bounded_vlbytes_t min max)) (parse32_bounded_vldata_strong' min min32 max max32 l serialize_all_bytes parse32_all_bytes) ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.SLow.VLGen.fst.checked", "LowParse.SLow.VLData.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Bytes.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.SLow.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 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": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
min: Prims.nat -> min32: FStar.UInt32.t{FStar.UInt32.v min32 == min} -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} -> max32: FStar.UInt32.t{FStar.UInt32.v max32 == max} -> LowParse.SLow.Base.parser32 (LowParse.Spec.Bytes.parse_bounded_vlbytes min max)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "FStar.UInt32.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.UInt32.v", "Prims.l_and", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "LowParse.SLow.Bytes.parse32_bounded_vlbytes'", "LowParse.Spec.BoundedInt.log256'", "LowParse.SLow.Base.parser32", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.Bytes.parse_bounded_vlbytes" ]
[]
false
false
false
false
false
let parse32_bounded_vlbytes (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (max32: U32.t{U32.v max32 == max}) : Tot (parser32 (parse_bounded_vlbytes min max)) =
parse32_bounded_vlbytes' min min32 max max32 (log256' max)
false
Vale.AES.PPC64LE.GF128_Init.fsti
Vale.AES.PPC64LE.GF128_Init.va_req_Keyhash_init
val va_req_Keyhash_init (va_b0: va_code) (va_s0: va_state) (alg: algorithm) (key: (seq nat32)) (roundkeys_b hkeys_b: buffer128) : prop
val va_req_Keyhash_init (va_b0: va_code) (va_s0: va_state) (alg: algorithm) (key: (seq nat32)) (roundkeys_b hkeys_b: buffer128) : prop
let va_req_Keyhash_init (va_b0:va_code) (va_s0:va_state) (alg:algorithm) (key:(seq nat32)) (roundkeys_b:buffer128) (hkeys_b:buffer128) : prop = (va_require_total va_b0 (va_code_Keyhash_init alg) va_s0 /\ va_get_ok va_s0 /\ Vale.PPC64LE.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (alg = AES_128 \/ alg = AES_256) /\ Vale.PPC64LE.Decls.buffers_disjoint128 roundkeys_b hkeys_b /\ Vale.AES.AES_BE_s.is_aes_key_word alg key /\ Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.buffer128_as_seq (va_get_mem va_s0) roundkeys_b) == Vale.AES.AES_BE_s.key_to_round_keys_word alg key /\ Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem va_s0) (va_get_reg 4 va_s0) roundkeys_b (Vale.AES.AES_common_s.nr alg + 1) (va_get_mem_layout va_s0) Secret /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem va_s0) (va_get_reg 3 va_s0) hkeys_b 3 (va_get_mem_layout va_s0) Secret)
{ "file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 68, "end_line": 46, "start_col": 0, "start_line": 36 }
module Vale.AES.PPC64LE.GF128_Init open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open FStar.Seq open Vale.Arch.Types open Vale.Arch.HeapImpl open Vale.Math.Poly2_s open Vale.Math.Poly2 open Vale.Math.Poly2.Bits_s open Vale.Math.Poly2.Bits open Vale.Math.Poly2.Lemmas open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.AES.GHash_BE open Vale.AES.AES_BE_s open Vale.AES.AES256_helpers_BE open Vale.AES.PPC64LE.AES open Vale.PPC64LE.Machine_s open Vale.PPC64LE.Memory open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.InsBasic open Vale.PPC64LE.InsMem open Vale.PPC64LE.InsVector open Vale.PPC64LE.QuickCode open Vale.PPC64LE.QuickCodes open Vale.AES.PPC64LE.PolyOps open Vale.AES.PPC64LE.GF128_Mul open Vale.AES.OptPublic_BE //-- Keyhash_init val va_code_Keyhash_init : alg:algorithm -> Tot va_code
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.QuickCodes.fsti.checked", "Vale.PPC64LE.QuickCode.fst.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.InsVector.fsti.checked", "Vale.PPC64LE.InsMem.fsti.checked", "Vale.PPC64LE.InsBasic.fsti.checked", "Vale.PPC64LE.Decls.fsti.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Lemmas.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Math.Poly2.Bits.fsti.checked", "Vale.Math.Poly2.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.AES.PPC64LE.PolyOps.fsti.checked", "Vale.AES.PPC64LE.GF128_Mul.fsti.checked", "Vale.AES.PPC64LE.AES.fsti.checked", "Vale.AES.OptPublic_BE.fsti.checked", "Vale.AES.GHash_BE.fsti.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "Vale.AES.AES_BE_s.fst.checked", "Vale.AES.AES256_helpers_BE.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.AES.PPC64LE.GF128_Init.fsti" }
[ { "abbrev": false, "full_module": "Vale.AES.OptPublic_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE.PolyOps", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES256_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_BE", "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.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_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": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
va_b0: Vale.PPC64LE.Decls.va_code -> va_s0: Vale.PPC64LE.Decls.va_state -> alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.PPC64LE.Memory.nat32 -> roundkeys_b: Vale.PPC64LE.Memory.buffer128 -> hkeys_b: Vale.PPC64LE.Memory.buffer128 -> Prims.prop
Prims.Tot
[ "total" ]
[]
[ "Vale.PPC64LE.Decls.va_code", "Vale.PPC64LE.Decls.va_state", "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.PPC64LE.Memory.nat32", "Vale.PPC64LE.Memory.buffer128", "Prims.l_and", "Vale.PPC64LE.Decls.va_require_total", "Vale.AES.PPC64LE.GF128_Init.va_code_Keyhash_init", "Prims.b2t", "Vale.PPC64LE.Decls.va_get_ok", "Vale.PPC64LE.Memory.is_initial_heap", "Vale.PPC64LE.Decls.va_get_mem_layout", "Vale.PPC64LE.Decls.va_get_mem", "Prims.l_or", "Prims.op_Equality", "Vale.AES.AES_common_s.AES_128", "Vale.AES.AES_common_s.AES_256", "Vale.PPC64LE.Decls.buffers_disjoint128", "Vale.AES.AES_BE_s.is_aes_key_word", "Prims.eq2", "Vale.Def.Types_s.quad32", "Vale.Arch.Types.reverse_bytes_quad32_seq", "Vale.PPC64LE.Decls.buffer128_as_seq", "Vale.AES.AES_BE_s.key_to_round_keys_word", "Vale.PPC64LE.Decls.validSrcAddrs128", "Vale.PPC64LE.Decls.va_get_reg", "Prims.op_Addition", "Vale.AES.AES_common_s.nr", "Vale.Arch.HeapTypes_s.Secret", "Vale.PPC64LE.Decls.validDstAddrs128", "Prims.prop" ]
[]
false
false
false
true
true
let va_req_Keyhash_init (va_b0: va_code) (va_s0: va_state) (alg: algorithm) (key: (seq nat32)) (roundkeys_b hkeys_b: buffer128) : prop =
(va_require_total va_b0 (va_code_Keyhash_init alg) va_s0 /\ va_get_ok va_s0 /\ Vale.PPC64LE.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (alg = AES_128 \/ alg = AES_256) /\ Vale.PPC64LE.Decls.buffers_disjoint128 roundkeys_b hkeys_b /\ Vale.AES.AES_BE_s.is_aes_key_word alg key /\ Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.buffer128_as_seq (va_get_mem va_s0) roundkeys_b) == Vale.AES.AES_BE_s.key_to_round_keys_word alg key /\ Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem va_s0) (va_get_reg 4 va_s0) roundkeys_b (Vale.AES.AES_common_s.nr alg + 1) (va_get_mem_layout va_s0) Secret /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem va_s0) (va_get_reg 3 va_s0) hkeys_b 3 (va_get_mem_layout va_s0) Secret)
false
Vale.AES.PPC64LE.GF128_Init.fsti
Vale.AES.PPC64LE.GF128_Init.va_quick_Keyhash_init
val va_quick_Keyhash_init (alg: algorithm) (key: (seq nat32)) (roundkeys_b hkeys_b: buffer128) : (va_quickCode unit (va_code_Keyhash_init alg))
val va_quick_Keyhash_init (alg: algorithm) (key: (seq nat32)) (roundkeys_b hkeys_b: buffer128) : (va_quickCode unit (va_code_Keyhash_init alg))
let va_quick_Keyhash_init (alg:algorithm) (key:(seq nat32)) (roundkeys_b:buffer128) (hkeys_b:buffer128) : (va_quickCode unit (va_code_Keyhash_init alg)) = (va_QProc (va_code_Keyhash_init alg) ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_mem]) (va_wp_Keyhash_init alg key roundkeys_b hkeys_b) (va_wpProof_Keyhash_init alg key roundkeys_b hkeys_b))
{ "file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 29, "end_line": 116, "start_col": 0, "start_line": 111 }
module Vale.AES.PPC64LE.GF128_Init open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open FStar.Seq open Vale.Arch.Types open Vale.Arch.HeapImpl open Vale.Math.Poly2_s open Vale.Math.Poly2 open Vale.Math.Poly2.Bits_s open Vale.Math.Poly2.Bits open Vale.Math.Poly2.Lemmas open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.AES.GHash_BE open Vale.AES.AES_BE_s open Vale.AES.AES256_helpers_BE open Vale.AES.PPC64LE.AES open Vale.PPC64LE.Machine_s open Vale.PPC64LE.Memory open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.InsBasic open Vale.PPC64LE.InsMem open Vale.PPC64LE.InsVector open Vale.PPC64LE.QuickCode open Vale.PPC64LE.QuickCodes open Vale.AES.PPC64LE.PolyOps open Vale.AES.PPC64LE.GF128_Mul open Vale.AES.OptPublic_BE //-- Keyhash_init val va_code_Keyhash_init : alg:algorithm -> Tot va_code val va_codegen_success_Keyhash_init : alg:algorithm -> Tot va_pbool let va_req_Keyhash_init (va_b0:va_code) (va_s0:va_state) (alg:algorithm) (key:(seq nat32)) (roundkeys_b:buffer128) (hkeys_b:buffer128) : prop = (va_require_total va_b0 (va_code_Keyhash_init alg) va_s0 /\ va_get_ok va_s0 /\ Vale.PPC64LE.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (alg = AES_128 \/ alg = AES_256) /\ Vale.PPC64LE.Decls.buffers_disjoint128 roundkeys_b hkeys_b /\ Vale.AES.AES_BE_s.is_aes_key_word alg key /\ Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.buffer128_as_seq (va_get_mem va_s0) roundkeys_b) == Vale.AES.AES_BE_s.key_to_round_keys_word alg key /\ Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem va_s0) (va_get_reg 4 va_s0) roundkeys_b (Vale.AES.AES_common_s.nr alg + 1) (va_get_mem_layout va_s0) Secret /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem va_s0) (va_get_reg 3 va_s0) hkeys_b 3 (va_get_mem_layout va_s0) Secret) let va_ens_Keyhash_init (va_b0:va_code) (va_s0:va_state) (alg:algorithm) (key:(seq nat32)) (roundkeys_b:buffer128) (hkeys_b:buffer128) (va_sM:va_state) (va_fM:va_fuel) : prop = (va_req_Keyhash_init va_b0 va_s0 alg key roundkeys_b hkeys_b /\ va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.PPC64LE.Decls.modifies_buffer128 hkeys_b (va_get_mem va_s0) (va_get_mem va_sM) /\ Vale.AES.OptPublic_BE.hkeys_reqs_pub (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem va_sM) hkeys_b)) (Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)) /\ va_state_eq va_sM (va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_mem_layout va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))) val va_lemma_Keyhash_init : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> key:(seq nat32) -> roundkeys_b:buffer128 -> hkeys_b:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Keyhash_init alg) va_s0 /\ va_get_ok va_s0 /\ Vale.PPC64LE.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (alg = AES_128 \/ alg = AES_256) /\ Vale.PPC64LE.Decls.buffers_disjoint128 roundkeys_b hkeys_b /\ Vale.AES.AES_BE_s.is_aes_key_word alg key /\ Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.buffer128_as_seq (va_get_mem va_s0) roundkeys_b) == Vale.AES.AES_BE_s.key_to_round_keys_word alg key /\ Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem va_s0) (va_get_reg 4 va_s0) roundkeys_b (Vale.AES.AES_common_s.nr alg + 1) (va_get_mem_layout va_s0) Secret /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem va_s0) (va_get_reg 3 va_s0) hkeys_b 3 (va_get_mem_layout va_s0) Secret)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.PPC64LE.Decls.modifies_buffer128 hkeys_b (va_get_mem va_s0) (va_get_mem va_sM) /\ Vale.AES.OptPublic_BE.hkeys_reqs_pub (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem va_sM) hkeys_b)) (Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)) /\ va_state_eq va_sM (va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_mem_layout va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))) [@ va_qattr] let va_wp_Keyhash_init (alg:algorithm) (key:(seq nat32)) (roundkeys_b:buffer128) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.PPC64LE.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (alg = AES_128 \/ alg = AES_256) /\ Vale.PPC64LE.Decls.buffers_disjoint128 roundkeys_b hkeys_b /\ Vale.AES.AES_BE_s.is_aes_key_word alg key /\ Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.buffer128_as_seq (va_get_mem va_s0) roundkeys_b) == Vale.AES.AES_BE_s.key_to_round_keys_word alg key /\ Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem va_s0) (va_get_reg 4 va_s0) roundkeys_b (Vale.AES.AES_common_s.nr alg + 1) (va_get_mem_layout va_s0) Secret /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem va_s0) (va_get_reg 3 va_s0) hkeys_b 3 (va_get_mem_layout va_s0) Secret /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_memLayout:vale_heap_layout) (va_x_r10:nat64) (va_x_v0:quad32) (va_x_v1:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) (va_x_v5:quad32) (va_x_v6:quad32) . let va_sM = va_upd_vec 6 va_x_v6 (va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1 (va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 (va_upd_mem_layout va_x_memLayout (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0)))))))))) in va_get_ok va_sM /\ Vale.PPC64LE.Decls.modifies_buffer128 hkeys_b (va_get_mem va_s0) (va_get_mem va_sM) /\ Vale.AES.OptPublic_BE.hkeys_reqs_pub (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem va_sM) hkeys_b)) (Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)) ==> va_k va_sM (()))) val va_wpProof_Keyhash_init : alg:algorithm -> key:(seq nat32) -> roundkeys_b:buffer128 -> hkeys_b:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Keyhash_init alg key roundkeys_b hkeys_b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Keyhash_init alg) ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.QuickCodes.fsti.checked", "Vale.PPC64LE.QuickCode.fst.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.InsVector.fsti.checked", "Vale.PPC64LE.InsMem.fsti.checked", "Vale.PPC64LE.InsBasic.fsti.checked", "Vale.PPC64LE.Decls.fsti.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Lemmas.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Math.Poly2.Bits.fsti.checked", "Vale.Math.Poly2.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.AES.PPC64LE.PolyOps.fsti.checked", "Vale.AES.PPC64LE.GF128_Mul.fsti.checked", "Vale.AES.PPC64LE.AES.fsti.checked", "Vale.AES.OptPublic_BE.fsti.checked", "Vale.AES.GHash_BE.fsti.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "Vale.AES.AES_BE_s.fst.checked", "Vale.AES.AES256_helpers_BE.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.AES.PPC64LE.GF128_Init.fsti" }
[ { "abbrev": false, "full_module": "Vale.AES.OptPublic_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE.PolyOps", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES256_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_BE", "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.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_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": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.PPC64LE.Memory.nat32 -> roundkeys_b: Vale.PPC64LE.Memory.buffer128 -> hkeys_b: Vale.PPC64LE.Memory.buffer128 -> Vale.PPC64LE.QuickCode.va_quickCode Prims.unit (Vale.AES.PPC64LE.GF128_Init.va_code_Keyhash_init alg)
Prims.Tot
[ "total" ]
[]
[ "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.PPC64LE.Memory.nat32", "Vale.PPC64LE.Memory.buffer128", "Vale.PPC64LE.QuickCode.va_QProc", "Prims.unit", "Vale.AES.PPC64LE.GF128_Init.va_code_Keyhash_init", "Prims.Cons", "Vale.PPC64LE.QuickCode.mod_t", "Vale.PPC64LE.QuickCode.va_Mod_vec", "Vale.PPC64LE.QuickCode.va_Mod_reg", "Vale.PPC64LE.QuickCode.va_Mod_mem_layout", "Vale.PPC64LE.QuickCode.va_Mod_mem_heaplet", "Vale.PPC64LE.QuickCode.va_Mod_mem", "Prims.Nil", "Vale.AES.PPC64LE.GF128_Init.va_wp_Keyhash_init", "Vale.AES.PPC64LE.GF128_Init.va_wpProof_Keyhash_init", "Vale.PPC64LE.QuickCode.va_quickCode" ]
[]
false
false
false
false
false
let va_quick_Keyhash_init (alg: algorithm) (key: (seq nat32)) (roundkeys_b hkeys_b: buffer128) : (va_quickCode unit (va_code_Keyhash_init alg)) =
(va_QProc (va_code_Keyhash_init alg) ([ va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_mem ]) (va_wp_Keyhash_init alg key roundkeys_b hkeys_b) (va_wpProof_Keyhash_init alg key roundkeys_b hkeys_b))
false
LowParse.SLow.Bytes.fst
LowParse.SLow.Bytes.parse32_bounded_vlbytes'
val parse32_bounded_vlbytes' (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (max32: U32.t{U32.v max32 == max}) (l: nat{l >= log256' max /\ l <= 4}) : Tot (parser32 (parse_bounded_vlbytes' min max l))
val parse32_bounded_vlbytes' (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (max32: U32.t{U32.v max32 == max}) (l: nat{l >= log256' max /\ l <= 4}) : Tot (parser32 (parse_bounded_vlbytes' min max l))
let parse32_bounded_vlbytes' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (parser32 (parse_bounded_vlbytes' min max l)) = parse32_synth _ (synth_bounded_vlbytes min max) (fun (x: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) -> (x <: parse_bounded_vlbytes_t min max)) (parse32_bounded_vldata_strong' min min32 max max32 l serialize_all_bytes parse32_all_bytes) ()
{ "file_name": "src/lowparse/LowParse.SLow.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 6, "end_line": 71, "start_col": 0, "start_line": 59 }
module LowParse.SLow.Bytes include LowParse.Spec.Bytes include LowParse.SLow.VLData include LowParse.SLow.VLGen module B32 = FStar.Bytes module Seq = FStar.Seq module U32 = FStar.UInt32 inline_for_extraction let parse32_flbytes_gen (sz: nat { sz < 4294967296 } ) (x: B32.lbytes sz) : Tot (y: B32.lbytes sz { y == parse_flbytes_gen sz (B32.reveal x) } ) = B32.hide_reveal x; x #set-options "--z3rlimit 32" inline_for_extraction let parse32_flbytes (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) : Tot ( lt_pow2_32 sz; parser32 (parse_flbytes sz) ) = lt_pow2_32 sz; make_total_constant_size_parser32 sz sz' #(B32.lbytes sz) (parse_flbytes_gen sz) () (parse32_flbytes_gen sz) inline_for_extraction let serialize32_flbytes (sz: nat { sz < 4294967296 } ) : Tot (serializer32 (serialize_flbytes sz)) = fun (input: B32.lbytes sz) -> B32.hide_reveal input; (input <: (res: bytes32 { serializer32_correct (serialize_flbytes sz) input res } )) inline_for_extraction let parse32_all_bytes : parser32 parse_all_bytes = fun (input: B32.bytes) -> let res = Some (input, B32.len input) in (res <: (res: option (bytes32 * U32.t) { parser32_correct parse_all_bytes input res } )) inline_for_extraction let serialize32_all_bytes : serializer32 serialize_all_bytes = fun (input: B32.bytes) -> (input <: (res: bytes32 { serializer32_correct serialize_all_bytes input res } ))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.SLow.VLGen.fst.checked", "LowParse.SLow.VLData.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Bytes.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.SLow.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 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": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
min: Prims.nat -> min32: FStar.UInt32.t{FStar.UInt32.v min32 == min} -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} -> max32: FStar.UInt32.t{FStar.UInt32.v max32 == max} -> l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4} -> LowParse.SLow.Base.parser32 (LowParse.Spec.Bytes.parse_bounded_vlbytes' min max l)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "FStar.UInt32.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.UInt32.v", "Prims.l_and", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "LowParse.Spec.BoundedInt.log256'", "LowParse.SLow.Combinators.parse32_synth", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.VLData.parse_bounded_vldata_strong_t", "FStar.Bytes.bytes", "LowParse.Spec.Bytes.parse_all_bytes", "LowParse.Spec.Bytes.serialize_all_bytes", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.VLData.parse_bounded_vldata_strong'", "LowParse.Spec.Bytes.synth_bounded_vlbytes", "LowParse.SLow.VLData.parse32_bounded_vldata_strong'", "LowParse.SLow.Bytes.parse32_all_bytes", "LowParse.SLow.Base.parser32", "LowParse.Spec.Bytes.parse_bounded_vlbytes'" ]
[]
false
false
false
false
false
let parse32_bounded_vlbytes' (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (max32: U32.t{U32.v max32 == max}) (l: nat{l >= log256' max /\ l <= 4}) : Tot (parser32 (parse_bounded_vlbytes' min max l)) =
parse32_synth _ (synth_bounded_vlbytes min max) (fun (x: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) -> (x <: parse_bounded_vlbytes_t min max)) (parse32_bounded_vldata_strong' min min32 max max32 l serialize_all_bytes parse32_all_bytes) ()
false
LowParse.SLow.Bytes.fst
LowParse.SLow.Bytes.parse32_flbytes
val parse32_flbytes (sz: nat) (sz': U32.t{U32.v sz' == sz}) : Tot (lt_pow2_32 sz; parser32 (parse_flbytes sz))
val parse32_flbytes (sz: nat) (sz': U32.t{U32.v sz' == sz}) : Tot (lt_pow2_32 sz; parser32 (parse_flbytes sz))
let parse32_flbytes (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) : Tot ( lt_pow2_32 sz; parser32 (parse_flbytes sz) ) = lt_pow2_32 sz; make_total_constant_size_parser32 sz sz' #(B32.lbytes sz) (parse_flbytes_gen sz) () (parse32_flbytes_gen sz)
{ "file_name": "src/lowparse/LowParse.SLow.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 28, "end_line": 35, "start_col": 0, "start_line": 21 }
module LowParse.SLow.Bytes include LowParse.Spec.Bytes include LowParse.SLow.VLData include LowParse.SLow.VLGen module B32 = FStar.Bytes module Seq = FStar.Seq module U32 = FStar.UInt32 inline_for_extraction let parse32_flbytes_gen (sz: nat { sz < 4294967296 } ) (x: B32.lbytes sz) : Tot (y: B32.lbytes sz { y == parse_flbytes_gen sz (B32.reveal x) } ) = B32.hide_reveal x; x #set-options "--z3rlimit 32"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.SLow.VLGen.fst.checked", "LowParse.SLow.VLData.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Bytes.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.SLow.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 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": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
sz: Prims.nat -> sz': FStar.UInt32.t{FStar.UInt32.v sz' == sz} -> (LowParse.Spec.Bytes.lt_pow2_32 sz; LowParse.SLow.Base.parser32 (LowParse.Spec.Bytes.parse_flbytes sz))
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "FStar.UInt32.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.UInt32.v", "LowParse.SLow.Combinators.make_total_constant_size_parser32", "FStar.Bytes.lbytes", "LowParse.Spec.Bytes.parse_flbytes_gen", "LowParse.SLow.Bytes.parse32_flbytes_gen", "Prims.unit", "LowParse.Spec.Bytes.lt_pow2_32", "LowParse.SLow.Base.parser32", "LowParse.Spec.Base.total_constant_size_parser_kind", "LowParse.Spec.Bytes.parse_flbytes" ]
[]
false
false
false
false
false
let parse32_flbytes (sz: nat) (sz': U32.t{U32.v sz' == sz}) : Tot (lt_pow2_32 sz; parser32 (parse_flbytes sz)) =
lt_pow2_32 sz; make_total_constant_size_parser32 sz sz' #(B32.lbytes sz) (parse_flbytes_gen sz) () (parse32_flbytes_gen sz)
false
LowParse.SLow.Bytes.fst
LowParse.SLow.Bytes.parse32_all_bytes
val parse32_all_bytes:parser32 parse_all_bytes
val parse32_all_bytes:parser32 parse_all_bytes
let parse32_all_bytes : parser32 parse_all_bytes = fun (input: B32.bytes) -> let res = Some (input, B32.len input) in (res <: (res: option (bytes32 * U32.t) { parser32_correct parse_all_bytes input res } ))
{ "file_name": "src/lowparse/LowParse.SLow.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 92, "end_line": 50, "start_col": 0, "start_line": 46 }
module LowParse.SLow.Bytes include LowParse.Spec.Bytes include LowParse.SLow.VLData include LowParse.SLow.VLGen module B32 = FStar.Bytes module Seq = FStar.Seq module U32 = FStar.UInt32 inline_for_extraction let parse32_flbytes_gen (sz: nat { sz < 4294967296 } ) (x: B32.lbytes sz) : Tot (y: B32.lbytes sz { y == parse_flbytes_gen sz (B32.reveal x) } ) = B32.hide_reveal x; x #set-options "--z3rlimit 32" inline_for_extraction let parse32_flbytes (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) : Tot ( lt_pow2_32 sz; parser32 (parse_flbytes sz) ) = lt_pow2_32 sz; make_total_constant_size_parser32 sz sz' #(B32.lbytes sz) (parse_flbytes_gen sz) () (parse32_flbytes_gen sz) inline_for_extraction let serialize32_flbytes (sz: nat { sz < 4294967296 } ) : Tot (serializer32 (serialize_flbytes sz)) = fun (input: B32.lbytes sz) -> B32.hide_reveal input; (input <: (res: bytes32 { serializer32_correct (serialize_flbytes sz) input res } ))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.SLow.VLGen.fst.checked", "LowParse.SLow.VLData.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Bytes.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.SLow.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 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": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
LowParse.SLow.Base.parser32 LowParse.Spec.Bytes.parse_all_bytes
Prims.Tot
[ "total" ]
[]
[ "FStar.Bytes.bytes", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "LowParse.SLow.Base.bytes32", "FStar.UInt32.t", "LowParse.SLow.Base.parser32_correct", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.Bytes.parse_all_bytes", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.Mktuple2", "FStar.Bytes.len" ]
[]
false
false
false
true
false
let parse32_all_bytes:parser32 parse_all_bytes =
fun (input: B32.bytes) -> let res = Some (input, B32.len input) in (res <: (res: option (bytes32 * U32.t) {parser32_correct parse_all_bytes input res}))
false
LowParse.SLow.Bytes.fst
LowParse.SLow.Bytes.size32_bounded_vlgenbytes
val size32_bounded_vlgenbytes (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (#kk: parser_kind) (#pk: parser kk (bounded_int32 min max)) (#sk: serializer pk) (sk32: size32 sk { kk.parser_kind_subkind == Some ParserStrong /\ Some? kk.parser_kind_high /\ Some?.v kk.parser_kind_high + max < 4294967296 }) : Tot (size32 (serialize_bounded_vlgenbytes min max sk))
val size32_bounded_vlgenbytes (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (#kk: parser_kind) (#pk: parser kk (bounded_int32 min max)) (#sk: serializer pk) (sk32: size32 sk { kk.parser_kind_subkind == Some ParserStrong /\ Some? kk.parser_kind_high /\ Some?.v kk.parser_kind_high + max < 4294967296 }) : Tot (size32 (serialize_bounded_vlgenbytes min max sk))
let size32_bounded_vlgenbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (#kk: parser_kind) (#pk: parser kk (bounded_int32 min max)) (#sk: serializer pk) (sk32: size32 sk {kk.parser_kind_subkind == Some ParserStrong /\ Some? kk.parser_kind_high /\ Some?.v kk.parser_kind_high + max < 4294967296 }) : Tot (size32 (serialize_bounded_vlgenbytes min max sk)) = size32_synth (parse_bounded_vlgen min max pk serialize_all_bytes) (fun x -> (x <: parse_bounded_vlbytes_t min max)) (serialize_bounded_vlgen min max sk serialize_all_bytes) (size32_bounded_vlgen min max sk32 size32_all_bytes) (fun x -> x) (fun x -> x) ()
{ "file_name": "src/lowparse/LowParse.SLow.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 6, "end_line": 224, "start_col": 0, "start_line": 209 }
module LowParse.SLow.Bytes include LowParse.Spec.Bytes include LowParse.SLow.VLData include LowParse.SLow.VLGen module B32 = FStar.Bytes module Seq = FStar.Seq module U32 = FStar.UInt32 inline_for_extraction let parse32_flbytes_gen (sz: nat { sz < 4294967296 } ) (x: B32.lbytes sz) : Tot (y: B32.lbytes sz { y == parse_flbytes_gen sz (B32.reveal x) } ) = B32.hide_reveal x; x #set-options "--z3rlimit 32" inline_for_extraction let parse32_flbytes (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) : Tot ( lt_pow2_32 sz; parser32 (parse_flbytes sz) ) = lt_pow2_32 sz; make_total_constant_size_parser32 sz sz' #(B32.lbytes sz) (parse_flbytes_gen sz) () (parse32_flbytes_gen sz) inline_for_extraction let serialize32_flbytes (sz: nat { sz < 4294967296 } ) : Tot (serializer32 (serialize_flbytes sz)) = fun (input: B32.lbytes sz) -> B32.hide_reveal input; (input <: (res: bytes32 { serializer32_correct (serialize_flbytes sz) input res } )) inline_for_extraction let parse32_all_bytes : parser32 parse_all_bytes = fun (input: B32.bytes) -> let res = Some (input, B32.len input) in (res <: (res: option (bytes32 * U32.t) { parser32_correct parse_all_bytes input res } )) inline_for_extraction let serialize32_all_bytes : serializer32 serialize_all_bytes = fun (input: B32.bytes) -> (input <: (res: bytes32 { serializer32_correct serialize_all_bytes input res } )) inline_for_extraction let parse32_bounded_vlbytes' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (parser32 (parse_bounded_vlbytes' min max l)) = parse32_synth _ (synth_bounded_vlbytes min max) (fun (x: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) -> (x <: parse_bounded_vlbytes_t min max)) (parse32_bounded_vldata_strong' min min32 max max32 l serialize_all_bytes parse32_all_bytes) () inline_for_extraction let parse32_bounded_vlbytes (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (max32: U32.t { U32.v max32 == max } ) : Tot (parser32 (parse_bounded_vlbytes min max)) = parse32_bounded_vlbytes' min min32 max max32 (log256' max) inline_for_extraction let serialize32_bounded_vlbytes_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (serializer32 (serialize_bounded_vlbytes_aux min max l)) = serialize32_bounded_vldata_strong' min max l #_ #_ #parse_all_bytes #serialize_all_bytes serialize32_all_bytes inline_for_extraction let serialize32_bounded_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (serializer32 (serialize_bounded_vlbytes' min max l)) = serialize32_synth (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) (serialize_bounded_vlbytes_aux min max l) (serialize32_bounded_vlbytes_aux min max l) (fun (x: parse_bounded_vlbytes_t min max) -> (x <: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) ) (fun x -> x) () inline_for_extraction let serialize32_bounded_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 : Tot (serializer32 (serialize_bounded_vlbytes min max)) = serialize32_bounded_vlbytes' min max (log256' max) inline_for_extraction let size32_all_bytes : size32 serialize_all_bytes = fun (input: B32.bytes) -> let res = B32.len input in (res <: (res: U32.t { size32_postcond serialize_all_bytes input res } )) inline_for_extraction let size32_bounded_vlbytes_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (size32 (serialize_bounded_vlbytes_aux min max l)) = size32_bounded_vldata_strong' min max l #_ #_ #parse_all_bytes #serialize_all_bytes size32_all_bytes (U32.uint_to_t l) inline_for_extraction let size32_bounded_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (size32 (serialize_bounded_vlbytes' min max l)) = size32_synth (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) (serialize_bounded_vlbytes_aux min max l) (size32_bounded_vlbytes_aux min max l) (fun (x: parse_bounded_vlbytes_t min max) -> (x <: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) ) (fun x -> x) () inline_for_extraction let size32_bounded_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 : Tot (size32 (serialize_bounded_vlbytes min max)) = size32_bounded_vlbytes' min max (log256' max) inline_for_extraction let parse32_bounded_vlgenbytes (min: nat) (min32: U32.t { U32.v min32 == min }) (max: nat{ min <= max /\ max > 0 }) (max32: U32.t { U32.v max32 == max }) (#kk: parser_kind) (#pk: parser kk (bounded_int32 min max)) (pk32: parser32 pk) : Tot (parser32 (parse_bounded_vlgenbytes min max pk)) = parse32_synth (parse_bounded_vlgen min max pk serialize_all_bytes) (fun x -> (x <: parse_bounded_vlbytes_t min max)) (fun x -> (x <: parse_bounded_vlbytes_t min max)) (parse32_bounded_vlgen min min32 max max32 pk32 serialize_all_bytes parse32_all_bytes) () inline_for_extraction let serialize32_bounded_vlgenbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (#kk: parser_kind) (#pk: parser kk (bounded_int32 min max)) (#sk: serializer pk) (sk32: serializer32 sk {kk.parser_kind_subkind == Some ParserStrong /\ Some? kk.parser_kind_high /\ Some?.v kk.parser_kind_high + max < 4294967296 }) : Tot (serializer32 (serialize_bounded_vlgenbytes min max sk)) = serialize32_synth (parse_bounded_vlgen min max pk serialize_all_bytes) (fun x -> (x <: parse_bounded_vlbytes_t min max)) (serialize_bounded_vlgen min max sk serialize_all_bytes) (serialize32_bounded_vlgen min max sk32 serialize32_all_bytes) (fun x -> x) (fun x -> x) ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.SLow.VLGen.fst.checked", "LowParse.SLow.VLData.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Bytes.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.SLow.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 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": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} -> sk32: LowParse.SLow.Base.size32 sk { Mkparser_kind'?.parser_kind_subkind kk == FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong /\ Some? (Mkparser_kind'?.parser_kind_high kk) /\ Some?.v (Mkparser_kind'?.parser_kind_high kk) + max < 4294967296 } -> LowParse.SLow.Base.size32 (LowParse.Spec.Bytes.serialize_bounded_vlgenbytes min max sk)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.size32", "Prims.eq2", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.ParserStrong", "FStar.Pervasives.Native.uu___is_Some", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high", "Prims.op_Addition", "FStar.Pervasives.Native.__proj__Some__item__v", "LowParse.SLow.Combinators.size32_synth", "LowParse.Spec.VLGen.parse_bounded_vlgen_kind", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.VLData.parse_bounded_vldata_strong_t", "FStar.Bytes.bytes", "LowParse.Spec.Bytes.parse_all_bytes", "LowParse.Spec.Bytes.serialize_all_bytes", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.VLGen.parse_bounded_vlgen", "LowParse.Spec.VLGen.serialize_bounded_vlgen", "LowParse.SLow.VLGen.size32_bounded_vlgen", "LowParse.SLow.Bytes.size32_all_bytes", "LowParse.Spec.Bytes.parse_bounded_vlgenbytes", "LowParse.Spec.Bytes.serialize_bounded_vlgenbytes" ]
[]
false
false
false
false
false
let size32_bounded_vlgenbytes (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (#kk: parser_kind) (#pk: parser kk (bounded_int32 min max)) (#sk: serializer pk) (sk32: size32 sk { kk.parser_kind_subkind == Some ParserStrong /\ Some? kk.parser_kind_high /\ Some?.v kk.parser_kind_high + max < 4294967296 }) : Tot (size32 (serialize_bounded_vlgenbytes min max sk)) =
size32_synth (parse_bounded_vlgen min max pk serialize_all_bytes) (fun x -> (x <: parse_bounded_vlbytes_t min max)) (serialize_bounded_vlgen min max sk serialize_all_bytes) (size32_bounded_vlgen min max sk32 size32_all_bytes) (fun x -> x) (fun x -> x) ()
false
Vale.AES.PPC64LE.GF128_Init.fsti
Vale.AES.PPC64LE.GF128_Init.va_wp_Keyhash_init
val va_wp_Keyhash_init (alg: algorithm) (key: (seq nat32)) (roundkeys_b hkeys_b: buffer128) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
val va_wp_Keyhash_init (alg: algorithm) (key: (seq nat32)) (roundkeys_b hkeys_b: buffer128) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
let va_wp_Keyhash_init (alg:algorithm) (key:(seq nat32)) (roundkeys_b:buffer128) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ Vale.PPC64LE.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (alg = AES_128 \/ alg = AES_256) /\ Vale.PPC64LE.Decls.buffers_disjoint128 roundkeys_b hkeys_b /\ Vale.AES.AES_BE_s.is_aes_key_word alg key /\ Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.buffer128_as_seq (va_get_mem va_s0) roundkeys_b) == Vale.AES.AES_BE_s.key_to_round_keys_word alg key /\ Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem va_s0) (va_get_reg 4 va_s0) roundkeys_b (Vale.AES.AES_common_s.nr alg + 1) (va_get_mem_layout va_s0) Secret /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem va_s0) (va_get_reg 3 va_s0) hkeys_b 3 (va_get_mem_layout va_s0) Secret /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_memLayout:vale_heap_layout) (va_x_r10:nat64) (va_x_v0:quad32) (va_x_v1:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) (va_x_v5:quad32) (va_x_v6:quad32) . let va_sM = va_upd_vec 6 va_x_v6 (va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1 (va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 (va_upd_mem_layout va_x_memLayout (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0)))))))))) in va_get_ok va_sM /\ Vale.PPC64LE.Decls.modifies_buffer128 hkeys_b (va_get_mem va_s0) (va_get_mem va_sM) /\ Vale.AES.OptPublic_BE.hkeys_reqs_pub (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem va_sM) hkeys_b)) (Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)) ==> va_k va_sM (())))
{ "file_name": "obj/Vale.AES.PPC64LE.GF128_Init.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 33, "end_line": 101, "start_col": 0, "start_line": 81 }
module Vale.AES.PPC64LE.GF128_Init open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open FStar.Seq open Vale.Arch.Types open Vale.Arch.HeapImpl open Vale.Math.Poly2_s open Vale.Math.Poly2 open Vale.Math.Poly2.Bits_s open Vale.Math.Poly2.Bits open Vale.Math.Poly2.Lemmas open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.AES.GHash_BE open Vale.AES.AES_BE_s open Vale.AES.AES256_helpers_BE open Vale.AES.PPC64LE.AES open Vale.PPC64LE.Machine_s open Vale.PPC64LE.Memory open Vale.PPC64LE.State open Vale.PPC64LE.Decls open Vale.PPC64LE.InsBasic open Vale.PPC64LE.InsMem open Vale.PPC64LE.InsVector open Vale.PPC64LE.QuickCode open Vale.PPC64LE.QuickCodes open Vale.AES.PPC64LE.PolyOps open Vale.AES.PPC64LE.GF128_Mul open Vale.AES.OptPublic_BE //-- Keyhash_init val va_code_Keyhash_init : alg:algorithm -> Tot va_code val va_codegen_success_Keyhash_init : alg:algorithm -> Tot va_pbool let va_req_Keyhash_init (va_b0:va_code) (va_s0:va_state) (alg:algorithm) (key:(seq nat32)) (roundkeys_b:buffer128) (hkeys_b:buffer128) : prop = (va_require_total va_b0 (va_code_Keyhash_init alg) va_s0 /\ va_get_ok va_s0 /\ Vale.PPC64LE.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (alg = AES_128 \/ alg = AES_256) /\ Vale.PPC64LE.Decls.buffers_disjoint128 roundkeys_b hkeys_b /\ Vale.AES.AES_BE_s.is_aes_key_word alg key /\ Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.buffer128_as_seq (va_get_mem va_s0) roundkeys_b) == Vale.AES.AES_BE_s.key_to_round_keys_word alg key /\ Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem va_s0) (va_get_reg 4 va_s0) roundkeys_b (Vale.AES.AES_common_s.nr alg + 1) (va_get_mem_layout va_s0) Secret /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem va_s0) (va_get_reg 3 va_s0) hkeys_b 3 (va_get_mem_layout va_s0) Secret) let va_ens_Keyhash_init (va_b0:va_code) (va_s0:va_state) (alg:algorithm) (key:(seq nat32)) (roundkeys_b:buffer128) (hkeys_b:buffer128) (va_sM:va_state) (va_fM:va_fuel) : prop = (va_req_Keyhash_init va_b0 va_s0 alg key roundkeys_b hkeys_b /\ va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.PPC64LE.Decls.modifies_buffer128 hkeys_b (va_get_mem va_s0) (va_get_mem va_sM) /\ Vale.AES.OptPublic_BE.hkeys_reqs_pub (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem va_sM) hkeys_b)) (Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)) /\ va_state_eq va_sM (va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_mem_layout va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))) val va_lemma_Keyhash_init : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> key:(seq nat32) -> roundkeys_b:buffer128 -> hkeys_b:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Keyhash_init alg) va_s0 /\ va_get_ok va_s0 /\ Vale.PPC64LE.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (alg = AES_128 \/ alg = AES_256) /\ Vale.PPC64LE.Decls.buffers_disjoint128 roundkeys_b hkeys_b /\ Vale.AES.AES_BE_s.is_aes_key_word alg key /\ Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.buffer128_as_seq (va_get_mem va_s0) roundkeys_b) == Vale.AES.AES_BE_s.key_to_round_keys_word alg key /\ Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem va_s0) (va_get_reg 4 va_s0) roundkeys_b (Vale.AES.AES_common_s.nr alg + 1) (va_get_mem_layout va_s0) Secret /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem va_s0) (va_get_reg 3 va_s0) hkeys_b 3 (va_get_mem_layout va_s0) Secret)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ Vale.PPC64LE.Decls.modifies_buffer128 hkeys_b (va_get_mem va_s0) (va_get_mem va_sM) /\ Vale.AES.OptPublic_BE.hkeys_reqs_pub (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem va_sM) hkeys_b)) (Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)) /\ va_state_eq va_sM (va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_mem_layout va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))))
{ "checked_file": "/", "dependencies": [ "Vale.PPC64LE.State.fsti.checked", "Vale.PPC64LE.QuickCodes.fsti.checked", "Vale.PPC64LE.QuickCode.fst.checked", "Vale.PPC64LE.Memory.fsti.checked", "Vale.PPC64LE.Machine_s.fst.checked", "Vale.PPC64LE.InsVector.fsti.checked", "Vale.PPC64LE.InsMem.fsti.checked", "Vale.PPC64LE.InsBasic.fsti.checked", "Vale.PPC64LE.Decls.fsti.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Lemmas.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Math.Poly2.Bits.fsti.checked", "Vale.Math.Poly2.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.AES.PPC64LE.PolyOps.fsti.checked", "Vale.AES.PPC64LE.GF128_Mul.fsti.checked", "Vale.AES.PPC64LE.AES.fsti.checked", "Vale.AES.OptPublic_BE.fsti.checked", "Vale.AES.GHash_BE.fsti.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "Vale.AES.AES_BE_s.fst.checked", "Vale.AES.AES256_helpers_BE.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.AES.PPC64LE.GF128_Init.fsti" }
[ { "abbrev": false, "full_module": "Vale.AES.OptPublic_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE.PolyOps", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.PPC64LE.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES256_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_BE", "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.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_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": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.PPC64LE", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.PPC64LE.Memory.nat32 -> roundkeys_b: Vale.PPC64LE.Memory.buffer128 -> hkeys_b: Vale.PPC64LE.Memory.buffer128 -> va_s0: Vale.PPC64LE.Decls.va_state -> va_k: (_: Vale.PPC64LE.Decls.va_state -> _: Prims.unit -> Type0) -> Type0
Prims.Tot
[ "total" ]
[]
[ "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.PPC64LE.Memory.nat32", "Vale.PPC64LE.Memory.buffer128", "Vale.PPC64LE.Decls.va_state", "Prims.unit", "Prims.l_and", "Prims.b2t", "Vale.PPC64LE.Decls.va_get_ok", "Vale.PPC64LE.Memory.is_initial_heap", "Vale.PPC64LE.Decls.va_get_mem_layout", "Vale.PPC64LE.Decls.va_get_mem", "Prims.l_or", "Prims.op_Equality", "Vale.AES.AES_common_s.AES_128", "Vale.AES.AES_common_s.AES_256", "Vale.PPC64LE.Decls.buffers_disjoint128", "Vale.AES.AES_BE_s.is_aes_key_word", "Prims.eq2", "Vale.Def.Types_s.quad32", "Vale.Arch.Types.reverse_bytes_quad32_seq", "Vale.PPC64LE.Decls.buffer128_as_seq", "Vale.AES.AES_BE_s.key_to_round_keys_word", "Vale.PPC64LE.Decls.validSrcAddrs128", "Vale.PPC64LE.Decls.va_get_reg", "Prims.op_Addition", "Vale.AES.AES_common_s.nr", "Vale.Arch.HeapTypes_s.Secret", "Vale.PPC64LE.Decls.validDstAddrs128", "Prims.l_Forall", "Vale.PPC64LE.InsBasic.vale_heap", "Vale.Arch.HeapImpl.vale_heap_layout", "Vale.PPC64LE.Memory.nat64", "Vale.PPC64LE.Memory.quad32", "Prims.l_imp", "Vale.PPC64LE.Decls.modifies_buffer128", "Vale.AES.OptPublic_BE.hkeys_reqs_pub", "Vale.PPC64LE.Decls.s128", "Vale.AES.AES_BE_s.aes_encrypt_word", "Vale.Def.Words_s.Mkfour", "Vale.Def.Types_s.nat32", "Vale.PPC64LE.Machine_s.state", "Vale.PPC64LE.Decls.va_upd_vec", "Vale.PPC64LE.Decls.va_upd_reg", "Vale.PPC64LE.Decls.va_upd_mem_layout", "Vale.PPC64LE.Decls.va_upd_mem_heaplet", "Vale.PPC64LE.Decls.va_upd_mem" ]
[]
false
false
false
true
true
let va_wp_Keyhash_init (alg: algorithm) (key: (seq nat32)) (roundkeys_b hkeys_b: buffer128) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ Vale.PPC64LE.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (alg = AES_128 \/ alg = AES_256) /\ Vale.PPC64LE.Decls.buffers_disjoint128 roundkeys_b hkeys_b /\ Vale.AES.AES_BE_s.is_aes_key_word alg key /\ Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.buffer128_as_seq (va_get_mem va_s0) roundkeys_b) == Vale.AES.AES_BE_s.key_to_round_keys_word alg key /\ Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem va_s0) (va_get_reg 4 va_s0) roundkeys_b (Vale.AES.AES_common_s.nr alg + 1) (va_get_mem_layout va_s0) Secret /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem va_s0) (va_get_reg 3 va_s0) hkeys_b 3 (va_get_mem_layout va_s0) Secret /\ (forall (va_x_mem: vale_heap) (va_x_heap1: vale_heap) (va_x_memLayout: vale_heap_layout) (va_x_r10: nat64) (va_x_v0: quad32) (va_x_v1: quad32) (va_x_v2: quad32) (va_x_v3: quad32) (va_x_v4: quad32) (va_x_v5: quad32) (va_x_v6: quad32). let va_sM = va_upd_vec 6 va_x_v6 (va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1 (va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 (va_upd_mem_layout va_x_memLayout (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0)))))))))) in va_get_ok va_sM /\ Vale.PPC64LE.Decls.modifies_buffer128 hkeys_b (va_get_mem va_s0) (va_get_mem va_sM) /\ Vale.AES.OptPublic_BE.hkeys_reqs_pub (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem va_sM) hkeys_b)) (Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)) ==> va_k va_sM (())))
false
LowParse.SLow.Bytes.fst
LowParse.SLow.Bytes.serialize32_bounded_vlbytes_aux
val serialize32_bounded_vlbytes_aux (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (l: nat{l >= log256' max /\ l <= 4}) : Tot (serializer32 (serialize_bounded_vlbytes_aux min max l))
val serialize32_bounded_vlbytes_aux (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (l: nat{l >= log256' max /\ l <= 4}) : Tot (serializer32 (serialize_bounded_vlbytes_aux min max l))
let serialize32_bounded_vlbytes_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (serializer32 (serialize_bounded_vlbytes_aux min max l)) = serialize32_bounded_vldata_strong' min max l #_ #_ #parse_all_bytes #serialize_all_bytes serialize32_all_bytes
{ "file_name": "src/lowparse/LowParse.SLow.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 25, "end_line": 97, "start_col": 0, "start_line": 83 }
module LowParse.SLow.Bytes include LowParse.Spec.Bytes include LowParse.SLow.VLData include LowParse.SLow.VLGen module B32 = FStar.Bytes module Seq = FStar.Seq module U32 = FStar.UInt32 inline_for_extraction let parse32_flbytes_gen (sz: nat { sz < 4294967296 } ) (x: B32.lbytes sz) : Tot (y: B32.lbytes sz { y == parse_flbytes_gen sz (B32.reveal x) } ) = B32.hide_reveal x; x #set-options "--z3rlimit 32" inline_for_extraction let parse32_flbytes (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) : Tot ( lt_pow2_32 sz; parser32 (parse_flbytes sz) ) = lt_pow2_32 sz; make_total_constant_size_parser32 sz sz' #(B32.lbytes sz) (parse_flbytes_gen sz) () (parse32_flbytes_gen sz) inline_for_extraction let serialize32_flbytes (sz: nat { sz < 4294967296 } ) : Tot (serializer32 (serialize_flbytes sz)) = fun (input: B32.lbytes sz) -> B32.hide_reveal input; (input <: (res: bytes32 { serializer32_correct (serialize_flbytes sz) input res } )) inline_for_extraction let parse32_all_bytes : parser32 parse_all_bytes = fun (input: B32.bytes) -> let res = Some (input, B32.len input) in (res <: (res: option (bytes32 * U32.t) { parser32_correct parse_all_bytes input res } )) inline_for_extraction let serialize32_all_bytes : serializer32 serialize_all_bytes = fun (input: B32.bytes) -> (input <: (res: bytes32 { serializer32_correct serialize_all_bytes input res } )) inline_for_extraction let parse32_bounded_vlbytes' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (parser32 (parse_bounded_vlbytes' min max l)) = parse32_synth _ (synth_bounded_vlbytes min max) (fun (x: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) -> (x <: parse_bounded_vlbytes_t min max)) (parse32_bounded_vldata_strong' min min32 max max32 l serialize_all_bytes parse32_all_bytes) () inline_for_extraction let parse32_bounded_vlbytes (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (max32: U32.t { U32.v max32 == max } ) : Tot (parser32 (parse_bounded_vlbytes min max)) = parse32_bounded_vlbytes' min min32 max max32 (log256' max)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.SLow.VLGen.fst.checked", "LowParse.SLow.VLData.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Bytes.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.SLow.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 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": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967292} -> l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4} -> LowParse.SLow.Base.serializer32 (LowParse.Spec.Bytes.serialize_bounded_vlbytes_aux min max l)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "Prims.op_GreaterThanOrEqual", "LowParse.Spec.BoundedInt.log256'", "LowParse.SLow.VLData.serialize32_bounded_vldata_strong'", "LowParse.Spec.Bytes.parse_all_bytes_kind", "FStar.Bytes.bytes", "LowParse.Spec.Bytes.parse_all_bytes", "LowParse.Spec.Bytes.serialize_all_bytes", "LowParse.SLow.Bytes.serialize32_all_bytes", "LowParse.SLow.Base.serializer32", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.VLData.parse_bounded_vldata_strong_t", "LowParse.Spec.Bytes.parse_bounded_vlbytes_aux", "LowParse.Spec.Bytes.serialize_bounded_vlbytes_aux" ]
[]
false
false
false
false
false
let serialize32_bounded_vlbytes_aux (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (l: nat{l >= log256' max /\ l <= 4}) : Tot (serializer32 (serialize_bounded_vlbytes_aux min max l)) =
serialize32_bounded_vldata_strong' min max l #_ #_ #parse_all_bytes #serialize_all_bytes serialize32_all_bytes
false
LowParse.SLow.Bytes.fst
LowParse.SLow.Bytes.size32_bounded_vlbytes
val size32_bounded_vlbytes (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) : Tot (size32 (serialize_bounded_vlbytes min max))
val size32_bounded_vlbytes (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) : Tot (size32 (serialize_bounded_vlbytes min max))
let size32_bounded_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 : Tot (size32 (serialize_bounded_vlbytes min max)) = size32_bounded_vlbytes' min max (log256' max)
{ "file_name": "src/lowparse/LowParse.SLow.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 47, "end_line": 171, "start_col": 0, "start_line": 167 }
module LowParse.SLow.Bytes include LowParse.Spec.Bytes include LowParse.SLow.VLData include LowParse.SLow.VLGen module B32 = FStar.Bytes module Seq = FStar.Seq module U32 = FStar.UInt32 inline_for_extraction let parse32_flbytes_gen (sz: nat { sz < 4294967296 } ) (x: B32.lbytes sz) : Tot (y: B32.lbytes sz { y == parse_flbytes_gen sz (B32.reveal x) } ) = B32.hide_reveal x; x #set-options "--z3rlimit 32" inline_for_extraction let parse32_flbytes (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) : Tot ( lt_pow2_32 sz; parser32 (parse_flbytes sz) ) = lt_pow2_32 sz; make_total_constant_size_parser32 sz sz' #(B32.lbytes sz) (parse_flbytes_gen sz) () (parse32_flbytes_gen sz) inline_for_extraction let serialize32_flbytes (sz: nat { sz < 4294967296 } ) : Tot (serializer32 (serialize_flbytes sz)) = fun (input: B32.lbytes sz) -> B32.hide_reveal input; (input <: (res: bytes32 { serializer32_correct (serialize_flbytes sz) input res } )) inline_for_extraction let parse32_all_bytes : parser32 parse_all_bytes = fun (input: B32.bytes) -> let res = Some (input, B32.len input) in (res <: (res: option (bytes32 * U32.t) { parser32_correct parse_all_bytes input res } )) inline_for_extraction let serialize32_all_bytes : serializer32 serialize_all_bytes = fun (input: B32.bytes) -> (input <: (res: bytes32 { serializer32_correct serialize_all_bytes input res } )) inline_for_extraction let parse32_bounded_vlbytes' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (parser32 (parse_bounded_vlbytes' min max l)) = parse32_synth _ (synth_bounded_vlbytes min max) (fun (x: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) -> (x <: parse_bounded_vlbytes_t min max)) (parse32_bounded_vldata_strong' min min32 max max32 l serialize_all_bytes parse32_all_bytes) () inline_for_extraction let parse32_bounded_vlbytes (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (max32: U32.t { U32.v max32 == max } ) : Tot (parser32 (parse_bounded_vlbytes min max)) = parse32_bounded_vlbytes' min min32 max max32 (log256' max) inline_for_extraction let serialize32_bounded_vlbytes_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (serializer32 (serialize_bounded_vlbytes_aux min max l)) = serialize32_bounded_vldata_strong' min max l #_ #_ #parse_all_bytes #serialize_all_bytes serialize32_all_bytes inline_for_extraction let serialize32_bounded_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (serializer32 (serialize_bounded_vlbytes' min max l)) = serialize32_synth (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) (serialize_bounded_vlbytes_aux min max l) (serialize32_bounded_vlbytes_aux min max l) (fun (x: parse_bounded_vlbytes_t min max) -> (x <: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) ) (fun x -> x) () inline_for_extraction let serialize32_bounded_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 : Tot (serializer32 (serialize_bounded_vlbytes min max)) = serialize32_bounded_vlbytes' min max (log256' max) inline_for_extraction let size32_all_bytes : size32 serialize_all_bytes = fun (input: B32.bytes) -> let res = B32.len input in (res <: (res: U32.t { size32_postcond serialize_all_bytes input res } )) inline_for_extraction let size32_bounded_vlbytes_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (size32 (serialize_bounded_vlbytes_aux min max l)) = size32_bounded_vldata_strong' min max l #_ #_ #parse_all_bytes #serialize_all_bytes size32_all_bytes (U32.uint_to_t l) inline_for_extraction let size32_bounded_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (size32 (serialize_bounded_vlbytes' min max l)) = size32_synth (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) (serialize_bounded_vlbytes_aux min max l) (size32_bounded_vlbytes_aux min max l) (fun (x: parse_bounded_vlbytes_t min max) -> (x <: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) ) (fun x -> x) ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.SLow.VLGen.fst.checked", "LowParse.SLow.VLData.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Bytes.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.SLow.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 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": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967292} -> LowParse.SLow.Base.size32 (LowParse.Spec.Bytes.serialize_bounded_vlbytes min max)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "LowParse.SLow.Bytes.size32_bounded_vlbytes'", "LowParse.Spec.BoundedInt.log256'", "LowParse.SLow.Base.size32", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.Bytes.parse_bounded_vlbytes", "LowParse.Spec.Bytes.serialize_bounded_vlbytes" ]
[]
false
false
false
false
false
let size32_bounded_vlbytes (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) : Tot (size32 (serialize_bounded_vlbytes min max)) =
size32_bounded_vlbytes' min max (log256' max)
false
LowParse.SLow.Bytes.fst
LowParse.SLow.Bytes.serialize32_bounded_vlgenbytes
val serialize32_bounded_vlgenbytes (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (#kk: parser_kind) (#pk: parser kk (bounded_int32 min max)) (#sk: serializer pk) (sk32: serializer32 sk { kk.parser_kind_subkind == Some ParserStrong /\ Some? kk.parser_kind_high /\ Some?.v kk.parser_kind_high + max < 4294967296 }) : Tot (serializer32 (serialize_bounded_vlgenbytes min max sk))
val serialize32_bounded_vlgenbytes (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (#kk: parser_kind) (#pk: parser kk (bounded_int32 min max)) (#sk: serializer pk) (sk32: serializer32 sk { kk.parser_kind_subkind == Some ParserStrong /\ Some? kk.parser_kind_high /\ Some?.v kk.parser_kind_high + max < 4294967296 }) : Tot (serializer32 (serialize_bounded_vlgenbytes min max sk))
let serialize32_bounded_vlgenbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (#kk: parser_kind) (#pk: parser kk (bounded_int32 min max)) (#sk: serializer pk) (sk32: serializer32 sk {kk.parser_kind_subkind == Some ParserStrong /\ Some? kk.parser_kind_high /\ Some?.v kk.parser_kind_high + max < 4294967296 }) : Tot (serializer32 (serialize_bounded_vlgenbytes min max sk)) = serialize32_synth (parse_bounded_vlgen min max pk serialize_all_bytes) (fun x -> (x <: parse_bounded_vlbytes_t min max)) (serialize_bounded_vlgen min max sk serialize_all_bytes) (serialize32_bounded_vlgen min max sk32 serialize32_all_bytes) (fun x -> x) (fun x -> x) ()
{ "file_name": "src/lowparse/LowParse.SLow.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 6, "end_line": 206, "start_col": 0, "start_line": 191 }
module LowParse.SLow.Bytes include LowParse.Spec.Bytes include LowParse.SLow.VLData include LowParse.SLow.VLGen module B32 = FStar.Bytes module Seq = FStar.Seq module U32 = FStar.UInt32 inline_for_extraction let parse32_flbytes_gen (sz: nat { sz < 4294967296 } ) (x: B32.lbytes sz) : Tot (y: B32.lbytes sz { y == parse_flbytes_gen sz (B32.reveal x) } ) = B32.hide_reveal x; x #set-options "--z3rlimit 32" inline_for_extraction let parse32_flbytes (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) : Tot ( lt_pow2_32 sz; parser32 (parse_flbytes sz) ) = lt_pow2_32 sz; make_total_constant_size_parser32 sz sz' #(B32.lbytes sz) (parse_flbytes_gen sz) () (parse32_flbytes_gen sz) inline_for_extraction let serialize32_flbytes (sz: nat { sz < 4294967296 } ) : Tot (serializer32 (serialize_flbytes sz)) = fun (input: B32.lbytes sz) -> B32.hide_reveal input; (input <: (res: bytes32 { serializer32_correct (serialize_flbytes sz) input res } )) inline_for_extraction let parse32_all_bytes : parser32 parse_all_bytes = fun (input: B32.bytes) -> let res = Some (input, B32.len input) in (res <: (res: option (bytes32 * U32.t) { parser32_correct parse_all_bytes input res } )) inline_for_extraction let serialize32_all_bytes : serializer32 serialize_all_bytes = fun (input: B32.bytes) -> (input <: (res: bytes32 { serializer32_correct serialize_all_bytes input res } )) inline_for_extraction let parse32_bounded_vlbytes' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (parser32 (parse_bounded_vlbytes' min max l)) = parse32_synth _ (synth_bounded_vlbytes min max) (fun (x: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) -> (x <: parse_bounded_vlbytes_t min max)) (parse32_bounded_vldata_strong' min min32 max max32 l serialize_all_bytes parse32_all_bytes) () inline_for_extraction let parse32_bounded_vlbytes (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (max32: U32.t { U32.v max32 == max } ) : Tot (parser32 (parse_bounded_vlbytes min max)) = parse32_bounded_vlbytes' min min32 max max32 (log256' max) inline_for_extraction let serialize32_bounded_vlbytes_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (serializer32 (serialize_bounded_vlbytes_aux min max l)) = serialize32_bounded_vldata_strong' min max l #_ #_ #parse_all_bytes #serialize_all_bytes serialize32_all_bytes inline_for_extraction let serialize32_bounded_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (serializer32 (serialize_bounded_vlbytes' min max l)) = serialize32_synth (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) (serialize_bounded_vlbytes_aux min max l) (serialize32_bounded_vlbytes_aux min max l) (fun (x: parse_bounded_vlbytes_t min max) -> (x <: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) ) (fun x -> x) () inline_for_extraction let serialize32_bounded_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 : Tot (serializer32 (serialize_bounded_vlbytes min max)) = serialize32_bounded_vlbytes' min max (log256' max) inline_for_extraction let size32_all_bytes : size32 serialize_all_bytes = fun (input: B32.bytes) -> let res = B32.len input in (res <: (res: U32.t { size32_postcond serialize_all_bytes input res } )) inline_for_extraction let size32_bounded_vlbytes_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (size32 (serialize_bounded_vlbytes_aux min max l)) = size32_bounded_vldata_strong' min max l #_ #_ #parse_all_bytes #serialize_all_bytes size32_all_bytes (U32.uint_to_t l) inline_for_extraction let size32_bounded_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (size32 (serialize_bounded_vlbytes' min max l)) = size32_synth (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) (serialize_bounded_vlbytes_aux min max l) (size32_bounded_vlbytes_aux min max l) (fun (x: parse_bounded_vlbytes_t min max) -> (x <: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) ) (fun x -> x) () inline_for_extraction let size32_bounded_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 : Tot (size32 (serialize_bounded_vlbytes min max)) = size32_bounded_vlbytes' min max (log256' max) inline_for_extraction let parse32_bounded_vlgenbytes (min: nat) (min32: U32.t { U32.v min32 == min }) (max: nat{ min <= max /\ max > 0 }) (max32: U32.t { U32.v max32 == max }) (#kk: parser_kind) (#pk: parser kk (bounded_int32 min max)) (pk32: parser32 pk) : Tot (parser32 (parse_bounded_vlgenbytes min max pk)) = parse32_synth (parse_bounded_vlgen min max pk serialize_all_bytes) (fun x -> (x <: parse_bounded_vlbytes_t min max)) (fun x -> (x <: parse_bounded_vlbytes_t min max)) (parse32_bounded_vlgen min min32 max max32 pk32 serialize_all_bytes parse32_all_bytes) ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.SLow.VLGen.fst.checked", "LowParse.SLow.VLData.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Bytes.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.SLow.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 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": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} -> sk32: LowParse.SLow.Base.serializer32 sk { Mkparser_kind'?.parser_kind_subkind kk == FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong /\ Some? (Mkparser_kind'?.parser_kind_high kk) /\ Some?.v (Mkparser_kind'?.parser_kind_high kk) + max < 4294967296 } -> LowParse.SLow.Base.serializer32 (LowParse.Spec.Bytes.serialize_bounded_vlgenbytes min max sk)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.serializer32", "Prims.eq2", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.ParserStrong", "FStar.Pervasives.Native.uu___is_Some", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high", "Prims.op_Addition", "FStar.Pervasives.Native.__proj__Some__item__v", "LowParse.SLow.Combinators.serialize32_synth", "LowParse.Spec.VLGen.parse_bounded_vlgen_kind", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.VLData.parse_bounded_vldata_strong_t", "FStar.Bytes.bytes", "LowParse.Spec.Bytes.parse_all_bytes", "LowParse.Spec.Bytes.serialize_all_bytes", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.VLGen.parse_bounded_vlgen", "LowParse.Spec.VLGen.serialize_bounded_vlgen", "LowParse.SLow.VLGen.serialize32_bounded_vlgen", "LowParse.SLow.Bytes.serialize32_all_bytes", "LowParse.Spec.Bytes.parse_bounded_vlgenbytes", "LowParse.Spec.Bytes.serialize_bounded_vlgenbytes" ]
[]
false
false
false
false
false
let serialize32_bounded_vlgenbytes (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (#kk: parser_kind) (#pk: parser kk (bounded_int32 min max)) (#sk: serializer pk) (sk32: serializer32 sk { kk.parser_kind_subkind == Some ParserStrong /\ Some? kk.parser_kind_high /\ Some?.v kk.parser_kind_high + max < 4294967296 }) : Tot (serializer32 (serialize_bounded_vlgenbytes min max sk)) =
serialize32_synth (parse_bounded_vlgen min max pk serialize_all_bytes) (fun x -> (x <: parse_bounded_vlbytes_t min max)) (serialize_bounded_vlgen min max sk serialize_all_bytes) (serialize32_bounded_vlgen min max sk32 serialize32_all_bytes) (fun x -> x) (fun x -> x) ()
false
LowParse.SLow.Bytes.fst
LowParse.SLow.Bytes.serialize32_bounded_vlbytes
val serialize32_bounded_vlbytes (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) : Tot (serializer32 (serialize_bounded_vlbytes min max))
val serialize32_bounded_vlbytes (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) : Tot (serializer32 (serialize_bounded_vlbytes min max))
let serialize32_bounded_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 : Tot (serializer32 (serialize_bounded_vlbytes min max)) = serialize32_bounded_vlbytes' min max (log256' max)
{ "file_name": "src/lowparse/LowParse.SLow.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 52, "end_line": 121, "start_col": 0, "start_line": 117 }
module LowParse.SLow.Bytes include LowParse.Spec.Bytes include LowParse.SLow.VLData include LowParse.SLow.VLGen module B32 = FStar.Bytes module Seq = FStar.Seq module U32 = FStar.UInt32 inline_for_extraction let parse32_flbytes_gen (sz: nat { sz < 4294967296 } ) (x: B32.lbytes sz) : Tot (y: B32.lbytes sz { y == parse_flbytes_gen sz (B32.reveal x) } ) = B32.hide_reveal x; x #set-options "--z3rlimit 32" inline_for_extraction let parse32_flbytes (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) : Tot ( lt_pow2_32 sz; parser32 (parse_flbytes sz) ) = lt_pow2_32 sz; make_total_constant_size_parser32 sz sz' #(B32.lbytes sz) (parse_flbytes_gen sz) () (parse32_flbytes_gen sz) inline_for_extraction let serialize32_flbytes (sz: nat { sz < 4294967296 } ) : Tot (serializer32 (serialize_flbytes sz)) = fun (input: B32.lbytes sz) -> B32.hide_reveal input; (input <: (res: bytes32 { serializer32_correct (serialize_flbytes sz) input res } )) inline_for_extraction let parse32_all_bytes : parser32 parse_all_bytes = fun (input: B32.bytes) -> let res = Some (input, B32.len input) in (res <: (res: option (bytes32 * U32.t) { parser32_correct parse_all_bytes input res } )) inline_for_extraction let serialize32_all_bytes : serializer32 serialize_all_bytes = fun (input: B32.bytes) -> (input <: (res: bytes32 { serializer32_correct serialize_all_bytes input res } )) inline_for_extraction let parse32_bounded_vlbytes' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (parser32 (parse_bounded_vlbytes' min max l)) = parse32_synth _ (synth_bounded_vlbytes min max) (fun (x: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) -> (x <: parse_bounded_vlbytes_t min max)) (parse32_bounded_vldata_strong' min min32 max max32 l serialize_all_bytes parse32_all_bytes) () inline_for_extraction let parse32_bounded_vlbytes (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (max32: U32.t { U32.v max32 == max } ) : Tot (parser32 (parse_bounded_vlbytes min max)) = parse32_bounded_vlbytes' min min32 max max32 (log256' max) inline_for_extraction let serialize32_bounded_vlbytes_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (serializer32 (serialize_bounded_vlbytes_aux min max l)) = serialize32_bounded_vldata_strong' min max l #_ #_ #parse_all_bytes #serialize_all_bytes serialize32_all_bytes inline_for_extraction let serialize32_bounded_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (serializer32 (serialize_bounded_vlbytes' min max l)) = serialize32_synth (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) (serialize_bounded_vlbytes_aux min max l) (serialize32_bounded_vlbytes_aux min max l) (fun (x: parse_bounded_vlbytes_t min max) -> (x <: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) ) (fun x -> x) ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.SLow.VLGen.fst.checked", "LowParse.SLow.VLData.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Bytes.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.SLow.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 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": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967292} -> LowParse.SLow.Base.serializer32 (LowParse.Spec.Bytes.serialize_bounded_vlbytes min max)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "LowParse.SLow.Bytes.serialize32_bounded_vlbytes'", "LowParse.Spec.BoundedInt.log256'", "LowParse.SLow.Base.serializer32", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.Bytes.parse_bounded_vlbytes", "LowParse.Spec.Bytes.serialize_bounded_vlbytes" ]
[]
false
false
false
false
false
let serialize32_bounded_vlbytes (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) : Tot (serializer32 (serialize_bounded_vlbytes min max)) =
serialize32_bounded_vlbytes' min max (log256' max)
false
LowParse.SLow.Bytes.fst
LowParse.SLow.Bytes.size32_all_bytes
val size32_all_bytes:size32 serialize_all_bytes
val size32_all_bytes:size32 serialize_all_bytes
let size32_all_bytes : size32 serialize_all_bytes = fun (input: B32.bytes) -> let res = B32.len input in (res <: (res: U32.t { size32_postcond serialize_all_bytes input res } ))
{ "file_name": "src/lowparse/LowParse.SLow.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 74, "end_line": 128, "start_col": 0, "start_line": 124 }
module LowParse.SLow.Bytes include LowParse.Spec.Bytes include LowParse.SLow.VLData include LowParse.SLow.VLGen module B32 = FStar.Bytes module Seq = FStar.Seq module U32 = FStar.UInt32 inline_for_extraction let parse32_flbytes_gen (sz: nat { sz < 4294967296 } ) (x: B32.lbytes sz) : Tot (y: B32.lbytes sz { y == parse_flbytes_gen sz (B32.reveal x) } ) = B32.hide_reveal x; x #set-options "--z3rlimit 32" inline_for_extraction let parse32_flbytes (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) : Tot ( lt_pow2_32 sz; parser32 (parse_flbytes sz) ) = lt_pow2_32 sz; make_total_constant_size_parser32 sz sz' #(B32.lbytes sz) (parse_flbytes_gen sz) () (parse32_flbytes_gen sz) inline_for_extraction let serialize32_flbytes (sz: nat { sz < 4294967296 } ) : Tot (serializer32 (serialize_flbytes sz)) = fun (input: B32.lbytes sz) -> B32.hide_reveal input; (input <: (res: bytes32 { serializer32_correct (serialize_flbytes sz) input res } )) inline_for_extraction let parse32_all_bytes : parser32 parse_all_bytes = fun (input: B32.bytes) -> let res = Some (input, B32.len input) in (res <: (res: option (bytes32 * U32.t) { parser32_correct parse_all_bytes input res } )) inline_for_extraction let serialize32_all_bytes : serializer32 serialize_all_bytes = fun (input: B32.bytes) -> (input <: (res: bytes32 { serializer32_correct serialize_all_bytes input res } )) inline_for_extraction let parse32_bounded_vlbytes' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (parser32 (parse_bounded_vlbytes' min max l)) = parse32_synth _ (synth_bounded_vlbytes min max) (fun (x: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) -> (x <: parse_bounded_vlbytes_t min max)) (parse32_bounded_vldata_strong' min min32 max max32 l serialize_all_bytes parse32_all_bytes) () inline_for_extraction let parse32_bounded_vlbytes (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (max32: U32.t { U32.v max32 == max } ) : Tot (parser32 (parse_bounded_vlbytes min max)) = parse32_bounded_vlbytes' min min32 max max32 (log256' max) inline_for_extraction let serialize32_bounded_vlbytes_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (serializer32 (serialize_bounded_vlbytes_aux min max l)) = serialize32_bounded_vldata_strong' min max l #_ #_ #parse_all_bytes #serialize_all_bytes serialize32_all_bytes inline_for_extraction let serialize32_bounded_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (serializer32 (serialize_bounded_vlbytes' min max l)) = serialize32_synth (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) (serialize_bounded_vlbytes_aux min max l) (serialize32_bounded_vlbytes_aux min max l) (fun (x: parse_bounded_vlbytes_t min max) -> (x <: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) ) (fun x -> x) () inline_for_extraction let serialize32_bounded_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 : Tot (serializer32 (serialize_bounded_vlbytes min max)) = serialize32_bounded_vlbytes' min max (log256' max)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.SLow.VLGen.fst.checked", "LowParse.SLow.VLData.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Bytes.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.SLow.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 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": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
LowParse.SLow.Base.size32 LowParse.Spec.Bytes.serialize_all_bytes
Prims.Tot
[ "total" ]
[]
[ "FStar.Bytes.bytes", "FStar.UInt32.t", "LowParse.SLow.Base.size32_postcond", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.Bytes.parse_all_bytes", "LowParse.Spec.Bytes.serialize_all_bytes", "FStar.Bytes.len" ]
[]
false
false
false
true
false
let size32_all_bytes:size32 serialize_all_bytes =
fun (input: B32.bytes) -> let res = B32.len input in (res <: (res: U32.t{size32_postcond serialize_all_bytes input res}))
false
LowParse.SLow.Bytes.fst
LowParse.SLow.Bytes.size32_bounded_vlbytes'
val size32_bounded_vlbytes' (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (l: nat{l >= log256' max /\ l <= 4}) : Tot (size32 (serialize_bounded_vlbytes' min max l))
val size32_bounded_vlbytes' (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (l: nat{l >= log256' max /\ l <= 4}) : Tot (size32 (serialize_bounded_vlbytes' min max l))
let size32_bounded_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (size32 (serialize_bounded_vlbytes' min max l)) = size32_synth (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) (serialize_bounded_vlbytes_aux min max l) (size32_bounded_vlbytes_aux min max l) (fun (x: parse_bounded_vlbytes_t min max) -> (x <: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) ) (fun x -> x) ()
{ "file_name": "src/lowparse/LowParse.SLow.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 6, "end_line": 164, "start_col": 0, "start_line": 149 }
module LowParse.SLow.Bytes include LowParse.Spec.Bytes include LowParse.SLow.VLData include LowParse.SLow.VLGen module B32 = FStar.Bytes module Seq = FStar.Seq module U32 = FStar.UInt32 inline_for_extraction let parse32_flbytes_gen (sz: nat { sz < 4294967296 } ) (x: B32.lbytes sz) : Tot (y: B32.lbytes sz { y == parse_flbytes_gen sz (B32.reveal x) } ) = B32.hide_reveal x; x #set-options "--z3rlimit 32" inline_for_extraction let parse32_flbytes (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) : Tot ( lt_pow2_32 sz; parser32 (parse_flbytes sz) ) = lt_pow2_32 sz; make_total_constant_size_parser32 sz sz' #(B32.lbytes sz) (parse_flbytes_gen sz) () (parse32_flbytes_gen sz) inline_for_extraction let serialize32_flbytes (sz: nat { sz < 4294967296 } ) : Tot (serializer32 (serialize_flbytes sz)) = fun (input: B32.lbytes sz) -> B32.hide_reveal input; (input <: (res: bytes32 { serializer32_correct (serialize_flbytes sz) input res } )) inline_for_extraction let parse32_all_bytes : parser32 parse_all_bytes = fun (input: B32.bytes) -> let res = Some (input, B32.len input) in (res <: (res: option (bytes32 * U32.t) { parser32_correct parse_all_bytes input res } )) inline_for_extraction let serialize32_all_bytes : serializer32 serialize_all_bytes = fun (input: B32.bytes) -> (input <: (res: bytes32 { serializer32_correct serialize_all_bytes input res } )) inline_for_extraction let parse32_bounded_vlbytes' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (parser32 (parse_bounded_vlbytes' min max l)) = parse32_synth _ (synth_bounded_vlbytes min max) (fun (x: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) -> (x <: parse_bounded_vlbytes_t min max)) (parse32_bounded_vldata_strong' min min32 max max32 l serialize_all_bytes parse32_all_bytes) () inline_for_extraction let parse32_bounded_vlbytes (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (max32: U32.t { U32.v max32 == max } ) : Tot (parser32 (parse_bounded_vlbytes min max)) = parse32_bounded_vlbytes' min min32 max max32 (log256' max) inline_for_extraction let serialize32_bounded_vlbytes_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (serializer32 (serialize_bounded_vlbytes_aux min max l)) = serialize32_bounded_vldata_strong' min max l #_ #_ #parse_all_bytes #serialize_all_bytes serialize32_all_bytes inline_for_extraction let serialize32_bounded_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (serializer32 (serialize_bounded_vlbytes' min max l)) = serialize32_synth (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) (serialize_bounded_vlbytes_aux min max l) (serialize32_bounded_vlbytes_aux min max l) (fun (x: parse_bounded_vlbytes_t min max) -> (x <: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) ) (fun x -> x) () inline_for_extraction let serialize32_bounded_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 : Tot (serializer32 (serialize_bounded_vlbytes min max)) = serialize32_bounded_vlbytes' min max (log256' max) inline_for_extraction let size32_all_bytes : size32 serialize_all_bytes = fun (input: B32.bytes) -> let res = B32.len input in (res <: (res: U32.t { size32_postcond serialize_all_bytes input res } )) inline_for_extraction let size32_bounded_vlbytes_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (size32 (serialize_bounded_vlbytes_aux min max l)) = size32_bounded_vldata_strong' min max l #_ #_ #parse_all_bytes #serialize_all_bytes size32_all_bytes (U32.uint_to_t l)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.SLow.VLGen.fst.checked", "LowParse.SLow.VLData.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Bytes.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.SLow.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 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": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967292} -> l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4} -> LowParse.SLow.Base.size32 (LowParse.Spec.Bytes.serialize_bounded_vlbytes' min max l)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "Prims.op_GreaterThanOrEqual", "LowParse.Spec.BoundedInt.log256'", "LowParse.SLow.Combinators.size32_synth", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.VLData.parse_bounded_vldata_strong_t", "FStar.Bytes.bytes", "LowParse.Spec.Bytes.parse_all_bytes", "LowParse.Spec.Bytes.serialize_all_bytes", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.Bytes.parse_bounded_vlbytes_aux", "LowParse.Spec.Bytes.synth_bounded_vlbytes", "LowParse.Spec.Bytes.serialize_bounded_vlbytes_aux", "LowParse.SLow.Bytes.size32_bounded_vlbytes_aux", "Prims.eq2", "LowParse.SLow.Base.size32", "LowParse.Spec.Bytes.parse_bounded_vlbytes'", "LowParse.Spec.Bytes.serialize_bounded_vlbytes'" ]
[]
false
false
false
false
false
let size32_bounded_vlbytes' (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (l: nat{l >= log256' max /\ l <= 4}) : Tot (size32 (serialize_bounded_vlbytes' min max l)) =
size32_synth (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) (serialize_bounded_vlbytes_aux min max l) (size32_bounded_vlbytes_aux min max l) (fun (x: parse_bounded_vlbytes_t min max) -> (x <: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes)) (fun x -> x) ()
false
LowParse.SLow.Bytes.fst
LowParse.SLow.Bytes.parse32_bounded_vlgenbytes
val parse32_bounded_vlgenbytes (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0}) (max32: U32.t{U32.v max32 == max}) (#kk: parser_kind) (#pk: parser kk (bounded_int32 min max)) (pk32: parser32 pk) : Tot (parser32 (parse_bounded_vlgenbytes min max pk))
val parse32_bounded_vlgenbytes (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0}) (max32: U32.t{U32.v max32 == max}) (#kk: parser_kind) (#pk: parser kk (bounded_int32 min max)) (pk32: parser32 pk) : Tot (parser32 (parse_bounded_vlgenbytes min max pk))
let parse32_bounded_vlgenbytes (min: nat) (min32: U32.t { U32.v min32 == min }) (max: nat{ min <= max /\ max > 0 }) (max32: U32.t { U32.v max32 == max }) (#kk: parser_kind) (#pk: parser kk (bounded_int32 min max)) (pk32: parser32 pk) : Tot (parser32 (parse_bounded_vlgenbytes min max pk)) = parse32_synth (parse_bounded_vlgen min max pk serialize_all_bytes) (fun x -> (x <: parse_bounded_vlbytes_t min max)) (fun x -> (x <: parse_bounded_vlbytes_t min max)) (parse32_bounded_vlgen min min32 max max32 pk32 serialize_all_bytes parse32_all_bytes) ()
{ "file_name": "src/lowparse/LowParse.SLow.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 6, "end_line": 188, "start_col": 0, "start_line": 174 }
module LowParse.SLow.Bytes include LowParse.Spec.Bytes include LowParse.SLow.VLData include LowParse.SLow.VLGen module B32 = FStar.Bytes module Seq = FStar.Seq module U32 = FStar.UInt32 inline_for_extraction let parse32_flbytes_gen (sz: nat { sz < 4294967296 } ) (x: B32.lbytes sz) : Tot (y: B32.lbytes sz { y == parse_flbytes_gen sz (B32.reveal x) } ) = B32.hide_reveal x; x #set-options "--z3rlimit 32" inline_for_extraction let parse32_flbytes (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) : Tot ( lt_pow2_32 sz; parser32 (parse_flbytes sz) ) = lt_pow2_32 sz; make_total_constant_size_parser32 sz sz' #(B32.lbytes sz) (parse_flbytes_gen sz) () (parse32_flbytes_gen sz) inline_for_extraction let serialize32_flbytes (sz: nat { sz < 4294967296 } ) : Tot (serializer32 (serialize_flbytes sz)) = fun (input: B32.lbytes sz) -> B32.hide_reveal input; (input <: (res: bytes32 { serializer32_correct (serialize_flbytes sz) input res } )) inline_for_extraction let parse32_all_bytes : parser32 parse_all_bytes = fun (input: B32.bytes) -> let res = Some (input, B32.len input) in (res <: (res: option (bytes32 * U32.t) { parser32_correct parse_all_bytes input res } )) inline_for_extraction let serialize32_all_bytes : serializer32 serialize_all_bytes = fun (input: B32.bytes) -> (input <: (res: bytes32 { serializer32_correct serialize_all_bytes input res } )) inline_for_extraction let parse32_bounded_vlbytes' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (parser32 (parse_bounded_vlbytes' min max l)) = parse32_synth _ (synth_bounded_vlbytes min max) (fun (x: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) -> (x <: parse_bounded_vlbytes_t min max)) (parse32_bounded_vldata_strong' min min32 max max32 l serialize_all_bytes parse32_all_bytes) () inline_for_extraction let parse32_bounded_vlbytes (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (max32: U32.t { U32.v max32 == max } ) : Tot (parser32 (parse_bounded_vlbytes min max)) = parse32_bounded_vlbytes' min min32 max max32 (log256' max) inline_for_extraction let serialize32_bounded_vlbytes_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (serializer32 (serialize_bounded_vlbytes_aux min max l)) = serialize32_bounded_vldata_strong' min max l #_ #_ #parse_all_bytes #serialize_all_bytes serialize32_all_bytes inline_for_extraction let serialize32_bounded_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (serializer32 (serialize_bounded_vlbytes' min max l)) = serialize32_synth (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) (serialize_bounded_vlbytes_aux min max l) (serialize32_bounded_vlbytes_aux min max l) (fun (x: parse_bounded_vlbytes_t min max) -> (x <: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) ) (fun x -> x) () inline_for_extraction let serialize32_bounded_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 : Tot (serializer32 (serialize_bounded_vlbytes min max)) = serialize32_bounded_vlbytes' min max (log256' max) inline_for_extraction let size32_all_bytes : size32 serialize_all_bytes = fun (input: B32.bytes) -> let res = B32.len input in (res <: (res: U32.t { size32_postcond serialize_all_bytes input res } )) inline_for_extraction let size32_bounded_vlbytes_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (size32 (serialize_bounded_vlbytes_aux min max l)) = size32_bounded_vldata_strong' min max l #_ #_ #parse_all_bytes #serialize_all_bytes size32_all_bytes (U32.uint_to_t l) inline_for_extraction let size32_bounded_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (size32 (serialize_bounded_vlbytes' min max l)) = size32_synth (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) (serialize_bounded_vlbytes_aux min max l) (size32_bounded_vlbytes_aux min max l) (fun (x: parse_bounded_vlbytes_t min max) -> (x <: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) ) (fun x -> x) () inline_for_extraction let size32_bounded_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 : Tot (size32 (serialize_bounded_vlbytes min max)) = size32_bounded_vlbytes' min max (log256' max)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.SLow.VLGen.fst.checked", "LowParse.SLow.VLData.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Bytes.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.SLow.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 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": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
min: Prims.nat -> min32: FStar.UInt32.t{FStar.UInt32.v min32 == min} -> max: Prims.nat{min <= max /\ max > 0} -> max32: FStar.UInt32.t{FStar.UInt32.v max32 == max} -> pk32: LowParse.SLow.Base.parser32 pk -> LowParse.SLow.Base.parser32 (LowParse.Spec.Bytes.parse_bounded_vlgenbytes min max pk)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "FStar.UInt32.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.UInt32.v", "Prims.l_and", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.SLow.Base.parser32", "LowParse.SLow.Combinators.parse32_synth", "LowParse.Spec.VLGen.parse_bounded_vlgen_kind", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.VLData.parse_bounded_vldata_strong_t", "FStar.Bytes.bytes", "LowParse.Spec.Bytes.parse_all_bytes", "LowParse.Spec.Bytes.serialize_all_bytes", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.VLGen.parse_bounded_vlgen", "LowParse.SLow.VLGen.parse32_bounded_vlgen", "LowParse.SLow.Bytes.parse32_all_bytes", "LowParse.Spec.Bytes.parse_bounded_vlgenbytes" ]
[]
false
false
false
false
false
let parse32_bounded_vlgenbytes (min: nat) (min32: U32.t{U32.v min32 == min}) (max: nat{min <= max /\ max > 0}) (max32: U32.t{U32.v max32 == max}) (#kk: parser_kind) (#pk: parser kk (bounded_int32 min max)) (pk32: parser32 pk) : Tot (parser32 (parse_bounded_vlgenbytes min max pk)) =
parse32_synth (parse_bounded_vlgen min max pk serialize_all_bytes) (fun x -> (x <: parse_bounded_vlbytes_t min max)) (fun x -> (x <: parse_bounded_vlbytes_t min max)) (parse32_bounded_vlgen min min32 max max32 pk32 serialize_all_bytes parse32_all_bytes) ()
false
LowParse.SLow.Bytes.fst
LowParse.SLow.Bytes.serialize32_bounded_vlbytes'
val serialize32_bounded_vlbytes' (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (l: nat{l >= log256' max /\ l <= 4}) : Tot (serializer32 (serialize_bounded_vlbytes' min max l))
val serialize32_bounded_vlbytes' (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (l: nat{l >= log256' max /\ l <= 4}) : Tot (serializer32 (serialize_bounded_vlbytes' min max l))
let serialize32_bounded_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (serializer32 (serialize_bounded_vlbytes' min max l)) = serialize32_synth (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) (serialize_bounded_vlbytes_aux min max l) (serialize32_bounded_vlbytes_aux min max l) (fun (x: parse_bounded_vlbytes_t min max) -> (x <: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) ) (fun x -> x) ()
{ "file_name": "src/lowparse/LowParse.SLow.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 6, "end_line": 114, "start_col": 0, "start_line": 100 }
module LowParse.SLow.Bytes include LowParse.Spec.Bytes include LowParse.SLow.VLData include LowParse.SLow.VLGen module B32 = FStar.Bytes module Seq = FStar.Seq module U32 = FStar.UInt32 inline_for_extraction let parse32_flbytes_gen (sz: nat { sz < 4294967296 } ) (x: B32.lbytes sz) : Tot (y: B32.lbytes sz { y == parse_flbytes_gen sz (B32.reveal x) } ) = B32.hide_reveal x; x #set-options "--z3rlimit 32" inline_for_extraction let parse32_flbytes (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) : Tot ( lt_pow2_32 sz; parser32 (parse_flbytes sz) ) = lt_pow2_32 sz; make_total_constant_size_parser32 sz sz' #(B32.lbytes sz) (parse_flbytes_gen sz) () (parse32_flbytes_gen sz) inline_for_extraction let serialize32_flbytes (sz: nat { sz < 4294967296 } ) : Tot (serializer32 (serialize_flbytes sz)) = fun (input: B32.lbytes sz) -> B32.hide_reveal input; (input <: (res: bytes32 { serializer32_correct (serialize_flbytes sz) input res } )) inline_for_extraction let parse32_all_bytes : parser32 parse_all_bytes = fun (input: B32.bytes) -> let res = Some (input, B32.len input) in (res <: (res: option (bytes32 * U32.t) { parser32_correct parse_all_bytes input res } )) inline_for_extraction let serialize32_all_bytes : serializer32 serialize_all_bytes = fun (input: B32.bytes) -> (input <: (res: bytes32 { serializer32_correct serialize_all_bytes input res } )) inline_for_extraction let parse32_bounded_vlbytes' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (parser32 (parse_bounded_vlbytes' min max l)) = parse32_synth _ (synth_bounded_vlbytes min max) (fun (x: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) -> (x <: parse_bounded_vlbytes_t min max)) (parse32_bounded_vldata_strong' min min32 max max32 l serialize_all_bytes parse32_all_bytes) () inline_for_extraction let parse32_bounded_vlbytes (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (max32: U32.t { U32.v max32 == max } ) : Tot (parser32 (parse_bounded_vlbytes min max)) = parse32_bounded_vlbytes' min min32 max max32 (log256' max) inline_for_extraction let serialize32_bounded_vlbytes_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (serializer32 (serialize_bounded_vlbytes_aux min max l)) = serialize32_bounded_vldata_strong' min max l #_ #_ #parse_all_bytes #serialize_all_bytes serialize32_all_bytes
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.SLow.VLGen.fst.checked", "LowParse.SLow.VLData.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Bytes.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.SLow.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 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": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967292} -> l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4} -> LowParse.SLow.Base.serializer32 (LowParse.Spec.Bytes.serialize_bounded_vlbytes' min max l)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "Prims.op_GreaterThanOrEqual", "LowParse.Spec.BoundedInt.log256'", "LowParse.SLow.Combinators.serialize32_synth", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.VLData.parse_bounded_vldata_strong_t", "FStar.Bytes.bytes", "LowParse.Spec.Bytes.parse_all_bytes", "LowParse.Spec.Bytes.serialize_all_bytes", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.Bytes.parse_bounded_vlbytes_aux", "LowParse.Spec.Bytes.synth_bounded_vlbytes", "LowParse.Spec.Bytes.serialize_bounded_vlbytes_aux", "LowParse.SLow.Bytes.serialize32_bounded_vlbytes_aux", "Prims.eq2", "LowParse.SLow.Base.serializer32", "LowParse.Spec.Bytes.parse_bounded_vlbytes'", "LowParse.Spec.Bytes.serialize_bounded_vlbytes'" ]
[]
false
false
false
false
false
let serialize32_bounded_vlbytes' (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (l: nat{l >= log256' max /\ l <= 4}) : Tot (serializer32 (serialize_bounded_vlbytes' min max l)) =
serialize32_synth (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) (serialize_bounded_vlbytes_aux min max l) (serialize32_bounded_vlbytes_aux min max l) (fun (x: parse_bounded_vlbytes_t min max) -> (x <: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes)) (fun x -> x) ()
false
LowParse.SLow.Bytes.fst
LowParse.SLow.Bytes.size32_bounded_vlbytes_aux
val size32_bounded_vlbytes_aux (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (l: nat{l >= log256' max /\ l <= 4}) : Tot (size32 (serialize_bounded_vlbytes_aux min max l))
val size32_bounded_vlbytes_aux (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (l: nat{l >= log256' max /\ l <= 4}) : Tot (size32 (serialize_bounded_vlbytes_aux min max l))
let size32_bounded_vlbytes_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (size32 (serialize_bounded_vlbytes_aux min max l)) = size32_bounded_vldata_strong' min max l #_ #_ #parse_all_bytes #serialize_all_bytes size32_all_bytes (U32.uint_to_t l)
{ "file_name": "src/lowparse/LowParse.SLow.Bytes.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 21, "end_line": 146, "start_col": 0, "start_line": 131 }
module LowParse.SLow.Bytes include LowParse.Spec.Bytes include LowParse.SLow.VLData include LowParse.SLow.VLGen module B32 = FStar.Bytes module Seq = FStar.Seq module U32 = FStar.UInt32 inline_for_extraction let parse32_flbytes_gen (sz: nat { sz < 4294967296 } ) (x: B32.lbytes sz) : Tot (y: B32.lbytes sz { y == parse_flbytes_gen sz (B32.reveal x) } ) = B32.hide_reveal x; x #set-options "--z3rlimit 32" inline_for_extraction let parse32_flbytes (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) : Tot ( lt_pow2_32 sz; parser32 (parse_flbytes sz) ) = lt_pow2_32 sz; make_total_constant_size_parser32 sz sz' #(B32.lbytes sz) (parse_flbytes_gen sz) () (parse32_flbytes_gen sz) inline_for_extraction let serialize32_flbytes (sz: nat { sz < 4294967296 } ) : Tot (serializer32 (serialize_flbytes sz)) = fun (input: B32.lbytes sz) -> B32.hide_reveal input; (input <: (res: bytes32 { serializer32_correct (serialize_flbytes sz) input res } )) inline_for_extraction let parse32_all_bytes : parser32 parse_all_bytes = fun (input: B32.bytes) -> let res = Some (input, B32.len input) in (res <: (res: option (bytes32 * U32.t) { parser32_correct parse_all_bytes input res } )) inline_for_extraction let serialize32_all_bytes : serializer32 serialize_all_bytes = fun (input: B32.bytes) -> (input <: (res: bytes32 { serializer32_correct serialize_all_bytes input res } )) inline_for_extraction let parse32_bounded_vlbytes' (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (max32: U32.t { U32.v max32 == max } ) (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (parser32 (parse_bounded_vlbytes' min max l)) = parse32_synth _ (synth_bounded_vlbytes min max) (fun (x: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) -> (x <: parse_bounded_vlbytes_t min max)) (parse32_bounded_vldata_strong' min min32 max max32 l serialize_all_bytes parse32_all_bytes) () inline_for_extraction let parse32_bounded_vlbytes (min: nat) (min32: U32.t { U32.v min32 == min } ) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (max32: U32.t { U32.v max32 == max } ) : Tot (parser32 (parse_bounded_vlbytes min max)) = parse32_bounded_vlbytes' min min32 max max32 (log256' max) inline_for_extraction let serialize32_bounded_vlbytes_aux (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (serializer32 (serialize_bounded_vlbytes_aux min max l)) = serialize32_bounded_vldata_strong' min max l #_ #_ #parse_all_bytes #serialize_all_bytes serialize32_all_bytes inline_for_extraction let serialize32_bounded_vlbytes' (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 (l: nat { l >= log256' max /\ l <= 4 } ) : Tot (serializer32 (serialize_bounded_vlbytes' min max l)) = serialize32_synth (parse_bounded_vlbytes_aux min max l) (synth_bounded_vlbytes min max) (serialize_bounded_vlbytes_aux min max l) (serialize32_bounded_vlbytes_aux min max l) (fun (x: parse_bounded_vlbytes_t min max) -> (x <: parse_bounded_vldata_strong_t min max #_ #_ #parse_all_bytes serialize_all_bytes) ) (fun x -> x) () inline_for_extraction let serialize32_bounded_vlbytes (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967292 } ) // max MUST BE less than 2^32 - 4 : Tot (serializer32 (serialize_bounded_vlbytes min max)) = serialize32_bounded_vlbytes' min max (log256' max) inline_for_extraction let size32_all_bytes : size32 serialize_all_bytes = fun (input: B32.bytes) -> let res = B32.len input in (res <: (res: U32.t { size32_postcond serialize_all_bytes input res } ))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Bytes.fst.checked", "LowParse.SLow.VLGen.fst.checked", "LowParse.SLow.VLData.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Bytes.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.SLow.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.VLData", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 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": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967292} -> l: Prims.nat{l >= LowParse.Spec.BoundedInt.log256' max /\ l <= 4} -> LowParse.SLow.Base.size32 (LowParse.Spec.Bytes.serialize_bounded_vlbytes_aux min max l)
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "Prims.op_GreaterThanOrEqual", "LowParse.Spec.BoundedInt.log256'", "LowParse.SLow.VLData.size32_bounded_vldata_strong'", "LowParse.Spec.Bytes.parse_all_bytes_kind", "FStar.Bytes.bytes", "LowParse.Spec.Bytes.parse_all_bytes", "LowParse.Spec.Bytes.serialize_all_bytes", "LowParse.SLow.Bytes.size32_all_bytes", "FStar.UInt32.uint_to_t", "LowParse.SLow.Base.size32", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.VLData.parse_bounded_vldata_strong_t", "LowParse.Spec.Bytes.parse_bounded_vlbytes_aux", "LowParse.Spec.Bytes.serialize_bounded_vlbytes_aux" ]
[]
false
false
false
false
false
let size32_bounded_vlbytes_aux (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967292}) (l: nat{l >= log256' max /\ l <= 4}) : Tot (size32 (serialize_bounded_vlbytes_aux min max l)) =
size32_bounded_vldata_strong' min max l #_ #_ #parse_all_bytes #serialize_all_bytes size32_all_bytes (U32.uint_to_t l)
false
Hacl.Impl.Frodo.Encode.fst
Hacl.Impl.Frodo.Encode.dc
val dc: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b < v logq} -> c:uint16 -> r:uint16{r == S.dc (v logq) (v b) c}
val dc: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b < v logq} -> c:uint16 -> r:uint16{r == S.dc (v logq) (v b) c}
let dc logq b c = let res1 = (c +. (u16 1 <<. (logq -. b -. size 1))) >>. (logq -. b) in res1 &. ((u16 1 <<. b) -. u16 1)
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Encode.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 34, "end_line": 42, "start_col": 0, "start_line": 40 }
module Hacl.Impl.Frodo.Encode open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Impl.Matrix module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module S = Spec.Frodo.Encode #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract private val ec: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= v logq} -> k:uint16{v k < pow2 (v b)} -> r:uint16{r == S.ec (v logq) (v b) k} let ec logq b a = a <<. (logq -. b) inline_for_extraction noextract private val dc: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b < v logq} -> c:uint16 -> r:uint16{r == S.dc (v logq) (v b) c}
{ "checked_file": "/", "dependencies": [ "Spec.Matrix.fst.checked", "Spec.Frodo.Lemmas.fst.checked", "Spec.Frodo.Encode.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Matrix.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.Frodo.Encode.fst" }
[ { "abbrev": true, "full_module": "Spec.Frodo.Encode", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "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.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
logq: Lib.IntTypes.size_t{0 < Lib.IntTypes.v logq /\ Lib.IntTypes.v logq <= 16} -> b: Lib.IntTypes.size_t{0 < Lib.IntTypes.v b /\ Lib.IntTypes.v b < Lib.IntTypes.v logq} -> c: Lib.IntTypes.uint16 -> r: Lib.IntTypes.uint16{r == Spec.Frodo.Encode.dc (Lib.IntTypes.v logq) (Lib.IntTypes.v b) c}
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.op_LessThanOrEqual", "Lib.IntTypes.uint16", "Lib.IntTypes.op_Amp_Dot", "Lib.IntTypes.U16", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Subtraction_Dot", "Lib.IntTypes.op_Less_Less_Dot", "Lib.IntTypes.u16", "Lib.IntTypes.int_t", "Lib.IntTypes.op_Greater_Greater_Dot", "Lib.IntTypes.op_Plus_Dot", "Lib.IntTypes.size", "Prims.eq2", "Spec.Frodo.Encode.dc" ]
[]
false
false
false
false
false
let dc logq b c =
let res1 = (c +. (u16 1 <<. (logq -. b -. size 1))) >>. (logq -. b) in res1 &. ((u16 1 <<. b) -. u16 1)
false
Hacl.Impl.Frodo.Encode.fst
Hacl.Impl.Frodo.Encode.ec
val ec: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= v logq} -> k:uint16{v k < pow2 (v b)} -> r:uint16{r == S.ec (v logq) (v b) k}
val ec: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= v logq} -> k:uint16{v k < pow2 (v b)} -> r:uint16{r == S.ec (v logq) (v b) k}
let ec logq b a = a <<. (logq -. b)
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Encode.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 19, "end_line": 30, "start_col": 0, "start_line": 29 }
module Hacl.Impl.Frodo.Encode open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Impl.Matrix module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module S = Spec.Frodo.Encode #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract private val ec: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= v logq} -> k:uint16{v k < pow2 (v b)} -> r:uint16{r == S.ec (v logq) (v b) k}
{ "checked_file": "/", "dependencies": [ "Spec.Matrix.fst.checked", "Spec.Frodo.Lemmas.fst.checked", "Spec.Frodo.Encode.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Matrix.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.Frodo.Encode.fst" }
[ { "abbrev": true, "full_module": "Spec.Frodo.Encode", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "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.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
logq: Lib.IntTypes.size_t{0 < Lib.IntTypes.v logq /\ Lib.IntTypes.v logq <= 16} -> b: Lib.IntTypes.size_t{0 < Lib.IntTypes.v b /\ Lib.IntTypes.v b <= Lib.IntTypes.v logq} -> k: Lib.IntTypes.uint16{Lib.IntTypes.v k < Prims.pow2 (Lib.IntTypes.v b)} -> r: Lib.IntTypes.uint16{r == Spec.Frodo.Encode.ec (Lib.IntTypes.v logq) (Lib.IntTypes.v b) k}
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.op_LessThanOrEqual", "Lib.IntTypes.uint16", "Lib.IntTypes.U16", "Lib.IntTypes.SEC", "Prims.pow2", "Lib.IntTypes.op_Less_Less_Dot", "Lib.IntTypes.op_Subtraction_Dot", "Prims.eq2", "Spec.Frodo.Encode.ec" ]
[]
false
false
false
false
false
let ec logq b a =
a <<. (logq -. b)
false
Hacl.Impl.Frodo.Encode.fst
Hacl.Impl.Frodo.Encode.ec1
val ec1: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b <= v logq} -> x:uint64 -> k:size_t{v k < 8} -> res:uint16{res == S.ec1 (v logq) (v b) x (v k)}
val ec1: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b <= v logq} -> x:uint64 -> k:size_t{v k < 8} -> res:uint16{res == S.ec1 (v logq) (v b) x (v k)}
let ec1 logq b x k = Spec.Frodo.Lemmas.modulo_pow2_u64 (x >>. (b *! k)) (v b); let rk = (x >>. (b *! k)) &. ((u64 1 <<. b) -. u64 1) in ec logq b (to_u16 rk)
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Encode.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 23, "end_line": 56, "start_col": 0, "start_line": 53 }
module Hacl.Impl.Frodo.Encode open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Impl.Matrix module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module S = Spec.Frodo.Encode #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract private val ec: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= v logq} -> k:uint16{v k < pow2 (v b)} -> r:uint16{r == S.ec (v logq) (v b) k} let ec logq b a = a <<. (logq -. b) inline_for_extraction noextract private val dc: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b < v logq} -> c:uint16 -> r:uint16{r == S.dc (v logq) (v b) c} let dc logq b c = let res1 = (c +. (u16 1 <<. (logq -. b -. size 1))) >>. (logq -. b) in res1 &. ((u16 1 <<. b) -. u16 1) inline_for_extraction noextract private val ec1: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b <= v logq} -> x:uint64 -> k:size_t{v k < 8} -> res:uint16{res == S.ec1 (v logq) (v b) x (v k)}
{ "checked_file": "/", "dependencies": [ "Spec.Matrix.fst.checked", "Spec.Frodo.Lemmas.fst.checked", "Spec.Frodo.Encode.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Matrix.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.Frodo.Encode.fst" }
[ { "abbrev": true, "full_module": "Spec.Frodo.Encode", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "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.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
logq: Lib.IntTypes.size_t{0 < Lib.IntTypes.v logq /\ Lib.IntTypes.v logq <= 16} -> b: Lib.IntTypes.size_t {0 < Lib.IntTypes.v b /\ Lib.IntTypes.v b <= 8 /\ Lib.IntTypes.v b <= Lib.IntTypes.v logq} -> x: Lib.IntTypes.uint64 -> k: Lib.IntTypes.size_t{Lib.IntTypes.v k < 8} -> res: Lib.IntTypes.uint16 {res == Spec.Frodo.Encode.ec1 (Lib.IntTypes.v logq) (Lib.IntTypes.v b) x (Lib.IntTypes.v k)}
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.op_LessThanOrEqual", "Lib.IntTypes.uint64", "Hacl.Impl.Frodo.Encode.ec", "Lib.IntTypes.to_u16", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.IntTypes.int_t", "Lib.IntTypes.op_Amp_Dot", "Lib.IntTypes.op_Greater_Greater_Dot", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.op_Subtraction_Dot", "Lib.IntTypes.op_Less_Less_Dot", "Lib.IntTypes.u64", "Prims.unit", "Spec.Frodo.Lemmas.modulo_pow2_u64", "Lib.IntTypes.uint16", "Prims.eq2", "Spec.Frodo.Encode.ec1" ]
[]
false
false
false
false
false
let ec1 logq b x k =
Spec.Frodo.Lemmas.modulo_pow2_u64 (x >>. (b *! k)) (v b); let rk = (x >>. (b *! k)) &. ((u64 1 <<. b) -. u64 1) in ec logq b (to_u16 rk)
false
Enum.fst
Enum.bounded
val bounded : b: Enum.bound -> Type0
let bounded (b:bound) = n:nat{bounded_by b n}
{ "file_name": "examples/typeclasses/Enum.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 45, "end_line": 30, "start_col": 0, "start_line": 30 }
(* 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 Enum open FStar.Tactics.Typeclasses open FStar.Tactics.V2 type bound = option nat let bounded_by (b:bound) n = match b with | Some b -> b2t (n <= b) | None -> True let succ : bound -> bound = function | None -> None | Some b -> Some (b+1)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Enum.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: Enum.bound -> Type0
Prims.Tot
[ "total" ]
[]
[ "Enum.bound", "Prims.nat", "Enum.bounded_by" ]
[]
false
false
false
true
true
let bounded (b: bound) =
n: nat{bounded_by b n}
false
Hacl.Spec.Poly1305.Field32xN.Lemmas.fst
Hacl.Spec.Poly1305.Field32xN.Lemmas.fmul_r4_normalize5_lemma
val fmul_r4_normalize5_lemma: acc:felem5 4 -> r:felem5 4 -> r_5:felem5 4 -> r4:felem5 4 -> Lemma (requires felem_fits5 acc (3, 3, 3, 3, 3) /\ felem_fits5 r (1, 1, 1, 1, 1) /\ felem_fits5 r4 (2, 2, 2, 2, 2) /\ r_5 == precomp_r5 r /\ feval5 r4 == Vec.compute_r4 (feval5 r).[0]) (ensures (let out = fmul_r4_normalize5 acc r r_5 r4 in felem_fits5 out (2, 1, 1, 1, 1) /\ (feval5 out).[0] == Vec.normalize_4 (feval5 r).[0] (feval5 acc))) [SMTPat (fmul_r4_normalize5 acc r r_5 r4)]
val fmul_r4_normalize5_lemma: acc:felem5 4 -> r:felem5 4 -> r_5:felem5 4 -> r4:felem5 4 -> Lemma (requires felem_fits5 acc (3, 3, 3, 3, 3) /\ felem_fits5 r (1, 1, 1, 1, 1) /\ felem_fits5 r4 (2, 2, 2, 2, 2) /\ r_5 == precomp_r5 r /\ feval5 r4 == Vec.compute_r4 (feval5 r).[0]) (ensures (let out = fmul_r4_normalize5 acc r r_5 r4 in felem_fits5 out (2, 1, 1, 1, 1) /\ (feval5 out).[0] == Vec.normalize_4 (feval5 r).[0] (feval5 acc))) [SMTPat (fmul_r4_normalize5 acc r r_5 r4)]
let fmul_r4_normalize5_lemma acc fr fr_5 fr4 = let fr2 = fmul_r5 #4 fr fr fr_5 in let fr3 = fmul_r5 #4 fr2 fr fr_5 in let out = fmul_r4_normalize50 acc fr fr2 fr3 fr4 in let v2 = fmul_r4_normalize51 out in let res = carry_full_felem5 v2 in carry_full_felem5_lemma v2
{ "file_name": "code/poly1305/Hacl.Spec.Poly1305.Field32xN.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 28, "end_line": 620, "start_col": 0, "start_line": 614 }
module Hacl.Spec.Poly1305.Field32xN.Lemmas open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open Hacl.Spec.Poly1305.Field32xN open Hacl.Poly1305.Field32xN.Lemmas0 open Hacl.Poly1305.Field32xN.Lemmas1 open Hacl.Poly1305.Field32xN.Lemmas2 module Vec = Hacl.Spec.Poly1305.Vec #set-options "--z3rlimit 100 --max_fuel 0 --initial_ifuel 1 --max_ifuel 1 --using_facts_from '* -FStar.Seq'" val lemma_feval_is_fas_nat_i: #w:lanes -> f:felem5 w{felem_less5 f (pow2 128)} -> i:size_nat{i < w} -> Lemma ((feval5 f).[i] == (fas_nat5 f).[i]) let lemma_feval_is_fas_nat_i #w f i = assert_norm (pow2 128 < Vec.prime); assert ((feval5 f).[i] == (as_nat5 (transpose f).[i]) % Vec.prime); FStar.Math.Lemmas.modulo_lemma (as_nat5 (transpose f).[i]) Vec.prime val lemma_feval_is_fas_nat: #w:lanes -> f:felem5 w{felem_less5 f (pow2 128)} -> Lemma (forall (i:nat). i < w ==> (fas_nat5 f).[i] == (feval5 f).[i]) let lemma_feval_is_fas_nat #w f = FStar.Classical.forall_intro (lemma_feval_is_fas_nat_i #w f) val precomp_r5_fits_lemma: #w:lanes -> r:felem5 w{felem_fits5 r (1, 1, 1, 1, 1)} -> Lemma (felem_fits5 (precomp_r5 #w r) (5, 5, 5, 5, 5)) [SMTPat (precomp_r5 #w r)] let precomp_r5_fits_lemma #w r = FStar.Classical.forall_intro (precomp_r5_as_tup64 #w r) val precomp_r5_fits_lemma2: #w:lanes -> r:felem5 w{felem_fits5 r (2, 2, 2, 2, 2)} -> Lemma (felem_fits5 (precomp_r5 #w r) (10, 10, 10, 10, 10)) [SMTPat (precomp_r5 #w r)] let precomp_r5_fits_lemma2 #w r = FStar.Classical.forall_intro (precomp_r5_as_tup64 #w r) val precomp_r5_zeros: w:lanes -> Lemma (let r = (zero w, zero w, zero w, zero w, zero w) in precomp_r5 r == (zero w, zero w, zero w, zero w, zero w)) let precomp_r5_zeros w = let r = (zero w, zero w, zero w, zero w, zero w) in let (r0, r1, r2, r3, r4) = precomp_r5 r in let aux (i:nat{i < w}) : Lemma ((vec_v (vec_smul_mod (zero w) (u64 5))).[i] == u64 0) = () in Classical.forall_intro aux; eq_intro (vec_v (vec_smul_mod (zero w) (u64 5))) (vec_v (zero w)); vecv_extensionality (vec_smul_mod (zero w) (u64 5)) (zero w) val fadd5_fits_lemma: #w:lanes -> f1:felem5 w{felem_fits5 f1 (2,2,2,2,2)} -> f2:felem5 w{felem_fits5 f2 (1,1,1,1,1)} -> Lemma (felem_fits5 (fadd5 f1 f2) (3,3,3,3,3)) [SMTPat (fadd5 f1 f2)] let fadd5_fits_lemma #w f1 f2 = let (f10, f11, f12, f13, f14) = f1 in let (f20, f21, f22, f23, f24) = f2 in let o = fadd5 f1 f2 in vec_add_mod_lemma f10 f20; vec_add_mod_lemma f11 f21; vec_add_mod_lemma f12 f22; vec_add_mod_lemma f13 f23; vec_add_mod_lemma f14 f24 val fadd5_eval_lemma: #w:lanes -> f1:felem5 w{felem_fits5 f1 (2,2,2,2,2)} -> f2:felem5 w{felem_fits5 f2 (1,1,1,1,1)} -> Lemma (feval5 (fadd5 f1 f2) == map2 Vec.pfadd (feval5 f1) (feval5 f2)) [SMTPat (fadd5 f1 f2)] let fadd5_eval_lemma #w f1 f2 = let o = fadd5 f1 f2 in FStar.Classical.forall_intro (fadd5_eval_lemma_i f1 f2); eq_intro (feval5 o) (map2 Vec.pfadd (feval5 f1) (feval5 f2)) val mul_felem5_fits_lemma: #w:lanes -> f1:felem5 w{felem_fits5 f1 (3, 3, 3, 3, 3)} -> r:felem5 w{felem_fits5 r (2, 2, 2, 2, 2)} -> r5:felem5 w{felem_fits5 r5 (10, 10, 10, 10, 10)} -> Lemma (felem_wide_fits5 (mul_felem5 #w f1 r r5) (126, 102, 78, 54, 30)) [SMTPat (mul_felem5 #w f1 r r5)] let mul_felem5_fits_lemma #w f1 r r5 = let (r0, r1, r2, r3, r4) = r in let (f10, f11, f12, f13, f14) = f1 in let (r50, r51, r52, r53, r54) = r5 in let (a0,a1,a2,a3,a4) = smul_felem5 #w f10 (r0,r1,r2,r3,r4) in smul_felem5_fits_lemma #w #3 #(2,2,2,2,2) f10 (r0,r1,r2,r3,r4); let (a10,a11,a12,a13,a14) = smul_add_felem5 #w f11 (r54,r0,r1,r2,r3) (a0,a1,a2,a3,a4) in smul_add_felem5_fits_lemma #w #3 #(10,2,2,2,2) #(6,6,6,6,6) f11 (r54,r0,r1,r2,r3) (a0,a1,a2,a3,a4); let (a20,a21,a22,a23,a24) = smul_add_felem5 #w f12 (r53,r54,r0,r1,r2) (a10,a11,a12,a13,a14) in smul_add_felem5_fits_lemma #w #3 #(10,10,2,2,2) #(36,12,12,12,12) f12 (r53,r54,r0,r1,r2) (a10,a11,a12,a13,a14); let (a30,a31,a32,a33,a34) = smul_add_felem5 #w f13 (r52,r53,r54,r0,r1) (a20,a21,a22,a23,a24) in smul_add_felem5_fits_lemma #w #3 #(10,10,10,2,2) #(66,42,18,18,18) f13 (r52,r53,r54,r0,r1) (a20,a21,a22,a23,a24); let (a40,a41,a42,a43,a44) = smul_add_felem5 #w f14 (r51,r52,r53,r54,r0) (a30,a31,a32,a33,a34) in smul_add_felem5_fits_lemma #w #3 #(10,10,10,10,2) #(96,72,48,24,24) f14 (r51,r52,r53,r54,r0) (a30,a31,a32,a33,a34) val mul_felem5_eval_lemma_i: #w:lanes -> f1:felem5 w{felem_fits5 f1 (3, 3, 3, 3, 3)} -> r:felem5 w{felem_fits5 r (2, 2, 2, 2, 2)} -> r5:felem5 w{felem_fits5 r5 (10, 10, 10, 10, 10) /\ r5 == precomp_r5 r} -> i:nat{i < w} -> Lemma ((feval5 (mul_felem5 #w f1 r r5)).[i] == (feval5 f1).[i] `Vec.pfmul` (feval5 r).[i]) let mul_felem5_eval_lemma_i #w f1 r r5 i = let (r0, r1, r2, r3, r4) = r in let (f10, f11, f12, f13, f14) = f1 in let (r50, r51, r52, r53, r54) = r5 in let (a0,a1,a2,a3,a4) = smul_felem5 #w f10 (r0,r1,r2,r3,r4) in smul_felem5_eval_lemma #w #3 #(2,2,2,2,2) f10 (r0,r1,r2,r3,r4); smul_felem5_fits_lemma #w #3 #(2,2,2,2,2) f10 (r0,r1,r2,r3,r4); assert ((fas_nat5 (a0,a1,a2,a3,a4)).[i] == (uint64xN_v f10).[i] * (fas_nat5 (r0,r1,r2,r3,r4)).[i]); let (a10,a11,a12,a13,a14) = smul_add_felem5 #w f11 (r54,r0,r1,r2,r3) (a0,a1,a2,a3,a4) in smul_add_felem5_eval_lemma #w #3 #(10,2,2,2,2) #(6,6,6,6,6) f11 (r54,r0,r1,r2,r3) (a0,a1,a2,a3,a4); smul_add_felem5_fits_lemma #w #3 #(10,2,2,2,2) #(6,6,6,6,6) f11 (r54,r0,r1,r2,r3) (a0,a1,a2,a3,a4); assert ((fas_nat5 (a10,a11,a12,a13,a14)).[i] == (fas_nat5 (a0,a1,a2,a3,a4)).[i] + (uint64xN_v f11).[i] * (fas_nat5 (r54,r0,r1,r2,r3)).[i]); let (a20,a21,a22,a23,a24) = smul_add_felem5 #w f12 (r53,r54,r0,r1,r2) (a10,a11,a12,a13,a14) in smul_add_felem5_eval_lemma #w #3 #(10,10,2,2,2) #(36,12,12,12,12) f12 (r53,r54,r0,r1,r2) (a10,a11,a12,a13,a14); smul_add_felem5_fits_lemma #w #3 #(10,10,2,2,2) #(36,12,12,12,12) f12 (r53,r54,r0,r1,r2) (a10,a11,a12,a13,a14); assert ((fas_nat5 (a20,a21,a22,a23,a24)).[i] == (fas_nat5 (a10,a11,a12,a13,a14)).[i] + (uint64xN_v f12).[i] * (fas_nat5 (r53,r54,r0,r1,r2)).[i]); let (a30,a31,a32,a33,a34) = smul_add_felem5 #w f13 (r52,r53,r54,r0,r1) (a20,a21,a22,a23,a24) in smul_add_felem5_eval_lemma #w #3 #(10,10,10,2,2) #(66,42,18,18,18) f13 (r52,r53,r54,r0,r1) (a20,a21,a22,a23,a24); smul_add_felem5_fits_lemma #w #3 #(10,10,10,2,2) #(66,42,18,18,18) f13 (r52,r53,r54,r0,r1) (a20,a21,a22,a23,a24); assert ((fas_nat5 (a30,a31,a32,a33,a34)).[i] == (fas_nat5 (a20,a21,a22,a23,a24)).[i] + (uint64xN_v f13).[i] * (fas_nat5 (r52,r53,r54,r0,r1)).[i]); let (a40,a41,a42,a43,a44) = smul_add_felem5 #w f14 (r51,r52,r53,r54,r0) (a30,a31,a32,a33,a34) in smul_add_felem5_eval_lemma #w #3 #(10,10,10,10,2) #(96,72,48,24,24) f14 (r51,r52,r53,r54,r0) (a30,a31,a32,a33,a34); smul_add_felem5_fits_lemma #w #3 #(10,10,10,10,2) #(96,72,48,24,24) f14 (r51,r52,r53,r54,r0) (a30,a31,a32,a33,a34); assert ((fas_nat5 (a40,a41,a42,a43,a44)).[i] == (fas_nat5 (a30,a31,a32,a33,a34)).[i] + (uint64xN_v f14).[i] * (fas_nat5 (r51,r52,r53,r54,r0)).[i]); assert ((fas_nat5 (a40,a41,a42,a43,a44)).[i] == (uint64xN_v f10).[i] * (fas_nat5 (r0,r1,r2,r3,r4)).[i] + (uint64xN_v f11).[i] * (fas_nat5 (r54,r0,r1,r2,r3)).[i] + (uint64xN_v f12).[i] * (fas_nat5 (r53,r54,r0,r1,r2)).[i] + (uint64xN_v f13).[i] * (fas_nat5 (r52,r53,r54,r0,r1)).[i] + (uint64xN_v f14).[i] * (fas_nat5 (r51,r52,r53,r54,r0)).[i]); mul_felem5_eval_as_tup64 #w f1 r r5 i; mul_felem5_lemma (as_tup64_i f1 i) (as_tup64_i r i) val mul_felem5_eval_lemma: #w:lanes -> f1:felem5 w{felem_fits5 f1 (3, 3, 3, 3, 3)} -> r:felem5 w{felem_fits5 r (2, 2, 2, 2, 2)} -> r5:felem5 w{felem_fits5 r5 (10, 10, 10, 10, 10) /\ r5 == precomp_r5 r} -> Lemma (feval5 (mul_felem5 #w f1 r r5) == map2 (Vec.pfmul) (feval5 f1) (feval5 r)) [SMTPat (mul_felem5 #w f1 r r5)] let mul_felem5_eval_lemma #w f1 r r5 = let tmp = map2 (Vec.pfmul) (feval5 f1) (feval5 r) in FStar.Classical.forall_intro (mul_felem5_eval_lemma_i #w f1 r r5); eq_intro (feval5 (mul_felem5 #w f1 r r5)) tmp val fmul_r5_fits_lemma: #w:lanes -> f1:felem5 w{felem_fits5 f1 (3, 3, 3, 3, 3)} -> r:felem5 w{felem_fits5 r (2, 2, 2, 2, 2)} -> r5:felem5 w{felem_fits5 r5 (10, 10, 10, 10, 10)} -> Lemma (felem_fits5 (fmul_r5 #w f1 r r5) (1, 2, 1, 1, 2)) [SMTPat (fmul_r5 #w f1 r r5)] let fmul_r5_fits_lemma #w f1 r r5 = let tmp = mul_felem5 f1 r r5 in mul_felem5_fits_lemma #w f1 r r5; let res = carry_wide_felem5 tmp in carry_wide_felem5_fits_lemma #w tmp val fmul_r5_eval_lemma: #w:lanes -> f1:felem5 w{felem_fits5 f1 (3, 3, 3, 3, 3)} -> r:felem5 w{felem_fits5 r (2, 2, 2, 2, 2)} -> r5:felem5 w{felem_fits5 r5 (10, 10, 10, 10, 10) /\ r5 == precomp_r5 r} -> Lemma (feval5 (fmul_r5 #w f1 r r5) == map2 (Vec.pfmul) (feval5 f1) (feval5 r)) [SMTPat (fmul_r5 #w f1 r r5)] let fmul_r5_eval_lemma #w f1 r r5 = let tmp = mul_felem5 f1 r r5 in mul_felem5_eval_lemma #w f1 r r5; let res = carry_wide_felem5 tmp in carry_wide_felem5_eval_lemma #w tmp val fadd_mul_r5_fits_lemma: #w:lanes -> acc:felem5 w{felem_fits5 acc (2, 2, 2, 2, 2)} -> f1:felem5 w{felem_fits5 f1 (1, 1, 1, 1, 1)} -> r:felem5 w{felem_fits5 r (1, 1, 1, 1, 1)} -> r5:felem5 w{felem_fits5 r5 (5, 5, 5, 5, 5)} -> Lemma (felem_fits5 (fadd_mul_r5 acc f1 r r5) (1, 2, 1, 1, 2)) [SMTPat (fadd_mul_r5 acc f1 r r5)] let fadd_mul_r5_fits_lemma #w acc f1 r r5 = let acc1 = fadd5 acc f1 in fadd5_fits_lemma #w acc f1; let tmp = mul_felem5 acc1 r r5 in mul_felem5_fits_lemma #w acc1 r r5; let res = carry_wide_felem5 tmp in carry_wide_felem5_fits_lemma #w tmp val fadd_mul_r5_eval_lemma: #w:lanes -> acc:felem5 w{felem_fits5 acc (2, 2, 2, 2, 2)} -> f1:felem5 w{felem_fits5 f1 (1, 1, 1, 1, 1)} -> r:felem5 w{felem_fits5 r (1, 1, 1, 1, 1)} -> r5:felem5 w{felem_fits5 r5 (5, 5, 5, 5, 5) /\ r5 == precomp_r5 r} -> Lemma (feval5 (fadd_mul_r5 acc f1 r r5) == map2 (Vec.pfmul) (map2 (Vec.pfadd) (feval5 acc) (feval5 f1)) (feval5 r)) [SMTPat (fadd_mul_r5 acc f1 r r5)] let fadd_mul_r5_eval_lemma #w acc f1 r r5 = let acc1 = fadd5 acc f1 in fadd5_eval_lemma #w acc f1; let tmp = mul_felem5 acc1 r r5 in mul_felem5_eval_lemma #w acc1 r r5; let res = carry_wide_felem5 tmp in carry_wide_felem5_eval_lemma #w tmp val reduce_felem5_eval_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (2, 2, 2, 2, 2)} -> Lemma (felem_fits5 (reduce_felem5 f) (1, 1, 1, 1, 1) /\ (feval5 f).[0] == (fas_nat5 (reduce_felem5 f)).[0]) [SMTPat (reduce_felem5 f)] let reduce_felem5_eval_lemma #w f = carry_full_felem5_eval_lemma f; carry_full_felem5_fits_lemma f; let f = carry_full_felem5 f in carry_reduce_felem5_lemma #w f; subtract_p5_felem5_lemma #w (carry_full_felem5 f) val fmul_r2_normalize50: acc:felem5 2 -> r:felem5 2 -> r2:felem5 2 -> Pure (felem5 2) (requires felem_fits5 acc (3, 3, 3, 3, 3) /\ felem_fits5 r (1, 1, 1, 1, 1) /\ felem_fits5 r2 (2, 2, 2, 2, 2) /\ feval5 r2 == Vec.compute_r2 (feval5 r).[0]) (ensures fun a -> let fr21 = create2 (feval5 r2).[0] (feval5 r).[0] in feval5 a == Vec.fmul (feval5 acc) fr21 /\ felem_fits5 a (1, 2, 1, 1, 2)) let fmul_r2_normalize50 (a0, a1, a2, a3, a4) (r0, r1, r2, r3, r4) (r20, r21, r22, r23, r24) = let r210 = vec_interleave_low r20 r0 in vec_interleave_low_lemma2 r20 r0; let r211 = vec_interleave_low r21 r1 in vec_interleave_low_lemma2 r21 r1; let r212 = vec_interleave_low r22 r2 in vec_interleave_low_lemma2 r22 r2; let r213 = vec_interleave_low r23 r3 in vec_interleave_low_lemma2 r23 r3; let r214 = vec_interleave_low r24 r4 in vec_interleave_low_lemma2 r24 r4; let acc = (a0, a1, a2, a3, a4) in let fr = (r0, r1, r2, r3, r4) in let fr2 = (r20, r21, r22, r23, r24) in assert ((feval5 fr2).[0] == Vec.pfmul ((feval5 fr).[0]) ((feval5 fr).[0])); let fr21 = (r210, r211, r212, r213, r214) in eq_intro (feval5 fr21) (create2 (feval5 fr2).[0] (feval5 fr).[0]); assert (feval5 fr21 == create2 (feval5 fr2).[0] (feval5 fr).[0]); assert (felem_fits5 fr21 (2, 2, 2, 2, 2)); let fr215 = precomp_r5 #2 fr21 in let a = fmul_r5 #2 acc fr21 fr215 in fmul_r5_eval_lemma acc fr21 fr215; fmul_r5_fits_lemma acc fr21 fr215; assert (feval5 a == Vec.fmul (feval5 acc) (feval5 fr21)); assert (felem_fits5 a (1, 2, 1, 1, 2)); a #push-options "--z3rlimit 150" val fmul_r2_normalize51: a:felem5 2 -> fa1:felem5 2 -> Pure (felem5 2) (requires felem_fits5 a (1, 2, 1, 1, 2) /\ felem_fits5 fa1 (1, 2, 1, 1, 2) /\ feval5 fa1 == create2 (feval5 a).[1] (feval5 a).[1]) (ensures fun out -> (feval5 out).[0] == Vec.pfadd (feval5 a).[0] (feval5 a).[1] /\ felem_fits5 out (2, 4, 2, 2, 4)) let fmul_r2_normalize51 a fa1 = let (a0, a1, a2, a3, a4) = a in let (a10, a11, a12, a13, a14) = fa1 in let o0 = vec_add_mod a0 a10 in let o1 = vec_add_mod a1 a11 in let o2 = vec_add_mod a2 a12 in let o3 = vec_add_mod a3 a13 in let o4 = vec_add_mod a4 a14 in let out = (o0, o1, o2, o3, o4) in let (a0, a1, a2, a3, a4) = as_tup64_i a 0 in let (a10, a11, a12, a13, a14) = as_tup64_i fa1 0 in let (o0, o1, o2, o3, o4) = as_tup64_i out 0 in FStar.Math.Lemmas.modulo_lemma (v a0 + v a10) (pow2 64); FStar.Math.Lemmas.modulo_lemma (v a1 + v a11) (pow2 64); FStar.Math.Lemmas.modulo_lemma (v a2 + v a12) (pow2 64); FStar.Math.Lemmas.modulo_lemma (v a3 + v a13) (pow2 64); FStar.Math.Lemmas.modulo_lemma (v a4 + v a14) (pow2 64); assert (felem_fits5 out (2, 4, 2, 2, 4)); calc (==) { ((feval5 a).[0] + (feval5 a).[1]) % Vec.prime; (==) { } (as_nat5 (a0, a1, a2, a3, a4) % Vec.prime + as_nat5 (a10, a11, a12, a13, a14) % Vec.prime) % Vec.prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_l (as_nat5 (a0, a1, a2, a3, a4)) (as_nat5 (a10, a11, a12, a13, a14)) Vec.prime; FStar.Math.Lemmas.lemma_mod_plus_distr_r (as_nat5 (a0, a1, a2, a3, a4) % Vec.prime) (as_nat5 (a10, a11, a12, a13, a14)) Vec.prime } (as_nat5 (a0, a1, a2, a3, a4) + as_nat5 (a10, a11, a12, a13, a14)) % Vec.prime; (==) { } (feval5 out).[0]; }; out #pop-options val fmul_r2_normalize5_lemma: acc:felem5 2 -> r:felem5 2 -> r2:felem5 2 -> Lemma (requires felem_fits5 acc (3, 3, 3, 3, 3) /\ felem_fits5 r (1, 1, 1, 1, 1) /\ felem_fits5 r2 (2, 2, 2, 2, 2) /\ feval5 r2 == Vec.compute_r2 (feval5 r).[0]) (ensures (let out = fmul_r2_normalize5 acc r r2 in felem_fits5 out (2, 1, 1, 1, 1) /\ (feval5 out).[0] == Vec.normalize_2 (feval5 r).[0] (feval5 acc))) [SMTPat (fmul_r2_normalize5 acc r r2)] let fmul_r2_normalize5_lemma acc r r2 = let a = fmul_r2_normalize50 acc r r2 in let (a0, a1, a2, a3, a4) = a in let a10 = vec_interleave_high a0 a0 in vec_interleave_high_lemma2 a0 a0; let a11 = vec_interleave_high a1 a1 in vec_interleave_high_lemma2 a1 a1; let a12 = vec_interleave_high a2 a2 in vec_interleave_high_lemma2 a2 a2; let a13 = vec_interleave_high a3 a3 in vec_interleave_high_lemma2 a3 a3; let a14 = vec_interleave_high a4 a4 in vec_interleave_high_lemma2 a4 a4; let fa1 = (a10, a11, a12, a13, a14) in eq_intro (feval5 fa1) (create2 (feval5 a).[1] (feval5 a).[1]); assert (feval5 fa1 == create2 (feval5 a).[1] (feval5 a).[1]); assert (felem_fits5 fa1 (1, 2, 1, 1, 2)); let out = fmul_r2_normalize51 a fa1 in assert ((feval5 out).[0] == Vec.pfadd (feval5 a).[0] (feval5 a).[1]); let res = carry_full_felem5 out in carry_full_felem5_lemma out val fmul_r4_normalize50: acc:felem5 4 -> r:felem5 4 -> r2:felem5 4 -> r3:felem5 4 -> r4:felem5 4 -> Pure (felem5 4) (requires felem_fits5 acc (3, 3, 3, 3, 3) /\ felem_fits5 r (1, 1, 1, 1, 1) /\ felem_fits5 r2 (2, 2, 2, 2, 2) /\ felem_fits5 r3 (2, 2, 2, 2, 2) /\ felem_fits5 r4 (2, 2, 2, 2, 2) /\ feval5 r2 == Vec.fmul (feval5 r) (feval5 r) /\ feval5 r3 == Vec.fmul (feval5 r2) (feval5 r) /\ feval5 r4 == Vec.compute_r4 (feval5 r).[0]) (ensures fun out -> let fr4321 = create4 (feval5 r4).[0] (feval5 r3).[0] (feval5 r2).[0] (feval5 r).[0] in feval5 out == Vec.fmul (feval5 acc) fr4321 /\ felem_fits5 out (1, 2, 1, 1, 2)) let fmul_r4_normalize50 acc fr fr2 fr3 fr4 = let (r10, r11, r12, r13, r14) = fr in let (r20, r21, r22, r23, r24) = fr2 in let (r30, r31, r32, r33, r34) = fr3 in let (r40, r41, r42, r43, r44) = fr4 in let (a0, a1, a2, a3, a4) = acc in let v12120 = vec_interleave_low r20 r10 in vec_interleave_low_lemma_uint64_4 r20 r10; let v34340 = vec_interleave_low r40 r30 in vec_interleave_low_lemma_uint64_4 r40 r30; let r12340 = vec_interleave_low_n 2 v34340 v12120 in vec_interleave_low_n_lemma_uint64_4_2 v34340 v12120; let v12121 = vec_interleave_low r21 r11 in vec_interleave_low_lemma_uint64_4 r21 r11; let v34341 = vec_interleave_low r41 r31 in vec_interleave_low_lemma_uint64_4 r41 r31; let r12341 = vec_interleave_low_n 2 v34341 v12121 in vec_interleave_low_n_lemma_uint64_4_2 v34341 v12121; let v12122 = vec_interleave_low r22 r12 in vec_interleave_low_lemma_uint64_4 r22 r12; let v34342 = vec_interleave_low r42 r32 in vec_interleave_low_lemma_uint64_4 r42 r32; let r12342 = vec_interleave_low_n 2 v34342 v12122 in vec_interleave_low_n_lemma_uint64_4_2 v34342 v12122; let v12123 = vec_interleave_low r23 r13 in vec_interleave_low_lemma_uint64_4 r23 r13; let v34343 = vec_interleave_low r43 r33 in vec_interleave_low_lemma_uint64_4 r43 r33; let r12343 = vec_interleave_low_n 2 v34343 v12123 in vec_interleave_low_n_lemma_uint64_4_2 v34343 v12123; let v12124 = vec_interleave_low r24 r14 in vec_interleave_low_lemma_uint64_4 r24 r14; let v34344 = vec_interleave_low r44 r34 in vec_interleave_low_lemma_uint64_4 r44 r34; let r12344 = vec_interleave_low_n 2 v34344 v12124 in vec_interleave_low_n_lemma_uint64_4_2 v34344 v12124; let fr1234 = (r12340, r12341, r12342, r12343, r12344) in eq_intro (feval5 fr1234) (create4 (feval5 fr4).[0] (feval5 fr3).[0] (feval5 fr2).[0] (feval5 fr).[0]); let fr12345 = precomp_r5 #4 fr1234 in let out = fmul_r5 #4 acc fr1234 fr12345 in fmul_r5_eval_lemma acc fr1234 fr12345; fmul_r5_fits_lemma acc fr1234 fr12345; out val lemma_fmul_r4_normalize51: #m:scale32{m <= 2} -> o:uint64xN 4{felem_fits1 o m} -> Lemma (let v00 = vec_interleave_high_n 2 o o in let v10 = vec_add_mod o v00 in let v10h = vec_interleave_high v10 v10 in let v20 = vec_add_mod v10 v10h in felem_fits1 v20 (4 * m) /\ (uint64xN_v v20).[0] == (uint64xN_v o).[0] + (uint64xN_v o).[1] + (uint64xN_v o).[2] + (uint64xN_v o).[3]) let lemma_fmul_r4_normalize51 #m o = let v00 = vec_interleave_high_n 2 o o in vec_interleave_high_n_lemma_uint64_4_2 o o; let (o0, o1, o2, o3) = ((vec_v o).[0], (vec_v o).[1], (vec_v o).[2], (vec_v o).[3]) in assert (vec_v v00 == create4 o2 o3 o2 o3); let v10 = vec_add_mod o v00 in FStar.Math.Lemmas.modulo_lemma (v o0 + v o2) (pow2 64); FStar.Math.Lemmas.modulo_lemma (v o1 + v o3) (pow2 64); assert (v (vec_v v10).[0] == v o0 + v o2); assert (v (vec_v v10).[1] == v o1 + v o3); let v10h = vec_interleave_high v10 v10 in vec_interleave_high_lemma_uint64_4 v10 v10; assert (v (vec_v v10h).[0] == v (vec_v v10).[1]); let v20 = vec_add_mod v10 v10h in FStar.Math.Lemmas.modulo_lemma (v o0 + v o2 + v o1 + v o3) (pow2 64) val lemma_fmul_r4_normalize51_expand: v2:felem5 4 -> out:felem5 4 -> Lemma (requires (let (v20, v21, v22, v23, v24) = v2 in let (o0, o1, o2, o3, o4) = out in (uint64xN_v v20).[0] == (uint64xN_v o0).[0] + (uint64xN_v o0).[1] + (uint64xN_v o0).[2] + (uint64xN_v o0).[3] /\ (uint64xN_v v21).[0] == (uint64xN_v o1).[0] + (uint64xN_v o1).[1] + (uint64xN_v o1).[2] + (uint64xN_v o1).[3] /\ (uint64xN_v v22).[0] == (uint64xN_v o2).[0] + (uint64xN_v o2).[1] + (uint64xN_v o2).[2] + (uint64xN_v o2).[3] /\ (uint64xN_v v23).[0] == (uint64xN_v o3).[0] + (uint64xN_v o3).[1] + (uint64xN_v o3).[2] + (uint64xN_v o3).[3] /\ (uint64xN_v v24).[0] == (uint64xN_v o4).[0] + (uint64xN_v o4).[1] + (uint64xN_v o4).[2] + (uint64xN_v o4).[3])) (ensures (let (v20, v21, v22, v23, v24) = v2 in let (o0, o1, o2, o3, o4) = out in (feval5 v2).[0] == Vec.pfadd (Vec.pfadd (Vec.pfadd (feval5 out).[0] (feval5 out).[1]) (feval5 out).[2]) (feval5 out).[3])) let lemma_fmul_r4_normalize51_expand v2 out = let (v20, v21, v22, v23, v24) = as_tup64_i v2 0 in let (o0, o1, o2, o3, o4) = out in calc (==) { as_nat5 (v20, v21, v22, v23, v24) % Vec.prime; (==) { } (as_nat5 (as_tup64_i out 0) + as_nat5 (as_tup64_i out 1) + as_nat5 (as_tup64_i out 2) + as_nat5 (as_tup64_i out 3)) % Vec.prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_l (as_nat5 (as_tup64_i out 0) + as_nat5 (as_tup64_i out 1)) (as_nat5 (as_tup64_i out 2) + as_nat5 (as_tup64_i out 3)) Vec.prime } ((as_nat5 (as_tup64_i out 0) + as_nat5 (as_tup64_i out 1)) % Vec.prime + as_nat5 (as_tup64_i out 2) + as_nat5 (as_tup64_i out 3)) % Vec.prime; (==) { FStar.Math.Lemmas.modulo_distributivity (as_nat5 (as_tup64_i out 0)) (as_nat5 (as_tup64_i out 1)) Vec.prime } (((feval5 out).[0] + (feval5 out).[1]) % Vec.prime + as_nat5 (as_tup64_i out 2) + as_nat5 (as_tup64_i out 3)) % Vec.prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_l (((feval5 out).[0] + (feval5 out).[1]) % Vec.prime + as_nat5 (as_tup64_i out 2)) (as_nat5 (as_tup64_i out 3)) Vec.prime } ((((feval5 out).[0] + (feval5 out).[1]) % Vec.prime + as_nat5 (as_tup64_i out 2)) % Vec.prime + as_nat5 (as_tup64_i out 3)) % Vec.prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r (((feval5 out).[0] + (feval5 out).[1]) % Vec.prime) (as_nat5 (as_tup64_i out 2)) Vec.prime } ((((feval5 out).[0] + (feval5 out).[1]) % Vec.prime + (feval5 out).[2]) % Vec.prime + as_nat5 (as_tup64_i out 3)) % Vec.prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r ((((feval5 out).[0] + (feval5 out).[1]) % Vec.prime + (feval5 out).[2]) % Vec.prime) (as_nat5 (as_tup64_i out 3)) Vec.prime } ((((feval5 out).[0] + (feval5 out).[1]) % Vec.prime + (feval5 out).[2]) % Vec.prime + (feval5 out).[3]) % Vec.prime; }; assert ((feval5 v2).[0] == ((((feval5 out).[0] + (feval5 out).[1]) % Vec.prime + (feval5 out).[2]) % Vec.prime + (feval5 out).[3]) % Vec.prime) val fmul_r4_normalize51: a:felem5 4 -> Pure (felem5 4) (requires felem_fits5 a (1, 2, 1, 1, 2)) (ensures fun res -> felem_fits5 res (4, 8, 4, 4, 8) /\ (feval5 res).[0] == Vec.pfadd (Vec.pfadd (Vec.pfadd (feval5 a).[0] (feval5 a).[1]) (feval5 a).[2]) (feval5 a).[3]) let fmul_r4_normalize51 fa = let (o0, o1, o2, o3, o4) = fa in let v00 = vec_interleave_high_n 2 o0 o0 in let v10 = vec_add_mod o0 v00 in let v10h = vec_interleave_high v10 v10 in let v20 = vec_add_mod v10 v10h in lemma_fmul_r4_normalize51 #1 o0; let v01 = vec_interleave_high_n 2 o1 o1 in let v11 = vec_add_mod o1 v01 in let v11h = vec_interleave_high v11 v11 in let v21 = vec_add_mod v11 v11h in lemma_fmul_r4_normalize51 #2 o1; let v02 = vec_interleave_high_n 2 o2 o2 in let v12 = vec_add_mod o2 v02 in let v12h = vec_interleave_high v12 v12 in let v22 = vec_add_mod v12 v12h in lemma_fmul_r4_normalize51 #1 o2; let v03 = vec_interleave_high_n 2 o3 o3 in let v13 = vec_add_mod o3 v03 in let v13h = vec_interleave_high v13 v13 in let v23 = vec_add_mod v13 v13h in lemma_fmul_r4_normalize51 #1 o3; let v04 = vec_interleave_high_n 2 o4 o4 in let v14 = vec_add_mod o4 v04 in let v14h = vec_interleave_high v14 v14 in let v24 = vec_add_mod v14 v14h in lemma_fmul_r4_normalize51 #2 o4; let res = (v20, v21, v22, v23, v24) in lemma_fmul_r4_normalize51_expand res fa; res val fmul_r4_normalize5_lemma: acc:felem5 4 -> r:felem5 4 -> r_5:felem5 4 -> r4:felem5 4 -> Lemma (requires felem_fits5 acc (3, 3, 3, 3, 3) /\ felem_fits5 r (1, 1, 1, 1, 1) /\ felem_fits5 r4 (2, 2, 2, 2, 2) /\ r_5 == precomp_r5 r /\ feval5 r4 == Vec.compute_r4 (feval5 r).[0]) (ensures (let out = fmul_r4_normalize5 acc r r_5 r4 in felem_fits5 out (2, 1, 1, 1, 1) /\ (feval5 out).[0] == Vec.normalize_4 (feval5 r).[0] (feval5 acc))) [SMTPat (fmul_r4_normalize5 acc r r_5 r4)] #restart-solver
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "Hacl.Poly1305.Field32xN.Lemmas2.fst.checked", "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "Hacl.Poly1305.Field32xN.Lemmas0.fst.checked", "Hacl.Impl.Poly1305.Lemmas.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Poly1305.Field32xN.Lemmas.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": "Vec" }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN.Lemmas2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN.Lemmas1", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN.Lemmas0", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 500, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
acc: Hacl.Spec.Poly1305.Field32xN.felem5 4 -> r: Hacl.Spec.Poly1305.Field32xN.felem5 4 -> r_5: Hacl.Spec.Poly1305.Field32xN.felem5 4 -> r4: Hacl.Spec.Poly1305.Field32xN.felem5 4 -> FStar.Pervasives.Lemma (requires Hacl.Spec.Poly1305.Field32xN.felem_fits5 acc (3, 3, 3, 3, 3) /\ Hacl.Spec.Poly1305.Field32xN.felem_fits5 r (1, 1, 1, 1, 1) /\ Hacl.Spec.Poly1305.Field32xN.felem_fits5 r4 (2, 2, 2, 2, 2) /\ r_5 == Hacl.Spec.Poly1305.Field32xN.precomp_r5 r /\ Hacl.Spec.Poly1305.Field32xN.feval5 r4 == Hacl.Spec.Poly1305.Vec.compute_r4 (Hacl.Spec.Poly1305.Field32xN.feval5 r).[ 0 ]) (ensures (let out = Hacl.Spec.Poly1305.Field32xN.fmul_r4_normalize5 acc r r_5 r4 in Hacl.Spec.Poly1305.Field32xN.felem_fits5 out (2, 1, 1, 1, 1) /\ (Hacl.Spec.Poly1305.Field32xN.feval5 out).[ 0 ] == Hacl.Spec.Poly1305.Vec.normalize_4 (Hacl.Spec.Poly1305.Field32xN.feval5 r).[ 0 ] (Hacl.Spec.Poly1305.Field32xN.feval5 acc))) [SMTPat (Hacl.Spec.Poly1305.Field32xN.fmul_r4_normalize5 acc r r_5 r4)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Hacl.Spec.Poly1305.Field32xN.felem5", "Hacl.Poly1305.Field32xN.Lemmas1.carry_full_felem5_lemma", "Hacl.Spec.Poly1305.Field32xN.carry_full_felem5", "Hacl.Spec.Poly1305.Field32xN.Lemmas.fmul_r4_normalize51", "Hacl.Spec.Poly1305.Field32xN.Lemmas.fmul_r4_normalize50", "Hacl.Spec.Poly1305.Field32xN.fmul_r5", "Prims.unit" ]
[]
true
false
true
false
false
let fmul_r4_normalize5_lemma acc fr fr_5 fr4 =
let fr2 = fmul_r5 #4 fr fr fr_5 in let fr3 = fmul_r5 #4 fr2 fr fr_5 in let out = fmul_r4_normalize50 acc fr fr2 fr3 fr4 in let v2 = fmul_r4_normalize51 out in let res = carry_full_felem5 v2 in carry_full_felem5_lemma v2
false
Hacl.K256.PrecompTable.fst
Hacl.K256.PrecompTable.precomp_basepoint_table_lemma_w5
val precomp_basepoint_table_lemma_w5: unit -> Lemma (forall (i:nat{i < 32}). precomp_table_acc_inv g_aff 32 precomp_basepoint_table_lseq_w5 i)
val precomp_basepoint_table_lemma_w5: unit -> Lemma (forall (i:nat{i < 32}). precomp_table_acc_inv g_aff 32 precomp_basepoint_table_lseq_w5 i)
let precomp_basepoint_table_lemma_w5 () = normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 31); SPT.precomp_base_table_lemma mk_k256_precomp_base_table S.g 32 precomp_basepoint_table_lseq_w5
{ "file_name": "code/k256/Hacl.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 96, "end_line": 291, "start_col": 0, "start_line": 289 }
module Hacl.K256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.K256.PrecompTable module S = Spec.K256 module SL = Spec.K256.Lemmas open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in [@inline_let] let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in [@inline_let] let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops S.g 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops S.g 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64); let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in [@inline_let] let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in [@inline_let] let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in [@inline_let] let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in [@inline_let] let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_k256_concrete_ops S.g val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_k256_concrete_ops S.g val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_k256_concrete_ops S.g let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 240} = normalize_term (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 15) let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 240 = normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 15); Seq.seq_of_list precomp_basepoint_table_list_w4 let precomp_basepoint_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 15); SPT.precomp_base_table_lemma mk_k256_precomp_base_table S.g 16 precomp_basepoint_table_lseq_w4 let precomp_basepoint_table_w4: x:glbuffer uint64 240ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} = createL_global precomp_basepoint_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 64]G), [1]([pow2 64]G), ..., [15]([pow2 64]G)] inline_for_extraction noextract let precomp_g_pow2_64_table_list_w4: x:list uint64{FStar.List.Tot.length x = 240} = normalize_term (SPT.precomp_base_table_list mk_k256_precomp_base_table proj_g_pow2_64 15) let precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 240 = normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table proj_g_pow2_64 15); Seq.seq_of_list precomp_g_pow2_64_table_list_w4 let precomp_g_pow2_64_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table proj_g_pow2_64 15); SPT.precomp_base_table_lemma mk_k256_precomp_base_table proj_g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_64_lemma () let precomp_g_pow2_64_table_w4: x:glbuffer uint64 240ul{witnessed x precomp_g_pow2_64_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_64_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 128]G), [1]([pow2 128]G),...,[15]([pow2 128]G)] inline_for_extraction noextract let precomp_g_pow2_128_table_list_w4: x:list uint64{FStar.List.Tot.length x = 240} = normalize_term (SPT.precomp_base_table_list mk_k256_precomp_base_table proj_g_pow2_128 15) let precomp_g_pow2_128_table_lseq_w4 : LSeq.lseq uint64 240 = normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table proj_g_pow2_128 15); Seq.seq_of_list precomp_g_pow2_128_table_list_w4 let precomp_g_pow2_128_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table proj_g_pow2_128 15); SPT.precomp_base_table_lemma mk_k256_precomp_base_table proj_g_pow2_128 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_128_lemma () let precomp_g_pow2_128_table_w4: x:glbuffer uint64 240ul{witnessed x precomp_g_pow2_128_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_128_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 192]G), [1]([pow2 192]G),...,[15]([pow2 192]G)] inline_for_extraction noextract let precomp_g_pow2_192_table_list_w4: x:list uint64{FStar.List.Tot.length x = 240} = normalize_term (SPT.precomp_base_table_list mk_k256_precomp_base_table proj_g_pow2_192 15) let precomp_g_pow2_192_table_lseq_w4 : LSeq.lseq uint64 240 = normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table proj_g_pow2_192 15); Seq.seq_of_list precomp_g_pow2_192_table_list_w4 let precomp_g_pow2_192_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table proj_g_pow2_192 15); SPT.precomp_base_table_lemma mk_k256_precomp_base_table proj_g_pow2_192 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_192_lemma () let precomp_g_pow2_192_table_w4: x:glbuffer uint64 240ul{witnessed x precomp_g_pow2_192_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_192_table_list_w4 /// window size = 5; precomputed table = [[0]G, [1]G, ..., [31]G] inline_for_extraction noextract let precomp_basepoint_table_list_w5: x:list uint64{FStar.List.Tot.length x = 480} = normalize_term (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 31) let precomp_basepoint_table_lseq_w5 : LSeq.lseq uint64 480 = normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 31); Seq.seq_of_list precomp_basepoint_table_list_w5
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.PrecompTable.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.K256.PrecompTable.fst" }
[ { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "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.Pervasives.Lemma (ensures forall (i: Prims.nat{i < 32}). Hacl.K256.PrecompTable.precomp_table_acc_inv Hacl.K256.PrecompTable.g_aff 32 Hacl.K256.PrecompTable.precomp_basepoint_table_lseq_w5 i)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "Hacl.Spec.PrecompBaseTable.precomp_base_table_lemma", "Spec.K256.PointOps.proj_point", "Lib.IntTypes.U64", "FStar.UInt32.uint_to_t", "Hacl.K256.PrecompTable.mk_k256_precomp_base_table", "Spec.K256.PointOps.g", "Hacl.K256.PrecompTable.precomp_basepoint_table_lseq_w5", "FStar.Pervasives.normalize_term_spec", "Prims.list", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "FStar.Mul.op_Star", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Spec.PrecompBaseTable.precomp_base_table_list" ]
[]
true
false
true
false
false
let precomp_basepoint_table_lemma_w5 () =
normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 31); SPT.precomp_base_table_lemma mk_k256_precomp_base_table S.g 32 precomp_basepoint_table_lseq_w5
false
Enum.fst
Enum.bounded_by
val bounded_by : b: Enum.bound -> n: Prims.int -> Prims.logical
let bounded_by (b:bound) n = match b with | Some b -> b2t (n <= b) | None -> True
{ "file_name": "examples/typeclasses/Enum.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 16, "end_line": 26, "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 Enum open FStar.Tactics.Typeclasses open FStar.Tactics.V2 type bound = option nat
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Enum.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: Enum.bound -> n: Prims.int -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Enum.bound", "Prims.int", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.l_True", "Prims.logical" ]
[]
false
false
false
true
true
let bounded_by (b: bound) n =
match b with | Some b -> b2t (n <= b) | None -> True
false
Hacl.Impl.Frodo.Encode.fst
Hacl.Impl.Frodo.Encode.frodo_key_encode2
val frodo_key_encode2: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b <= v logq} -> n:size_t{v n == 8} -> a:lbytes (n *! n *! b /. size 8) -> i:size_t{v i < v n} -> x:uint64 -> res:matrix_t n n -> Stack unit (requires fun h -> live h a /\ live h res /\ disjoint a res) (ensures fun h0 _ h1 -> modifies1 res h0 h1 /\ as_matrix h1 res == Loops.repeati 8 (S.frodo_key_encode0 (v logq) (v b) (v n) (as_seq h0 a) x (v i)) (as_matrix h0 res))
val frodo_key_encode2: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b <= v logq} -> n:size_t{v n == 8} -> a:lbytes (n *! n *! b /. size 8) -> i:size_t{v i < v n} -> x:uint64 -> res:matrix_t n n -> Stack unit (requires fun h -> live h a /\ live h res /\ disjoint a res) (ensures fun h0 _ h1 -> modifies1 res h0 h1 /\ as_matrix h1 res == Loops.repeati 8 (S.frodo_key_encode0 (v logq) (v b) (v n) (as_seq h0 a) x (v i)) (as_matrix h0 res))
let frodo_key_encode2 logq b n a i x res = [@ inline_let] let spec h0 = S.frodo_key_encode0 (v logq) (v b) (v n) (as_seq h0 a) x (v i) in let h0 = ST.get () in loop1 h0 (size 8) res spec (fun k -> Loops.unfold_repeati 8 (spec h0) (as_seq h0 res) (v k); mset res i k (ec1 logq b x k) )
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Encode.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 108, "start_col": 0, "start_line": 100 }
module Hacl.Impl.Frodo.Encode open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Impl.Matrix module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module S = Spec.Frodo.Encode #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract private val ec: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= v logq} -> k:uint16{v k < pow2 (v b)} -> r:uint16{r == S.ec (v logq) (v b) k} let ec logq b a = a <<. (logq -. b) inline_for_extraction noextract private val dc: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b < v logq} -> c:uint16 -> r:uint16{r == S.dc (v logq) (v b) c} let dc logq b c = let res1 = (c +. (u16 1 <<. (logq -. b -. size 1))) >>. (logq -. b) in res1 &. ((u16 1 <<. b) -. u16 1) inline_for_extraction noextract private val ec1: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b <= v logq} -> x:uint64 -> k:size_t{v k < 8} -> res:uint16{res == S.ec1 (v logq) (v b) x (v k)} let ec1 logq b x k = Spec.Frodo.Lemmas.modulo_pow2_u64 (x >>. (b *! k)) (v b); let rk = (x >>. (b *! k)) &. ((u64 1 <<. b) -. u64 1) in ec logq b (to_u16 rk) inline_for_extraction noextract private val frodo_key_encode1: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b <= v logq} -> n:size_t{v n == 8} -> a:lbytes (n *! n *! b /. size 8) -> i:size_t{v i < v n} -> Stack uint64 (requires fun h -> live h a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.frodo_key_encode1 (v logq) (v b) (v n) (as_seq h0 a) (v i)) let frodo_key_encode1 logq b n a i = let h0 = ST.get() in push_frame(); let v8 = create (size 8) (u8 0) in let chunk = sub a (i *! b) b in let h1 = ST.get() in assert (as_seq h1 chunk == LSeq.sub (as_seq h0 a) (v (i *! b)) (v b)); update_sub v8 (size 0) b chunk; let x = uint_from_bytes_le #U64 v8 in pop_frame(); x inline_for_extraction noextract private val frodo_key_encode2: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b <= v logq} -> n:size_t{v n == 8} -> a:lbytes (n *! n *! b /. size 8) -> i:size_t{v i < v n} -> x:uint64 -> res:matrix_t n n -> Stack unit (requires fun h -> live h a /\ live h res /\ disjoint a res) (ensures fun h0 _ h1 -> modifies1 res h0 h1 /\ as_matrix h1 res == Loops.repeati 8 (S.frodo_key_encode0 (v logq) (v b) (v n) (as_seq h0 a) x (v i)) (as_matrix h0 res))
{ "checked_file": "/", "dependencies": [ "Spec.Matrix.fst.checked", "Spec.Frodo.Lemmas.fst.checked", "Spec.Frodo.Encode.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Matrix.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.Frodo.Encode.fst" }
[ { "abbrev": true, "full_module": "Spec.Frodo.Encode", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "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.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
logq: Lib.IntTypes.size_t{0 < Lib.IntTypes.v logq /\ Lib.IntTypes.v logq <= 16} -> b: Lib.IntTypes.size_t {0 < Lib.IntTypes.v b /\ Lib.IntTypes.v b <= 8 /\ Lib.IntTypes.v b <= Lib.IntTypes.v logq} -> n: Lib.IntTypes.size_t{Lib.IntTypes.v n == 8} -> a: Hacl.Impl.Matrix.lbytes (n *! n *! b /. Lib.IntTypes.size 8) -> i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v n} -> x: Lib.IntTypes.uint64 -> res: Hacl.Impl.Matrix.matrix_t n n -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "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.eq2", "Prims.int", "Hacl.Impl.Matrix.lbytes", "Lib.IntTypes.op_Slash_Dot", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.size", "Lib.IntTypes.uint64", "Hacl.Impl.Matrix.matrix_t", "Lib.Buffer.loop1", "Hacl.Impl.Matrix.elem", "Hacl.Impl.Matrix.mset", "Hacl.Impl.Frodo.Encode.ec1", "Prims.unit", "Lib.LoopCombinators.unfold_repeati", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U16", "Lib.IntTypes.SEC", "Prims.op_Multiply", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Prims.nat", "Prims.op_Subtraction", "Prims.pow2", "Spec.Frodo.Encode.frodo_key_encode0", "Lib.IntTypes.uint8" ]
[]
false
true
false
false
false
let frodo_key_encode2 logq b n a i x res =
[@@ inline_let ]let spec h0 = S.frodo_key_encode0 (v logq) (v b) (v n) (as_seq h0 a) x (v i) in let h0 = ST.get () in loop1 h0 (size 8) res spec (fun k -> Loops.unfold_repeati 8 (spec h0) (as_seq h0 res) (v k); mset res i k (ec1 logq b x k))
false
Hacl.Bignum.MontArithmetic.fsti
Hacl.Bignum.MontArithmetic.pbn_mont_ctx_u32
val pbn_mont_ctx_u32 : Type0
let pbn_mont_ctx_u32 = B.pointer bn_mont_ctx_u32
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 48, "end_line": 57, "start_col": 0, "start_line": 57 }
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module Euclid = FStar.Math.Euclid module S = Hacl.Spec.Bignum.MontArithmetic module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val _align_fsti : unit inline_for_extraction noextract let lb (t:limb_t) = match t with | U32 -> buffer uint32 | U64 -> buffer uint64 inline_for_extraction noextract let ll (t:limb_t) = match t with | U32 -> uint32 | U64 -> uint64 inline_for_extraction noeq type bn_mont_ctx' (t:limb_t) (a:Type0{a == lb t}) (b:Type0{b == ll t}) = { len: BN.meta_len t; n: x:a{length #MUT #(limb t) x == v len}; mu: b; r2: x:a{length #MUT #(limb t) x == v len}; } inline_for_extraction noextract let bn_mont_ctx (t:limb_t) = bn_mont_ctx' t (lb t) (ll t) let bn_mont_ctx_u32 = bn_mont_ctx' U32 (lb U32) (ll U32) let bn_mont_ctx_u64 = bn_mont_ctx' U64 (lb U64) (ll U64) inline_for_extraction noextract let pbn_mont_ctx (t:limb_t) = B.pointer (bn_mont_ctx t)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontArithmetic.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "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
Type0
Prims.Tot
[ "total" ]
[]
[ "LowStar.Buffer.pointer", "Hacl.Bignum.MontArithmetic.bn_mont_ctx_u32" ]
[]
false
false
false
true
true
let pbn_mont_ctx_u32 =
B.pointer bn_mont_ctx_u32
false
Hacl.Bignum.MontArithmetic.fsti
Hacl.Bignum.MontArithmetic.bn_mont_ctx
val bn_mont_ctx : t: Hacl.Bignum.Definitions.limb_t -> Type0
let bn_mont_ctx (t:limb_t) = bn_mont_ctx' t (lb t) (ll t)
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 57, "end_line": 48, "start_col": 0, "start_line": 48 }
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module Euclid = FStar.Math.Euclid module S = Hacl.Spec.Bignum.MontArithmetic module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val _align_fsti : unit inline_for_extraction noextract let lb (t:limb_t) = match t with | U32 -> buffer uint32 | U64 -> buffer uint64 inline_for_extraction noextract let ll (t:limb_t) = match t with | U32 -> uint32 | U64 -> uint64 inline_for_extraction noeq type bn_mont_ctx' (t:limb_t) (a:Type0{a == lb t}) (b:Type0{b == ll t}) = { len: BN.meta_len t; n: x:a{length #MUT #(limb t) x == v len}; mu: b; r2: x:a{length #MUT #(limb t) x == v len}; }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontArithmetic.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Hacl.Bignum.Definitions.limb_t -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.MontArithmetic.bn_mont_ctx'", "Hacl.Bignum.MontArithmetic.lb", "Hacl.Bignum.MontArithmetic.ll" ]
[]
false
false
false
true
true
let bn_mont_ctx (t: limb_t) =
bn_mont_ctx' t (lb t) (ll t)
false
Hacl.Bignum.MontArithmetic.fsti
Hacl.Bignum.MontArithmetic.bn_mont_ctx_u64
val bn_mont_ctx_u64 : Type0
let bn_mont_ctx_u64 = bn_mont_ctx' U64 (lb U64) (ll U64)
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 56, "end_line": 51, "start_col": 0, "start_line": 51 }
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module Euclid = FStar.Math.Euclid module S = Hacl.Spec.Bignum.MontArithmetic module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val _align_fsti : unit inline_for_extraction noextract let lb (t:limb_t) = match t with | U32 -> buffer uint32 | U64 -> buffer uint64 inline_for_extraction noextract let ll (t:limb_t) = match t with | U32 -> uint32 | U64 -> uint64 inline_for_extraction noeq type bn_mont_ctx' (t:limb_t) (a:Type0{a == lb t}) (b:Type0{b == ll t}) = { len: BN.meta_len t; n: x:a{length #MUT #(limb t) x == v len}; mu: b; r2: x:a{length #MUT #(limb t) x == v len}; } inline_for_extraction noextract let bn_mont_ctx (t:limb_t) = bn_mont_ctx' t (lb t) (ll t)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontArithmetic.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "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
Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.MontArithmetic.bn_mont_ctx'", "Lib.IntTypes.U64", "Hacl.Bignum.MontArithmetic.lb", "Hacl.Bignum.MontArithmetic.ll" ]
[]
false
false
false
true
true
let bn_mont_ctx_u64 =
bn_mont_ctx' U64 (lb U64) (ll U64)
false
Hacl.Bignum.MontArithmetic.fsti
Hacl.Bignum.MontArithmetic.bn_mont_ctx_u32
val bn_mont_ctx_u32 : Type0
let bn_mont_ctx_u32 = bn_mont_ctx' U32 (lb U32) (ll U32)
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 56, "end_line": 50, "start_col": 0, "start_line": 50 }
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module Euclid = FStar.Math.Euclid module S = Hacl.Spec.Bignum.MontArithmetic module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val _align_fsti : unit inline_for_extraction noextract let lb (t:limb_t) = match t with | U32 -> buffer uint32 | U64 -> buffer uint64 inline_for_extraction noextract let ll (t:limb_t) = match t with | U32 -> uint32 | U64 -> uint64 inline_for_extraction noeq type bn_mont_ctx' (t:limb_t) (a:Type0{a == lb t}) (b:Type0{b == ll t}) = { len: BN.meta_len t; n: x:a{length #MUT #(limb t) x == v len}; mu: b; r2: x:a{length #MUT #(limb t) x == v len}; } inline_for_extraction noextract let bn_mont_ctx (t:limb_t) = bn_mont_ctx' t (lb t) (ll t)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontArithmetic.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "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
Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.MontArithmetic.bn_mont_ctx'", "Lib.IntTypes.U32", "Hacl.Bignum.MontArithmetic.lb", "Hacl.Bignum.MontArithmetic.ll" ]
[]
false
false
false
true
true
let bn_mont_ctx_u32 =
bn_mont_ctx' U32 (lb U32) (ll U32)
false
Hacl.Bignum.MontArithmetic.fsti
Hacl.Bignum.MontArithmetic.pbn_mont_ctx_u64
val pbn_mont_ctx_u64 : Type0
let pbn_mont_ctx_u64 = B.pointer bn_mont_ctx_u64
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 48, "end_line": 59, "start_col": 0, "start_line": 59 }
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module Euclid = FStar.Math.Euclid module S = Hacl.Spec.Bignum.MontArithmetic module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val _align_fsti : unit inline_for_extraction noextract let lb (t:limb_t) = match t with | U32 -> buffer uint32 | U64 -> buffer uint64 inline_for_extraction noextract let ll (t:limb_t) = match t with | U32 -> uint32 | U64 -> uint64 inline_for_extraction noeq type bn_mont_ctx' (t:limb_t) (a:Type0{a == lb t}) (b:Type0{b == ll t}) = { len: BN.meta_len t; n: x:a{length #MUT #(limb t) x == v len}; mu: b; r2: x:a{length #MUT #(limb t) x == v len}; } inline_for_extraction noextract let bn_mont_ctx (t:limb_t) = bn_mont_ctx' t (lb t) (ll t) let bn_mont_ctx_u32 = bn_mont_ctx' U32 (lb U32) (ll U32) let bn_mont_ctx_u64 = bn_mont_ctx' U64 (lb U64) (ll U64) inline_for_extraction noextract let pbn_mont_ctx (t:limb_t) = B.pointer (bn_mont_ctx t) inline_for_extraction noextract let pbn_mont_ctx_u32 = B.pointer bn_mont_ctx_u32
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontArithmetic.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "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
Type0
Prims.Tot
[ "total" ]
[]
[ "LowStar.Buffer.pointer", "Hacl.Bignum.MontArithmetic.bn_mont_ctx_u64" ]
[]
false
false
false
true
true
let pbn_mont_ctx_u64 =
B.pointer bn_mont_ctx_u64
false
Enum.fst
Enum.enum_opt
[@@ FStar.Tactics.Typeclasses.tcinstance] val enum_opt (i: enum 'a) : enum (option 'a)
[@@ FStar.Tactics.Typeclasses.tcinstance] val enum_opt (i: enum 'a) : enum (option 'a)
instance enum_opt (i:enum 'a): enum (option 'a) = { max = succ i.max; toInt = (function | None -> 0 | Some x -> 1 + i.toInt x); fromInt = (function | 0 -> None | x -> Some (i.fromInt (x-1))); inv1 = (function | None -> () | Some x -> i.inv1 x); inv2 = (function | 0 -> () | x -> i.inv2 (x-1)); }
{ "file_name": "examples/typeclasses/Enum.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 3, "end_line": 54, "start_col": 0, "start_line": 48 }
(* 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 Enum open FStar.Tactics.Typeclasses open FStar.Tactics.V2 type bound = option nat let bounded_by (b:bound) n = match b with | Some b -> b2t (n <= b) | None -> True let succ : bound -> bound = function | None -> None | Some b -> Some (b+1) let bounded (b:bound) = n:nat{bounded_by b n} class enum a = { max : bound; toInt : a -> bounded max; fromInt : bounded max -> a; inv1 : x:a -> Lemma (fromInt (toInt x) == x); inv2 : i:(bounded max) -> Lemma (toInt (fromInt i) == i); } instance enum_nat : enum nat = { max = None; toInt = id; fromInt = id; inv1 = easy; inv2 = easy; }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Enum.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
i: Enum.enum 'a -> Enum.enum (FStar.Pervasives.Native.option 'a)
Prims.Tot
[ "total" ]
[]
[ "Enum.enum", "Enum.Mkenum", "FStar.Pervasives.Native.option", "Enum.succ", "Enum.__proj__Mkenum__item__max", "Prims.op_Addition", "Enum.__proj__Mkenum__item__toInt", "Enum.bounded", "FStar.Pervasives.Native.None", "Prims.int", "FStar.Pervasives.Native.Some", "Enum.__proj__Mkenum__item__fromInt", "Prims.op_Subtraction", "Enum.__proj__Mkenum__item__inv1", "Prims.unit", "Enum.__proj__Mkenum__item__inv2" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let enum_opt (i: enum 'a) : enum (option 'a) =
{ max = succ i.max; toInt = (function | None -> 0 | Some x -> 1 + i.toInt x); fromInt = (function | 0 -> None | x -> Some (i.fromInt (x - 1))); inv1 = (function | None -> () | Some x -> i.inv1 x); inv2 = (function | 0 -> () | x -> i.inv2 (x - 1)) }
false
Enum.fst
Enum.succ
val succ: bound -> bound
val succ: bound -> bound
let succ : bound -> bound = function | None -> None | Some b -> Some (b+1)
{ "file_name": "examples/typeclasses/Enum.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 74, "end_line": 28, "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 Enum open FStar.Tactics.Typeclasses open FStar.Tactics.V2 type bound = option nat let bounded_by (b:bound) n = match b with | Some b -> b2t (n <= b) | None -> True
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Enum.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Enum.bound -> Enum.bound
Prims.Tot
[ "total" ]
[]
[ "Enum.bound", "FStar.Pervasives.Native.None", "Prims.nat", "FStar.Pervasives.Native.Some", "Prims.op_Addition" ]
[]
false
false
false
true
false
let succ: bound -> bound =
function | None -> None | Some b -> Some (b + 1)
false
Hacl.Bignum.MontArithmetic.fsti
Hacl.Bignum.MontArithmetic.pbn_mont_ctx
val pbn_mont_ctx : t: Hacl.Bignum.Definitions.limb_t -> Type0
let pbn_mont_ctx (t:limb_t) = B.pointer (bn_mont_ctx t)
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 55, "end_line": 54, "start_col": 0, "start_line": 54 }
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module Euclid = FStar.Math.Euclid module S = Hacl.Spec.Bignum.MontArithmetic module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val _align_fsti : unit inline_for_extraction noextract let lb (t:limb_t) = match t with | U32 -> buffer uint32 | U64 -> buffer uint64 inline_for_extraction noextract let ll (t:limb_t) = match t with | U32 -> uint32 | U64 -> uint64 inline_for_extraction noeq type bn_mont_ctx' (t:limb_t) (a:Type0{a == lb t}) (b:Type0{b == ll t}) = { len: BN.meta_len t; n: x:a{length #MUT #(limb t) x == v len}; mu: b; r2: x:a{length #MUT #(limb t) x == v len}; } inline_for_extraction noextract let bn_mont_ctx (t:limb_t) = bn_mont_ctx' t (lb t) (ll t) let bn_mont_ctx_u32 = bn_mont_ctx' U32 (lb U32) (ll U32) let bn_mont_ctx_u64 = bn_mont_ctx' U64 (lb U64) (ll U64)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontArithmetic.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Hacl.Bignum.Definitions.limb_t -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "LowStar.Buffer.pointer", "Hacl.Bignum.MontArithmetic.bn_mont_ctx" ]
[]
false
false
false
true
true
let pbn_mont_ctx (t: limb_t) =
B.pointer (bn_mont_ctx t)
false
Enum.fst
Enum.enum_nat
[@@ FStar.Tactics.Typeclasses.tcinstance] val enum_nat:enum nat
[@@ FStar.Tactics.Typeclasses.tcinstance] val enum_nat:enum nat
instance enum_nat : enum nat = { max = None; toInt = id; fromInt = id; inv1 = easy; inv2 = easy; }
{ "file_name": "examples/typeclasses/Enum.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 3, "end_line": 46, "start_col": 0, "start_line": 40 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Enum open FStar.Tactics.Typeclasses open FStar.Tactics.V2 type bound = option nat let bounded_by (b:bound) n = match b with | Some b -> b2t (n <= b) | None -> True let succ : bound -> bound = function | None -> None | Some b -> Some (b+1) let bounded (b:bound) = n:nat{bounded_by b n} class enum a = { max : bound; toInt : a -> bounded max; fromInt : bounded max -> a; inv1 : x:a -> Lemma (fromInt (toInt x) == x); inv2 : i:(bounded max) -> Lemma (toInt (fromInt i) == i); }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Enum.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.V2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Enum.enum Prims.nat
Prims.Tot
[ "total" ]
[]
[ "Enum.Mkenum", "Prims.nat", "FStar.Pervasives.Native.None", "FStar.Pervasives.id", "Enum.bounded", "FStar.Tactics.V2.Logic.easy", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Tactics.V2.Logic.lemma_from_squash" ]
[]
false
false
false
true
false
[@@ FStar.Tactics.Typeclasses.tcinstance] let enum_nat:enum nat =
{ max = None; toInt = id; fromInt = id; inv1 = easy; inv2 = easy }
false
Hacl.Bignum.MontArithmetic.fsti
Hacl.Bignum.MontArithmetic.as_pctx
val as_pctx (#t: limb_t) (h: mem) (k: pbn_mont_ctx t) : GTot (S.bn_mont_ctx t)
val as_pctx (#t: limb_t) (h: mem) (k: pbn_mont_ctx t) : GTot (S.bn_mont_ctx t)
let as_pctx (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) : GTot (S.bn_mont_ctx t) = as_ctx h (B.deref h k)
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 24, "end_line": 105, "start_col": 0, "start_line": 104 }
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module Euclid = FStar.Math.Euclid module S = Hacl.Spec.Bignum.MontArithmetic module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val _align_fsti : unit inline_for_extraction noextract let lb (t:limb_t) = match t with | U32 -> buffer uint32 | U64 -> buffer uint64 inline_for_extraction noextract let ll (t:limb_t) = match t with | U32 -> uint32 | U64 -> uint64 inline_for_extraction noeq type bn_mont_ctx' (t:limb_t) (a:Type0{a == lb t}) (b:Type0{b == ll t}) = { len: BN.meta_len t; n: x:a{length #MUT #(limb t) x == v len}; mu: b; r2: x:a{length #MUT #(limb t) x == v len}; } inline_for_extraction noextract let bn_mont_ctx (t:limb_t) = bn_mont_ctx' t (lb t) (ll t) let bn_mont_ctx_u32 = bn_mont_ctx' U32 (lb U32) (ll U32) let bn_mont_ctx_u64 = bn_mont_ctx' U64 (lb U64) (ll U64) inline_for_extraction noextract let pbn_mont_ctx (t:limb_t) = B.pointer (bn_mont_ctx t) inline_for_extraction noextract let pbn_mont_ctx_u32 = B.pointer bn_mont_ctx_u32 inline_for_extraction noextract let pbn_mont_ctx_u64 = B.pointer bn_mont_ctx_u64 inline_for_extraction noextract let as_ctx (#t:limb_t) (h:mem) (k:bn_mont_ctx t) : GTot (S.bn_mont_ctx t) = { S.len = v k.len; S.n = as_seq h (k.n <: lbignum t k.len); S.mu = k.mu; S.r2 = as_seq h (k.r2 <: lbignum t k.len); } inline_for_extraction noextract let bn_mont_ctx_inv (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in live h n /\ live h r2 /\ disjoint n r2 /\ S.bn_mont_ctx_inv (as_ctx h k) inline_for_extraction noextract let bn_v_n (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = let k1 = B.deref h k in let n : lbignum t k1.len = k1.n in bn_v h n inline_for_extraction noextract let freeable_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.freeable n /\ B.freeable r2 inline_for_extraction noextract let freeable (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.freeable k /\ freeable_s h (B.deref h k) inline_for_extraction noextract let footprint_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.(loc_union (loc_addr_of_buffer n) (loc_addr_of_buffer r2)) inline_for_extraction noextract let footprint (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.(loc_union (loc_addr_of_buffer k) (footprint_s h (B.deref h k)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontArithmetic.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "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
h: FStar.Monotonic.HyperStack.mem -> k: Hacl.Bignum.MontArithmetic.pbn_mont_ctx t -> Prims.GTot (Hacl.Spec.Bignum.MontArithmetic.bn_mont_ctx t)
Prims.GTot
[ "sometrivial" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "FStar.Monotonic.HyperStack.mem", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.Bignum.MontArithmetic.as_ctx", "LowStar.Monotonic.Buffer.deref", "Hacl.Bignum.MontArithmetic.bn_mont_ctx", "LowStar.Buffer.trivial_preorder", "Hacl.Spec.Bignum.MontArithmetic.bn_mont_ctx" ]
[]
false
false
false
false
false
let as_pctx (#t: limb_t) (h: mem) (k: pbn_mont_ctx t) : GTot (S.bn_mont_ctx t) =
as_ctx h (B.deref h k)
false
Hacl.Impl.Frodo.Encode.fst
Hacl.Impl.Frodo.Encode.frodo_key_encode
val frodo_key_encode: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b <= v logq} -> n:size_t{v n == 8} -> a:lbytes (n *! n *! b /. size 8) -> res:matrix_t n n -> Stack unit (requires fun h -> live h a /\ live h res /\ disjoint a res /\ as_seq h res == Spec.Matrix.create (v n) (v n)) (ensures fun h0 _ h1 -> modifies1 res h0 h1 /\ as_matrix h1 res == S.frodo_key_encode (v logq) (v b) (v n) (as_seq h0 a))
val frodo_key_encode: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b <= v logq} -> n:size_t{v n == 8} -> a:lbytes (n *! n *! b /. size 8) -> res:matrix_t n n -> Stack unit (requires fun h -> live h a /\ live h res /\ disjoint a res /\ as_seq h res == Spec.Matrix.create (v n) (v n)) (ensures fun h0 _ h1 -> modifies1 res h0 h1 /\ as_matrix h1 res == S.frodo_key_encode (v logq) (v b) (v n) (as_seq h0 a))
let frodo_key_encode logq b n a res = let h0 = ST.get () in [@ inline_let] let spec h0 = S.frodo_key_encode2 (v logq) (v b) (v n) (as_seq h0 a) in loop1 h0 n res spec (fun i -> Loops.unfold_repeati (v n) (spec h0) (as_seq h0 res) (v i); let x = frodo_key_encode1 logq b n a i in frodo_key_encode2 logq b n a i x res )
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Encode.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 134, "start_col": 0, "start_line": 125 }
module Hacl.Impl.Frodo.Encode open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Impl.Matrix module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module S = Spec.Frodo.Encode #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract private val ec: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= v logq} -> k:uint16{v k < pow2 (v b)} -> r:uint16{r == S.ec (v logq) (v b) k} let ec logq b a = a <<. (logq -. b) inline_for_extraction noextract private val dc: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b < v logq} -> c:uint16 -> r:uint16{r == S.dc (v logq) (v b) c} let dc logq b c = let res1 = (c +. (u16 1 <<. (logq -. b -. size 1))) >>. (logq -. b) in res1 &. ((u16 1 <<. b) -. u16 1) inline_for_extraction noextract private val ec1: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b <= v logq} -> x:uint64 -> k:size_t{v k < 8} -> res:uint16{res == S.ec1 (v logq) (v b) x (v k)} let ec1 logq b x k = Spec.Frodo.Lemmas.modulo_pow2_u64 (x >>. (b *! k)) (v b); let rk = (x >>. (b *! k)) &. ((u64 1 <<. b) -. u64 1) in ec logq b (to_u16 rk) inline_for_extraction noextract private val frodo_key_encode1: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b <= v logq} -> n:size_t{v n == 8} -> a:lbytes (n *! n *! b /. size 8) -> i:size_t{v i < v n} -> Stack uint64 (requires fun h -> live h a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.frodo_key_encode1 (v logq) (v b) (v n) (as_seq h0 a) (v i)) let frodo_key_encode1 logq b n a i = let h0 = ST.get() in push_frame(); let v8 = create (size 8) (u8 0) in let chunk = sub a (i *! b) b in let h1 = ST.get() in assert (as_seq h1 chunk == LSeq.sub (as_seq h0 a) (v (i *! b)) (v b)); update_sub v8 (size 0) b chunk; let x = uint_from_bytes_le #U64 v8 in pop_frame(); x inline_for_extraction noextract private val frodo_key_encode2: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b <= v logq} -> n:size_t{v n == 8} -> a:lbytes (n *! n *! b /. size 8) -> i:size_t{v i < v n} -> x:uint64 -> res:matrix_t n n -> Stack unit (requires fun h -> live h a /\ live h res /\ disjoint a res) (ensures fun h0 _ h1 -> modifies1 res h0 h1 /\ as_matrix h1 res == Loops.repeati 8 (S.frodo_key_encode0 (v logq) (v b) (v n) (as_seq h0 a) x (v i)) (as_matrix h0 res)) let frodo_key_encode2 logq b n a i x res = [@ inline_let] let spec h0 = S.frodo_key_encode0 (v logq) (v b) (v n) (as_seq h0 a) x (v i) in let h0 = ST.get () in loop1 h0 (size 8) res spec (fun k -> Loops.unfold_repeati 8 (spec h0) (as_seq h0 res) (v k); mset res i k (ec1 logq b x k) ) val frodo_key_encode: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b <= v logq} -> n:size_t{v n == 8} -> a:lbytes (n *! n *! b /. size 8) -> res:matrix_t n n -> Stack unit (requires fun h -> live h a /\ live h res /\ disjoint a res /\ as_seq h res == Spec.Matrix.create (v n) (v n)) (ensures fun h0 _ h1 -> modifies1 res h0 h1 /\ as_matrix h1 res == S.frodo_key_encode (v logq) (v b) (v n) (as_seq h0 a))
{ "checked_file": "/", "dependencies": [ "Spec.Matrix.fst.checked", "Spec.Frodo.Lemmas.fst.checked", "Spec.Frodo.Encode.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Matrix.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.Frodo.Encode.fst" }
[ { "abbrev": true, "full_module": "Spec.Frodo.Encode", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "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.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
logq: Lib.IntTypes.size_t{0 < Lib.IntTypes.v logq /\ Lib.IntTypes.v logq <= 16} -> b: Lib.IntTypes.size_t {0 < Lib.IntTypes.v b /\ Lib.IntTypes.v b <= 8 /\ Lib.IntTypes.v b <= Lib.IntTypes.v logq} -> n: Lib.IntTypes.size_t{Lib.IntTypes.v n == 8} -> a: Hacl.Impl.Matrix.lbytes (n *! n *! b /. Lib.IntTypes.size 8) -> res: Hacl.Impl.Matrix.matrix_t n n -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "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.eq2", "Prims.int", "Hacl.Impl.Matrix.lbytes", "Lib.IntTypes.op_Slash_Dot", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.size", "Hacl.Impl.Matrix.matrix_t", "Lib.Buffer.loop1", "Hacl.Impl.Matrix.elem", "Hacl.Impl.Frodo.Encode.frodo_key_encode2", "Prims.unit", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Hacl.Impl.Frodo.Encode.frodo_key_encode1", "Lib.IntTypes.uint64", "Lib.LoopCombinators.unfold_repeati", "Lib.Sequence.lseq", "Lib.IntTypes.U16", "Prims.op_Multiply", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "FStar.Monotonic.HyperStack.mem", "Prims.nat", "Prims.op_Subtraction", "Prims.pow2", "Spec.Frodo.Encode.frodo_key_encode2", "Lib.IntTypes.uint8", "FStar.HyperStack.ST.get" ]
[]
false
true
false
false
false
let frodo_key_encode logq b n a res =
let h0 = ST.get () in [@@ inline_let ]let spec h0 = S.frodo_key_encode2 (v logq) (v b) (v n) (as_seq h0 a) in loop1 h0 n res spec (fun i -> Loops.unfold_repeati (v n) (spec h0) (as_seq h0 res) (v i); let x = frodo_key_encode1 logq b n a i in frodo_key_encode2 logq b n a i x res)
false
Hacl.Bignum.MontArithmetic.fsti
Hacl.Bignum.MontArithmetic.freeable
val freeable : h: FStar.Monotonic.HyperStack.mem -> k: Hacl.Bignum.MontArithmetic.pbn_mont_ctx t -> Prims.logical
let freeable (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.freeable k /\ freeable_s h (B.deref h k)
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 44, "end_line": 91, "start_col": 0, "start_line": 90 }
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module Euclid = FStar.Math.Euclid module S = Hacl.Spec.Bignum.MontArithmetic module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val _align_fsti : unit inline_for_extraction noextract let lb (t:limb_t) = match t with | U32 -> buffer uint32 | U64 -> buffer uint64 inline_for_extraction noextract let ll (t:limb_t) = match t with | U32 -> uint32 | U64 -> uint64 inline_for_extraction noeq type bn_mont_ctx' (t:limb_t) (a:Type0{a == lb t}) (b:Type0{b == ll t}) = { len: BN.meta_len t; n: x:a{length #MUT #(limb t) x == v len}; mu: b; r2: x:a{length #MUT #(limb t) x == v len}; } inline_for_extraction noextract let bn_mont_ctx (t:limb_t) = bn_mont_ctx' t (lb t) (ll t) let bn_mont_ctx_u32 = bn_mont_ctx' U32 (lb U32) (ll U32) let bn_mont_ctx_u64 = bn_mont_ctx' U64 (lb U64) (ll U64) inline_for_extraction noextract let pbn_mont_ctx (t:limb_t) = B.pointer (bn_mont_ctx t) inline_for_extraction noextract let pbn_mont_ctx_u32 = B.pointer bn_mont_ctx_u32 inline_for_extraction noextract let pbn_mont_ctx_u64 = B.pointer bn_mont_ctx_u64 inline_for_extraction noextract let as_ctx (#t:limb_t) (h:mem) (k:bn_mont_ctx t) : GTot (S.bn_mont_ctx t) = { S.len = v k.len; S.n = as_seq h (k.n <: lbignum t k.len); S.mu = k.mu; S.r2 = as_seq h (k.r2 <: lbignum t k.len); } inline_for_extraction noextract let bn_mont_ctx_inv (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in live h n /\ live h r2 /\ disjoint n r2 /\ S.bn_mont_ctx_inv (as_ctx h k) inline_for_extraction noextract let bn_v_n (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = let k1 = B.deref h k in let n : lbignum t k1.len = k1.n in bn_v h n inline_for_extraction noextract let freeable_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.freeable n /\ B.freeable r2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontArithmetic.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "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
h: FStar.Monotonic.HyperStack.mem -> k: Hacl.Bignum.MontArithmetic.pbn_mont_ctx t -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "FStar.Monotonic.HyperStack.mem", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Prims.l_and", "LowStar.Monotonic.Buffer.freeable", "Hacl.Bignum.MontArithmetic.bn_mont_ctx", "LowStar.Buffer.trivial_preorder", "Hacl.Bignum.MontArithmetic.freeable_s", "LowStar.Monotonic.Buffer.deref", "Prims.logical" ]
[]
false
false
false
false
true
let freeable (#t: limb_t) (h: mem) (k: pbn_mont_ctx t) =
B.freeable k /\ freeable_s h (B.deref h k)
false
Hacl.Bignum.MontArithmetic.fsti
Hacl.Bignum.MontArithmetic.pbn_mont_ctx_inv
val pbn_mont_ctx_inv : h: FStar.Monotonic.HyperStack.mem -> k: Hacl.Bignum.MontArithmetic.pbn_mont_ctx t -> Prims.logical
let pbn_mont_ctx_inv (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.live h k /\ B.(loc_disjoint (loc_addr_of_buffer k) (footprint_s h (B.deref h k))) /\ bn_mont_ctx_inv h (B.deref h k)
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 33, "end_line": 111, "start_col": 0, "start_line": 108 }
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module Euclid = FStar.Math.Euclid module S = Hacl.Spec.Bignum.MontArithmetic module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val _align_fsti : unit inline_for_extraction noextract let lb (t:limb_t) = match t with | U32 -> buffer uint32 | U64 -> buffer uint64 inline_for_extraction noextract let ll (t:limb_t) = match t with | U32 -> uint32 | U64 -> uint64 inline_for_extraction noeq type bn_mont_ctx' (t:limb_t) (a:Type0{a == lb t}) (b:Type0{b == ll t}) = { len: BN.meta_len t; n: x:a{length #MUT #(limb t) x == v len}; mu: b; r2: x:a{length #MUT #(limb t) x == v len}; } inline_for_extraction noextract let bn_mont_ctx (t:limb_t) = bn_mont_ctx' t (lb t) (ll t) let bn_mont_ctx_u32 = bn_mont_ctx' U32 (lb U32) (ll U32) let bn_mont_ctx_u64 = bn_mont_ctx' U64 (lb U64) (ll U64) inline_for_extraction noextract let pbn_mont_ctx (t:limb_t) = B.pointer (bn_mont_ctx t) inline_for_extraction noextract let pbn_mont_ctx_u32 = B.pointer bn_mont_ctx_u32 inline_for_extraction noextract let pbn_mont_ctx_u64 = B.pointer bn_mont_ctx_u64 inline_for_extraction noextract let as_ctx (#t:limb_t) (h:mem) (k:bn_mont_ctx t) : GTot (S.bn_mont_ctx t) = { S.len = v k.len; S.n = as_seq h (k.n <: lbignum t k.len); S.mu = k.mu; S.r2 = as_seq h (k.r2 <: lbignum t k.len); } inline_for_extraction noextract let bn_mont_ctx_inv (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in live h n /\ live h r2 /\ disjoint n r2 /\ S.bn_mont_ctx_inv (as_ctx h k) inline_for_extraction noextract let bn_v_n (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = let k1 = B.deref h k in let n : lbignum t k1.len = k1.n in bn_v h n inline_for_extraction noextract let freeable_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.freeable n /\ B.freeable r2 inline_for_extraction noextract let freeable (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.freeable k /\ freeable_s h (B.deref h k) inline_for_extraction noextract let footprint_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.(loc_union (loc_addr_of_buffer n) (loc_addr_of_buffer r2)) inline_for_extraction noextract let footprint (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.(loc_union (loc_addr_of_buffer k) (footprint_s h (B.deref h k))) inline_for_extraction noextract let as_pctx (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) : GTot (S.bn_mont_ctx t) = as_ctx h (B.deref h k)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontArithmetic.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "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
h: FStar.Monotonic.HyperStack.mem -> k: Hacl.Bignum.MontArithmetic.pbn_mont_ctx t -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "FStar.Monotonic.HyperStack.mem", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Prims.l_and", "LowStar.Monotonic.Buffer.live", "Hacl.Bignum.MontArithmetic.bn_mont_ctx", "LowStar.Buffer.trivial_preorder", "LowStar.Monotonic.Buffer.loc_disjoint", "LowStar.Monotonic.Buffer.loc_addr_of_buffer", "Hacl.Bignum.MontArithmetic.footprint_s", "LowStar.Monotonic.Buffer.deref", "Hacl.Bignum.MontArithmetic.bn_mont_ctx_inv", "Prims.logical" ]
[]
false
false
false
false
true
let pbn_mont_ctx_inv (#t: limb_t) (h: mem) (k: pbn_mont_ctx t) =
B.live h k /\ B.(loc_disjoint (loc_addr_of_buffer k) (footprint_s h (B.deref h k))) /\ bn_mont_ctx_inv h (B.deref h k)
false
Hacl.Bignum.MontArithmetic.fsti
Hacl.Bignum.MontArithmetic.footprint
val footprint : h: FStar.Monotonic.HyperStack.mem -> k: Hacl.Bignum.MontArithmetic.pbn_mont_ctx t -> Prims.GTot LowStar.Monotonic.Buffer.loc
let footprint (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.(loc_union (loc_addr_of_buffer k) (footprint_s h (B.deref h k)))
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 68, "end_line": 101, "start_col": 0, "start_line": 100 }
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module Euclid = FStar.Math.Euclid module S = Hacl.Spec.Bignum.MontArithmetic module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val _align_fsti : unit inline_for_extraction noextract let lb (t:limb_t) = match t with | U32 -> buffer uint32 | U64 -> buffer uint64 inline_for_extraction noextract let ll (t:limb_t) = match t with | U32 -> uint32 | U64 -> uint64 inline_for_extraction noeq type bn_mont_ctx' (t:limb_t) (a:Type0{a == lb t}) (b:Type0{b == ll t}) = { len: BN.meta_len t; n: x:a{length #MUT #(limb t) x == v len}; mu: b; r2: x:a{length #MUT #(limb t) x == v len}; } inline_for_extraction noextract let bn_mont_ctx (t:limb_t) = bn_mont_ctx' t (lb t) (ll t) let bn_mont_ctx_u32 = bn_mont_ctx' U32 (lb U32) (ll U32) let bn_mont_ctx_u64 = bn_mont_ctx' U64 (lb U64) (ll U64) inline_for_extraction noextract let pbn_mont_ctx (t:limb_t) = B.pointer (bn_mont_ctx t) inline_for_extraction noextract let pbn_mont_ctx_u32 = B.pointer bn_mont_ctx_u32 inline_for_extraction noextract let pbn_mont_ctx_u64 = B.pointer bn_mont_ctx_u64 inline_for_extraction noextract let as_ctx (#t:limb_t) (h:mem) (k:bn_mont_ctx t) : GTot (S.bn_mont_ctx t) = { S.len = v k.len; S.n = as_seq h (k.n <: lbignum t k.len); S.mu = k.mu; S.r2 = as_seq h (k.r2 <: lbignum t k.len); } inline_for_extraction noextract let bn_mont_ctx_inv (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in live h n /\ live h r2 /\ disjoint n r2 /\ S.bn_mont_ctx_inv (as_ctx h k) inline_for_extraction noextract let bn_v_n (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = let k1 = B.deref h k in let n : lbignum t k1.len = k1.n in bn_v h n inline_for_extraction noextract let freeable_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.freeable n /\ B.freeable r2 inline_for_extraction noextract let freeable (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.freeable k /\ freeable_s h (B.deref h k) inline_for_extraction noextract let footprint_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.(loc_union (loc_addr_of_buffer n) (loc_addr_of_buffer r2))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontArithmetic.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "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
h: FStar.Monotonic.HyperStack.mem -> k: Hacl.Bignum.MontArithmetic.pbn_mont_ctx t -> Prims.GTot LowStar.Monotonic.Buffer.loc
Prims.GTot
[ "sometrivial" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "FStar.Monotonic.HyperStack.mem", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "LowStar.Monotonic.Buffer.loc_union", "LowStar.Monotonic.Buffer.loc_addr_of_buffer", "Hacl.Bignum.MontArithmetic.bn_mont_ctx", "LowStar.Buffer.trivial_preorder", "Hacl.Bignum.MontArithmetic.footprint_s", "LowStar.Monotonic.Buffer.deref", "LowStar.Monotonic.Buffer.loc" ]
[]
false
false
false
false
false
let footprint (#t: limb_t) (h: mem) (k: pbn_mont_ctx t) =
let open B in loc_union (loc_addr_of_buffer k) (footprint_s h (B.deref h k))
false
Hacl.Impl.Frodo.Encode.fst
Hacl.Impl.Frodo.Encode.frodo_key_encode1
val frodo_key_encode1: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b <= v logq} -> n:size_t{v n == 8} -> a:lbytes (n *! n *! b /. size 8) -> i:size_t{v i < v n} -> Stack uint64 (requires fun h -> live h a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.frodo_key_encode1 (v logq) (v b) (v n) (as_seq h0 a) (v i))
val frodo_key_encode1: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b <= v logq} -> n:size_t{v n == 8} -> a:lbytes (n *! n *! b /. size 8) -> i:size_t{v i < v n} -> Stack uint64 (requires fun h -> live h a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.frodo_key_encode1 (v logq) (v b) (v n) (as_seq h0 a) (v i))
let frodo_key_encode1 logq b n a i = let h0 = ST.get() in push_frame(); let v8 = create (size 8) (u8 0) in let chunk = sub a (i *! b) b in let h1 = ST.get() in assert (as_seq h1 chunk == LSeq.sub (as_seq h0 a) (v (i *! b)) (v b)); update_sub v8 (size 0) b chunk; let x = uint_from_bytes_le #U64 v8 in pop_frame(); x
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Encode.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 81, "start_col": 0, "start_line": 71 }
module Hacl.Impl.Frodo.Encode open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Impl.Matrix module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module S = Spec.Frodo.Encode #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract private val ec: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= v logq} -> k:uint16{v k < pow2 (v b)} -> r:uint16{r == S.ec (v logq) (v b) k} let ec logq b a = a <<. (logq -. b) inline_for_extraction noextract private val dc: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b < v logq} -> c:uint16 -> r:uint16{r == S.dc (v logq) (v b) c} let dc logq b c = let res1 = (c +. (u16 1 <<. (logq -. b -. size 1))) >>. (logq -. b) in res1 &. ((u16 1 <<. b) -. u16 1) inline_for_extraction noextract private val ec1: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b <= v logq} -> x:uint64 -> k:size_t{v k < 8} -> res:uint16{res == S.ec1 (v logq) (v b) x (v k)} let ec1 logq b x k = Spec.Frodo.Lemmas.modulo_pow2_u64 (x >>. (b *! k)) (v b); let rk = (x >>. (b *! k)) &. ((u64 1 <<. b) -. u64 1) in ec logq b (to_u16 rk) inline_for_extraction noextract private val frodo_key_encode1: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b <= v logq} -> n:size_t{v n == 8} -> a:lbytes (n *! n *! b /. size 8) -> i:size_t{v i < v n} -> Stack uint64 (requires fun h -> live h a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.frodo_key_encode1 (v logq) (v b) (v n) (as_seq h0 a) (v i))
{ "checked_file": "/", "dependencies": [ "Spec.Matrix.fst.checked", "Spec.Frodo.Lemmas.fst.checked", "Spec.Frodo.Encode.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Matrix.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.Frodo.Encode.fst" }
[ { "abbrev": true, "full_module": "Spec.Frodo.Encode", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "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.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
logq: Lib.IntTypes.size_t{0 < Lib.IntTypes.v logq /\ Lib.IntTypes.v logq <= 16} -> b: Lib.IntTypes.size_t {0 < Lib.IntTypes.v b /\ Lib.IntTypes.v b <= 8 /\ Lib.IntTypes.v b <= Lib.IntTypes.v logq} -> n: Lib.IntTypes.size_t{Lib.IntTypes.v n == 8} -> a: Hacl.Impl.Matrix.lbytes (n *! n *! b /. Lib.IntTypes.size 8) -> i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v n} -> FStar.HyperStack.ST.Stack Lib.IntTypes.uint64
FStar.HyperStack.ST.Stack
[]
[]
[ "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.eq2", "Prims.int", "Hacl.Impl.Matrix.lbytes", "Lib.IntTypes.op_Slash_Dot", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.size", "Lib.IntTypes.uint64", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.ByteBuffer.uint_from_bytes_le", "Lib.IntTypes.uint_t", "Lib.Buffer.update_sub", "Lib.Buffer.MUT", "Lib.IntTypes.uint8", "Prims._assert", "Lib.Sequence.lseq", "Lib.Buffer.as_seq", "Lib.Sequence.sub", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.U8", "Lib.Buffer.sub", "Lib.IntTypes.mk_int", "Lib.Buffer.create", "Lib.IntTypes.u8", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let frodo_key_encode1 logq b n a i =
let h0 = ST.get () in push_frame (); let v8 = create (size 8) (u8 0) in let chunk = sub a (i *! b) b in let h1 = ST.get () in assert (as_seq h1 chunk == LSeq.sub (as_seq h0 a) (v (i *! b)) (v b)); update_sub v8 (size 0) b chunk; let x = uint_from_bytes_le #U64 v8 in pop_frame (); x
false
Hacl.Bignum.MontArithmetic.fsti
Hacl.Bignum.MontArithmetic.bn_field_free_st
val bn_field_free_st : t: Hacl.Bignum.Definitions.limb_t -> Type0
let bn_field_free_st (t:limb_t) = k:pbn_mont_ctx t -> ST unit (requires fun h -> freeable h k /\ pbn_mont_ctx_inv h k) (ensures fun h0 _ h1 -> B.(modifies (footprint h0 k) h0 h1))
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 40, "end_line": 173, "start_col": 0, "start_line": 167 }
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module Euclid = FStar.Math.Euclid module S = Hacl.Spec.Bignum.MontArithmetic module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val _align_fsti : unit inline_for_extraction noextract let lb (t:limb_t) = match t with | U32 -> buffer uint32 | U64 -> buffer uint64 inline_for_extraction noextract let ll (t:limb_t) = match t with | U32 -> uint32 | U64 -> uint64 inline_for_extraction noeq type bn_mont_ctx' (t:limb_t) (a:Type0{a == lb t}) (b:Type0{b == ll t}) = { len: BN.meta_len t; n: x:a{length #MUT #(limb t) x == v len}; mu: b; r2: x:a{length #MUT #(limb t) x == v len}; } inline_for_extraction noextract let bn_mont_ctx (t:limb_t) = bn_mont_ctx' t (lb t) (ll t) let bn_mont_ctx_u32 = bn_mont_ctx' U32 (lb U32) (ll U32) let bn_mont_ctx_u64 = bn_mont_ctx' U64 (lb U64) (ll U64) inline_for_extraction noextract let pbn_mont_ctx (t:limb_t) = B.pointer (bn_mont_ctx t) inline_for_extraction noextract let pbn_mont_ctx_u32 = B.pointer bn_mont_ctx_u32 inline_for_extraction noextract let pbn_mont_ctx_u64 = B.pointer bn_mont_ctx_u64 inline_for_extraction noextract let as_ctx (#t:limb_t) (h:mem) (k:bn_mont_ctx t) : GTot (S.bn_mont_ctx t) = { S.len = v k.len; S.n = as_seq h (k.n <: lbignum t k.len); S.mu = k.mu; S.r2 = as_seq h (k.r2 <: lbignum t k.len); } inline_for_extraction noextract let bn_mont_ctx_inv (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in live h n /\ live h r2 /\ disjoint n r2 /\ S.bn_mont_ctx_inv (as_ctx h k) inline_for_extraction noextract let bn_v_n (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = let k1 = B.deref h k in let n : lbignum t k1.len = k1.n in bn_v h n inline_for_extraction noextract let freeable_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.freeable n /\ B.freeable r2 inline_for_extraction noextract let freeable (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.freeable k /\ freeable_s h (B.deref h k) inline_for_extraction noextract let footprint_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.(loc_union (loc_addr_of_buffer n) (loc_addr_of_buffer r2)) inline_for_extraction noextract let footprint (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.(loc_union (loc_addr_of_buffer k) (footprint_s h (B.deref h k))) inline_for_extraction noextract let as_pctx (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) : GTot (S.bn_mont_ctx t) = as_ctx h (B.deref h k) inline_for_extraction noextract let pbn_mont_ctx_inv (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.live h k /\ B.(loc_disjoint (loc_addr_of_buffer k) (footprint_s h (B.deref h k))) /\ bn_mont_ctx_inv h (B.deref h k) inline_for_extraction noextract let bn_field_get_len_st (t:limb_t) = k:pbn_mont_ctx t -> Stack (BN.meta_len t) (requires fun h -> pbn_mont_ctx_inv h k) (ensures fun h0 r h1 -> h0 == h1 /\ r == (B.deref h0 k).len /\ v r == S.bn_field_get_len (as_pctx h0 k)) inline_for_extraction noextract val bn_field_get_len: #t:limb_t -> bn_field_get_len_st t inline_for_extraction noextract let bn_field_check_modulus_st (t:limb_t) (len:BN.meta_len t) = n:lbignum t len -> Stack bool (requires fun h -> live h n) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_field_check_modulus (as_seq h0 n)) inline_for_extraction noextract val bn_field_check_modulus: #t:limb_t -> km:BM.mont t -> bn_field_check_modulus_st t km.BM.bn.BN.len inline_for_extraction noextract let bn_field_init_st (t:limb_t) (len:BN.meta_len t) = r:HS.rid -> n:lbignum t len -> ST (pbn_mont_ctx t) (requires fun h -> S.bn_mont_ctx_pre (as_seq h n) /\ live h n /\ ST.is_eternal_region r) (ensures fun h0 res h1 -> B.(modifies loc_none h0 h1) /\ B.(fresh_loc (footprint h1 res) h0 h1) /\ B.(loc_includes (loc_region_only true r) (footprint h1 res)) /\ freeable h1 res /\ (B.deref h1 res).len == len /\ bn_v_n h1 res == bn_v h0 n /\ S.bn_mont_ctx_inv (as_pctx h1 res) /\ as_pctx h1 res == S.bn_field_init (as_seq h0 n)) inline_for_extraction noextract val bn_field_init: #t:limb_t -> len:BN.meta_len t -> precomp_r2:BM.bn_precomp_r2_mod_n_st t len -> bn_field_init_st t len
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontArithmetic.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Hacl.Bignum.Definitions.limb_t -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Hacl.Bignum.MontArithmetic.freeable", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx_inv", "LowStar.Monotonic.Buffer.modifies", "Hacl.Bignum.MontArithmetic.footprint" ]
[]
false
false
false
true
true
let bn_field_free_st (t: limb_t) =
k: pbn_mont_ctx t -> ST unit (requires fun h -> freeable h k /\ pbn_mont_ctx_inv h k) (ensures fun h0 _ h1 -> let open B in modifies (footprint h0 k) h0 h1)
false
Hacl.K256.PrecompTable.fst
Hacl.K256.PrecompTable.precomp_basepoint_table_w4
val precomp_basepoint_table_w4: x:glbuffer uint64 240ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x}
val precomp_basepoint_table_w4: x:glbuffer uint64 240ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x}
let precomp_basepoint_table_w4: x:glbuffer uint64 240ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} = createL_global precomp_basepoint_table_list_w4
{ "file_name": "code/k256/Hacl.K256.PrecompTable.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 48, "end_line": 213, "start_col": 0, "start_line": 211 }
module Hacl.K256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.K256.PrecompTable module S = Spec.K256 module SL = Spec.K256.Lemmas open Hacl.Impl.K256.Point include Hacl.Impl.K256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in [@inline_let] let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in [@inline_let] let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops S.g 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops S.g 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64); let rX : S.felem = 0x46ec0aa60b0b98c37b29371784676ad967b7beb1a941ddb6fbbff95b44cb788b in let rY : S.felem = 0x6b946755bbc6b677576579c990a1ccf14a710545251a1428fabbf02f40268e63 in let rZ : S.felem = 0x3c114b2ac17c199ec9eba9f7cc64dc459ca2e53f5bbead2b4e618b318ffcc00e in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in [@inline_let] let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in [@inline_let] let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x98299efbc8e459915404ae015b48cac3b929e0158665f3c7fa5489fbd25c4297 in let rY : S.felem = 0xf1e5cbc9579e7d11a31681e947c2959ae0298a006d1c06ab1ad93d6716ea50cc in let rZ : S.felem = 0x5c53ffe15001674a2eacb60c9327a8b0ddbd93a0fa6d90309de6cc124133938b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in [@inline_let] let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in [@inline_let] let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_k256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xbd382b67d20492b1480ca58a6d7d617ba413a9bc7c2f1cff51301ef960fb245c in let rY : S.felem = 0x0b232afcf692673aa714357c524c07867a64ea3b9dfab53f0e74622159e86b0d in let rZ : S.felem = 0x028a1380449aede5df8219420b458d464a6a4773ac91e8305237878cef1cffa6 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops S.g 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_k256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 15 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_k256_concrete_ops S.g val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_k256_concrete_ops S.g val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_k256_concrete_ops S.g let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 240} = normalize_term (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 15) let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 240 = normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 15); Seq.seq_of_list precomp_basepoint_table_list_w4 let precomp_basepoint_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_k256_precomp_base_table S.g 15); SPT.precomp_base_table_lemma mk_k256_precomp_base_table S.g 16 precomp_basepoint_table_lseq_w4
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.K256.PrecompTable.fsti.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.K256.PrecompTable.fst" }
[ { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Hacl.Spec.K256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.K256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "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
x: Lib.Buffer.glbuffer Lib.IntTypes.uint64 240ul { Lib.Buffer.witnessed x Hacl.K256.PrecompTable.precomp_basepoint_table_lseq_w4 /\ Lib.Buffer.recallable x }
Prims.Tot
[ "total" ]
[]
[ "Lib.Buffer.createL_global", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Hacl.K256.PrecompTable.precomp_basepoint_table_list_w4", "Lib.Buffer.glbuffer", "Lib.IntTypes.size", "FStar.Pervasives.normalize_term", "Lib.IntTypes.size_nat", "FStar.List.Tot.Base.length", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Prims.l_and", "Lib.Buffer.witnessed", "Hacl.K256.PrecompTable.precomp_basepoint_table_lseq_w4", "Lib.Buffer.recallable", "Lib.Buffer.CONST" ]
[]
false
false
false
false
false
let precomp_basepoint_table_w4:x: glbuffer uint64 240ul {witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} =
createL_global precomp_basepoint_table_list_w4
false
Hacl.Bignum.MontArithmetic.fsti
Hacl.Bignum.MontArithmetic.ll
val ll : t: Hacl.Bignum.Definitions.limb_t -> Type0
let ll (t:limb_t) = match t with | U32 -> uint32 | U64 -> uint64
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 17, "end_line": 36, "start_col": 0, "start_line": 33 }
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module Euclid = FStar.Math.Euclid module S = Hacl.Spec.Bignum.MontArithmetic module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val _align_fsti : unit inline_for_extraction noextract let lb (t:limb_t) = match t with | U32 -> buffer uint32 | U64 -> buffer uint64
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontArithmetic.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Hacl.Bignum.Definitions.limb_t -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Lib.IntTypes.uint32", "Lib.IntTypes.uint64" ]
[]
false
false
false
true
true
let ll (t: limb_t) =
match t with | U32 -> uint32 | U64 -> uint64
false
Hacl.Bignum.MontArithmetic.fsti
Hacl.Bignum.MontArithmetic.bn_mont_ctx_inv
val bn_mont_ctx_inv : h: FStar.Monotonic.HyperStack.mem -> k: Hacl.Bignum.MontArithmetic.bn_mont_ctx t -> Prims.logical
let bn_mont_ctx_inv (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in live h n /\ live h r2 /\ disjoint n r2 /\ S.bn_mont_ctx_inv (as_ctx h k)
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 32, "end_line": 74, "start_col": 0, "start_line": 70 }
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module Euclid = FStar.Math.Euclid module S = Hacl.Spec.Bignum.MontArithmetic module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val _align_fsti : unit inline_for_extraction noextract let lb (t:limb_t) = match t with | U32 -> buffer uint32 | U64 -> buffer uint64 inline_for_extraction noextract let ll (t:limb_t) = match t with | U32 -> uint32 | U64 -> uint64 inline_for_extraction noeq type bn_mont_ctx' (t:limb_t) (a:Type0{a == lb t}) (b:Type0{b == ll t}) = { len: BN.meta_len t; n: x:a{length #MUT #(limb t) x == v len}; mu: b; r2: x:a{length #MUT #(limb t) x == v len}; } inline_for_extraction noextract let bn_mont_ctx (t:limb_t) = bn_mont_ctx' t (lb t) (ll t) let bn_mont_ctx_u32 = bn_mont_ctx' U32 (lb U32) (ll U32) let bn_mont_ctx_u64 = bn_mont_ctx' U64 (lb U64) (ll U64) inline_for_extraction noextract let pbn_mont_ctx (t:limb_t) = B.pointer (bn_mont_ctx t) inline_for_extraction noextract let pbn_mont_ctx_u32 = B.pointer bn_mont_ctx_u32 inline_for_extraction noextract let pbn_mont_ctx_u64 = B.pointer bn_mont_ctx_u64 inline_for_extraction noextract let as_ctx (#t:limb_t) (h:mem) (k:bn_mont_ctx t) : GTot (S.bn_mont_ctx t) = { S.len = v k.len; S.n = as_seq h (k.n <: lbignum t k.len); S.mu = k.mu; S.r2 = as_seq h (k.r2 <: lbignum t k.len); }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontArithmetic.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "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
h: FStar.Monotonic.HyperStack.mem -> k: Hacl.Bignum.MontArithmetic.bn_mont_ctx t -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "FStar.Monotonic.HyperStack.mem", "Hacl.Bignum.MontArithmetic.bn_mont_ctx", "Prims.l_and", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.disjoint", "Hacl.Spec.Bignum.MontArithmetic.bn_mont_ctx_inv", "Hacl.Bignum.MontArithmetic.as_ctx", "Lib.Buffer.buffer_t", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__r2", "Hacl.Bignum.MontArithmetic.lb", "Hacl.Bignum.MontArithmetic.ll", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__n", "Prims.logical" ]
[]
false
false
false
false
true
let bn_mont_ctx_inv (#t: limb_t) (h: mem) (k: bn_mont_ctx t) =
let n:buffer (limb t) = k.n in let r2:buffer (limb t) = k.r2 in live h n /\ live h r2 /\ disjoint n r2 /\ S.bn_mont_ctx_inv (as_ctx h k)
false
Hacl.Bignum.MontArithmetic.fsti
Hacl.Bignum.MontArithmetic.lb
val lb : t: Hacl.Bignum.Definitions.limb_t -> Type0
let lb (t:limb_t) = match t with | U32 -> buffer uint32 | U64 -> buffer uint64
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 24, "end_line": 30, "start_col": 0, "start_line": 27 }
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module Euclid = FStar.Math.Euclid module S = Hacl.Spec.Bignum.MontArithmetic module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val _align_fsti : unit
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontArithmetic.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Hacl.Bignum.Definitions.limb_t -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Lib.Buffer.buffer", "Lib.IntTypes.uint32", "Lib.IntTypes.uint64" ]
[]
false
false
false
true
true
let lb (t: limb_t) =
match t with | U32 -> buffer uint32 | U64 -> buffer uint64
false
Hacl.Impl.Frodo.Encode.fst
Hacl.Impl.Frodo.Encode.frodo_key_decode
val frodo_key_decode: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b < v logq} -> n:size_t{v n == 8} -> a:matrix_t n n -> res:lbytes (n *! n *! b /. size 8) -> Stack unit (requires fun h -> live h a /\ live h res /\ disjoint a res /\ as_seq h res == LSeq.create (v n * v n * v b / 8) (u8 0)) (ensures fun h0 _ h1 -> modifies1 res h0 h1 /\ as_seq h1 res == S.frodo_key_decode (v logq) (v b) (v n) (as_matrix h0 a))
val frodo_key_decode: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b < v logq} -> n:size_t{v n == 8} -> a:matrix_t n n -> res:lbytes (n *! n *! b /. size 8) -> Stack unit (requires fun h -> live h a /\ live h res /\ disjoint a res /\ as_seq h res == LSeq.create (v n * v n * v b / 8) (u8 0)) (ensures fun h0 _ h1 -> modifies1 res h0 h1 /\ as_seq h1 res == S.frodo_key_decode (v logq) (v b) (v n) (as_matrix h0 a))
let frodo_key_decode logq b n a res = [@ inline_let] let spec h0 = S.frodo_key_decode2 (v logq) (v b) (v n) (as_seq h0 a) in let h0 = ST.get() in loop1 h0 n res spec (fun i -> Loops.unfold_repeati (v n) (spec h0) (as_seq h0 res) (v i); let templong = frodo_key_decode2 logq b n a i in frodo_key_decode1 logq b n i templong res )
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Encode.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 217, "start_col": 0, "start_line": 208 }
module Hacl.Impl.Frodo.Encode open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Impl.Matrix module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module S = Spec.Frodo.Encode #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract private val ec: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= v logq} -> k:uint16{v k < pow2 (v b)} -> r:uint16{r == S.ec (v logq) (v b) k} let ec logq b a = a <<. (logq -. b) inline_for_extraction noextract private val dc: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b < v logq} -> c:uint16 -> r:uint16{r == S.dc (v logq) (v b) c} let dc logq b c = let res1 = (c +. (u16 1 <<. (logq -. b -. size 1))) >>. (logq -. b) in res1 &. ((u16 1 <<. b) -. u16 1) inline_for_extraction noextract private val ec1: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b <= v logq} -> x:uint64 -> k:size_t{v k < 8} -> res:uint16{res == S.ec1 (v logq) (v b) x (v k)} let ec1 logq b x k = Spec.Frodo.Lemmas.modulo_pow2_u64 (x >>. (b *! k)) (v b); let rk = (x >>. (b *! k)) &. ((u64 1 <<. b) -. u64 1) in ec logq b (to_u16 rk) inline_for_extraction noextract private val frodo_key_encode1: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b <= v logq} -> n:size_t{v n == 8} -> a:lbytes (n *! n *! b /. size 8) -> i:size_t{v i < v n} -> Stack uint64 (requires fun h -> live h a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.frodo_key_encode1 (v logq) (v b) (v n) (as_seq h0 a) (v i)) let frodo_key_encode1 logq b n a i = let h0 = ST.get() in push_frame(); let v8 = create (size 8) (u8 0) in let chunk = sub a (i *! b) b in let h1 = ST.get() in assert (as_seq h1 chunk == LSeq.sub (as_seq h0 a) (v (i *! b)) (v b)); update_sub v8 (size 0) b chunk; let x = uint_from_bytes_le #U64 v8 in pop_frame(); x inline_for_extraction noextract private val frodo_key_encode2: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b <= v logq} -> n:size_t{v n == 8} -> a:lbytes (n *! n *! b /. size 8) -> i:size_t{v i < v n} -> x:uint64 -> res:matrix_t n n -> Stack unit (requires fun h -> live h a /\ live h res /\ disjoint a res) (ensures fun h0 _ h1 -> modifies1 res h0 h1 /\ as_matrix h1 res == Loops.repeati 8 (S.frodo_key_encode0 (v logq) (v b) (v n) (as_seq h0 a) x (v i)) (as_matrix h0 res)) let frodo_key_encode2 logq b n a i x res = [@ inline_let] let spec h0 = S.frodo_key_encode0 (v logq) (v b) (v n) (as_seq h0 a) x (v i) in let h0 = ST.get () in loop1 h0 (size 8) res spec (fun k -> Loops.unfold_repeati 8 (spec h0) (as_seq h0 res) (v k); mset res i k (ec1 logq b x k) ) val frodo_key_encode: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b <= v logq} -> n:size_t{v n == 8} -> a:lbytes (n *! n *! b /. size 8) -> res:matrix_t n n -> Stack unit (requires fun h -> live h a /\ live h res /\ disjoint a res /\ as_seq h res == Spec.Matrix.create (v n) (v n)) (ensures fun h0 _ h1 -> modifies1 res h0 h1 /\ as_matrix h1 res == S.frodo_key_encode (v logq) (v b) (v n) (as_seq h0 a)) [@"c_inline"] let frodo_key_encode logq b n a res = let h0 = ST.get () in [@ inline_let] let spec h0 = S.frodo_key_encode2 (v logq) (v b) (v n) (as_seq h0 a) in loop1 h0 n res spec (fun i -> Loops.unfold_repeati (v n) (spec h0) (as_seq h0 res) (v i); let x = frodo_key_encode1 logq b n a i in frodo_key_encode2 logq b n a i x res ) inline_for_extraction noextract private val frodo_key_decode1: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b < v logq} -> n:size_t{v n == 8} -> i:size_t{v i < v n} -> templong:uint64 -> res:lbytes (n *! n *! b /. size 8) -> Stack unit (requires fun h -> live h res) (ensures fun h0 _ h1 -> modifies1 res h0 h1 /\ as_seq h1 res == S.frodo_key_decode1 (v logq) (v b) (v n) (v i) templong (as_seq h0 res)) let frodo_key_decode1 logq b n i templong res = push_frame(); let v8 = create (size 8) (u8 0) in uint_to_bytes_le v8 templong; let tmp = sub v8 (size 0) b in update_sub res (i *! b) b tmp; pop_frame() inline_for_extraction noextract private val frodo_key_decode2: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b < v logq} -> n:size_t{v n == 8} -> a:matrix_t n n -> i:size_t{v i < v n} -> Stack uint64 (requires fun h -> live h a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == Loops.repeat_gen 8 S.decode_templong_t (S.frodo_key_decode0 (v logq) (v b) (v n) (as_matrix h0 a) (v i)) (u64 0)) let frodo_key_decode2 logq b n a i = push_frame(); let templong = create (size 1) (u64 0) in [@ inline_let] let refl h i : GTot uint64 = bget h templong 0 in [@ inline_let] let footprint i = loc templong in [@ inline_let] let spec h0 = S.frodo_key_decode0 (v logq) (v b) (v n) (as_matrix h0 a) (v i) in let h0 = ST.get () in assert (bget h0 templong 0 == u64 0); loop h0 (size 8) S.decode_templong_t refl footprint spec (fun k -> Loops.unfold_repeat_gen 8 S.decode_templong_t (spec h0) (refl h0 0) (v k); let aik = mget a i k in templong.(size 0) <- templong.(size 0) |. (to_u64 (dc logq b aik) <<. (b *! k)) ); let templong = templong.(size 0) in pop_frame(); templong val frodo_key_decode: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b < v logq} -> n:size_t{v n == 8} -> a:matrix_t n n -> res:lbytes (n *! n *! b /. size 8) -> Stack unit (requires fun h -> live h a /\ live h res /\ disjoint a res /\ as_seq h res == LSeq.create (v n * v n * v b / 8) (u8 0)) (ensures fun h0 _ h1 -> modifies1 res h0 h1 /\ as_seq h1 res == S.frodo_key_decode (v logq) (v b) (v n) (as_matrix h0 a))
{ "checked_file": "/", "dependencies": [ "Spec.Matrix.fst.checked", "Spec.Frodo.Lemmas.fst.checked", "Spec.Frodo.Encode.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Matrix.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.Frodo.Encode.fst" }
[ { "abbrev": true, "full_module": "Spec.Frodo.Encode", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "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.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
logq: Lib.IntTypes.size_t{0 < Lib.IntTypes.v logq /\ Lib.IntTypes.v logq <= 16} -> b: Lib.IntTypes.size_t {0 < Lib.IntTypes.v b /\ Lib.IntTypes.v b <= 8 /\ Lib.IntTypes.v b < Lib.IntTypes.v logq} -> n: Lib.IntTypes.size_t{Lib.IntTypes.v n == 8} -> a: Hacl.Impl.Matrix.matrix_t n n -> res: Hacl.Impl.Matrix.lbytes (n *! n *! b /. Lib.IntTypes.size 8) -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "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.eq2", "Prims.int", "Hacl.Impl.Matrix.matrix_t", "Hacl.Impl.Matrix.lbytes", "Lib.IntTypes.op_Slash_Dot", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.size", "Lib.Buffer.loop1", "Lib.IntTypes.uint8", "Hacl.Impl.Frodo.Encode.frodo_key_decode1", "Prims.unit", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Hacl.Impl.Frodo.Encode.frodo_key_decode2", "Lib.IntTypes.uint64", "Lib.LoopCombinators.unfold_repeati", "Lib.Sequence.lseq", "Lib.IntTypes.U8", "Prims.op_Division", "Prims.op_Multiply", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Prims.nat", "Prims.op_Subtraction", "Prims.pow2", "Spec.Frodo.Encode.frodo_key_decode2", "Hacl.Impl.Matrix.elem" ]
[]
false
true
false
false
false
let frodo_key_decode logq b n a res =
[@@ inline_let ]let spec h0 = S.frodo_key_decode2 (v logq) (v b) (v n) (as_seq h0 a) in let h0 = ST.get () in loop1 h0 n res spec (fun i -> Loops.unfold_repeati (v n) (spec h0) (as_seq h0 res) (v i); let templong = frodo_key_decode2 logq b n a i in frodo_key_decode1 logq b n i templong res)
false
Hacl.Spec.Montgomery.Lemmas.fst
Hacl.Spec.Montgomery.Lemmas.from_mont
val from_mont: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> aM:nat -> nat
val from_mont: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> aM:nat -> nat
let from_mont pbits rLen n mu aM = mont_reduction pbits rLen n mu aM
{ "file_name": "code/bignum/Hacl.Spec.Montgomery.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 35, "end_line": 225, "start_col": 0, "start_line": 224 }
module Hacl.Spec.Montgomery.Lemmas open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators (** https://members.loria.fr/PZimmermann/mca/mca-cup-0.5.9.pdf https://eprint.iacr.org/2011/239.pdf https://eprint.iacr.org/2017/1057.pdf *) #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val eea_pow2_odd_k_lemma_d: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let d = n * k1 / pow2 (a - 1) in d % 2 == (if n * k1 % pow2 a < pow2 (a - 1) then 0 else 1))) let eea_pow2_odd_k_lemma_d a n k1 = let d = n * k1 / pow2 (a - 1) in Math.Lemmas.pow2_modulo_division_lemma_1 (n * k1) (a - 1) a; assert (d % 2 == n * k1 % pow2 a / pow2 (a - 1)); if d % 2 = 0 then begin Math.Lemmas.small_division_lemma_2 (n * k1 % pow2 a) (pow2 (a - 1)); assert (n * k1 % pow2 a < pow2 (a - 1)); () end #push-options "--z3rlimit 100" val eea_pow2_odd_k_lemma: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in n * k % pow2 a == 1)) let eea_pow2_odd_k_lemma a n k1 = let d = n * k1 / pow2 (a - 1) in let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in calc (==) { n * k1; (==) { Math.Lemmas.euclidean_division_definition (n * k1) (pow2 (a - 1)) } 1 + d * pow2 (a - 1); (==) { Math.Lemmas.euclidean_division_definition d 2 } 1 + (d / 2 * 2 + d % 2) * pow2 (a - 1); (==) { Math.Lemmas.distributivity_add_left (d / 2 * 2) (d % 2) (pow2 (a - 1)) } 1 + d / 2 * 2 * pow2 (a - 1) + d % 2 * pow2 (a - 1); (==) { Math.Lemmas.pow2_plus 1 (a - 1) } 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1); }; assert (n * k1 == 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1)); if n * k1 % pow2 a < pow2 (a - 1) then begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 0); calc (==) { n * k % pow2 a; (==) { } (1 + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) (d / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a = 1); () end else begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 1); assert (n * k1 == 1 + d / 2 * pow2 a + pow2 (a - 1)); //assert (n * k == 1 + d / 2 * pow2 a + pow2 (a - 1) + n * pow2 (a - 1)); calc (==) { n * k % pow2 a; (==) { Math.Lemmas.distributivity_add_right n k1 (pow2 (a - 1)) } (n * k1 + n * pow2 (a - 1)) % pow2 a; (==) { } (1 + pow2 (a - 1) + n * pow2 (a - 1) + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma (1 + pow2 (a - 1) + n * pow2 (a - 1)) (pow2 a) (d / 2) } (1 + pow2 (a - 1) + n * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.distributivity_add_left 1 n (pow2 (a - 1)) } (1 + (1 + n) * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.lemma_div_exact (1 + n) 2 } (1 + (1 + n) / 2 * 2 * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.paren_mul_right ((1 + n) / 2) 2 (pow2 (a - 1)) } (1 + (1 + n) / 2 * (2 * pow2 (a - 1))) % pow2 a; (==) { Math.Lemmas.pow2_plus 1 (a - 1)} (1 + (1 + n) / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) ((1 + n) / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a == 1); () end #pop-options val eea_pow2_odd_k_lemma_bound: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1 /\ k1 < pow2 (a - 1)) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in k < pow2 a)) let eea_pow2_odd_k_lemma_bound a n k1 = if n * k1 % pow2 a < pow2 (a - 1) then Math.Lemmas.pow2_lt_compat a (a - 1) else Math.Lemmas.pow2_double_sum (a - 1) val eea_pow2_odd_k: a:pos -> n:pos -> Pure pos (requires n % 2 = 1) (ensures fun k -> n * k % pow2 a == 1 /\ k < pow2 a) let rec eea_pow2_odd_k a n = if a = 1 then 1 else begin let k1 = eea_pow2_odd_k (a - 1) n in assert (n * k1 % pow2 (a - 1) == 1); let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in eea_pow2_odd_k_lemma a n k1; eea_pow2_odd_k_lemma_bound a n k1; assert (n * k % pow2 a == 1); k end val eea_pow2_odd: a:pos -> n:pos -> Pure (tuple2 int int) (requires n % 2 = 1) (ensures fun (d, k) -> pow2 a * d == 1 + k * n /\ - d < n) let eea_pow2_odd a n = let k = eea_pow2_odd_k a n in assert (n * k % pow2 a == 1); assert (n * k == n * k / pow2 a * pow2 a + 1); let d = n * k / pow2 a in Math.Lemmas.lemma_mult_lt_left n k (pow2 a); assert (n * k < n * pow2 a); Math.Lemmas.cancel_mul_div n (pow2 a); assert (d < n); assert (n * k == d * pow2 a + 1); (- d, - k) val mont_preconditions_d: pbits:pos -> rLen:pos -> n:pos{1 < n} -> Lemma (requires n % 2 = 1) (ensures (let d, k = eea_pow2_odd (pbits * rLen) n in pow2 (pbits * rLen) * d % n == 1)) let mont_preconditions_d pbits rLen n = let d, k = eea_pow2_odd (pbits * rLen) n in calc (==) { pow2 (pbits * rLen) * d % n; (==) { } (1 + k * n) % n; (==) { Math.Lemmas.modulo_addition_lemma 1 n k } 1 % n; (==) { Math.Lemmas.small_mod 1 n } 1; }; assert (pow2 (pbits * rLen) * d % n == 1) val mont_preconditions_n0: pbits:pos -> n:pos{n > 1} -> mu:nat -> Lemma (requires (1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) (ensures (1 + n * mu) % pow2 pbits == 0) let mont_preconditions_n0 pbits n mu = calc (==) { (1 + n * mu) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_plus_distr_r 1 (n * mu) (pow2 pbits) } (1 + n * mu % pow2 pbits) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_mul_distr_l n mu (pow2 pbits) } (1 + n % pow2 pbits * mu % pow2 pbits) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_plus_distr_r 1 (n % pow2 pbits * mu) (pow2 pbits) } (1 + n % pow2 pbits * mu) % pow2 pbits; (==) { assert ((1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) } 0; }; assert ((1 + n * mu) % pow2 pbits == 0) val mont_preconditions: pbits:pos -> rLen:pos -> n:pos{1 < n} -> mu:nat -> Lemma (requires n % 2 = 1 /\ (1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) (ensures (let r = pow2 (pbits * rLen) in let d, _ = eea_pow2_odd (pbits * rLen) n in r * d % n == 1 /\ (1 + n * mu) % pow2 pbits == 0)) let mont_preconditions pbits rLen n mu = mont_preconditions_d pbits rLen n; mont_preconditions_n0 pbits n mu /// High-level specification of Montgomery arithmetic val mont_reduction_f: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> i:nat{i < rLen} -> c:nat -> nat let mont_reduction_f pbits rLen n mu i c = let c_i = c / pow2 (pbits * i) % pow2 pbits in let q_i = mu * c_i % pow2 pbits in let res = c + n * q_i * pow2 (pbits * i) in res val mont_reduction_loop_div_r: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> c:nat -> nat let mont_reduction_loop_div_r pbits rLen n mu c = let res = repeati rLen (mont_reduction_f pbits rLen n mu) c in let res = res / pow2 (pbits * rLen) in res val mont_reduction: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> c:nat -> nat let mont_reduction pbits rLen n mu c = let res = mont_reduction_loop_div_r pbits rLen n mu c in if res < n then res else res - n val to_mont: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> a:nat -> nat let to_mont pbits rLen n mu a = let r2 = pow2 (2 * pbits * rLen) % n in let c = a * r2 in mont_reduction pbits rLen n mu c
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Montgomery.Lemmas.fst" }
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
pbits: Prims.pos -> rLen: Prims.nat -> n: Prims.pos -> mu: Prims.nat -> aM: Prims.nat -> Prims.nat
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "Prims.nat", "Hacl.Spec.Montgomery.Lemmas.mont_reduction" ]
[]
false
false
false
true
false
let from_mont pbits rLen n mu aM =
mont_reduction pbits rLen n mu aM
false
Hacl.Spec.Montgomery.Lemmas.fst
Hacl.Spec.Montgomery.Lemmas.mont_sqr
val mont_sqr: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> a:nat -> nat
val mont_sqr: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> a:nat -> nat
let mont_sqr pbits rLen n mu a = mont_mul pbits rLen n mu a a
{ "file_name": "code/bignum/Hacl.Spec.Montgomery.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 30, "end_line": 234, "start_col": 0, "start_line": 233 }
module Hacl.Spec.Montgomery.Lemmas open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators (** https://members.loria.fr/PZimmermann/mca/mca-cup-0.5.9.pdf https://eprint.iacr.org/2011/239.pdf https://eprint.iacr.org/2017/1057.pdf *) #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val eea_pow2_odd_k_lemma_d: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let d = n * k1 / pow2 (a - 1) in d % 2 == (if n * k1 % pow2 a < pow2 (a - 1) then 0 else 1))) let eea_pow2_odd_k_lemma_d a n k1 = let d = n * k1 / pow2 (a - 1) in Math.Lemmas.pow2_modulo_division_lemma_1 (n * k1) (a - 1) a; assert (d % 2 == n * k1 % pow2 a / pow2 (a - 1)); if d % 2 = 0 then begin Math.Lemmas.small_division_lemma_2 (n * k1 % pow2 a) (pow2 (a - 1)); assert (n * k1 % pow2 a < pow2 (a - 1)); () end #push-options "--z3rlimit 100" val eea_pow2_odd_k_lemma: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in n * k % pow2 a == 1)) let eea_pow2_odd_k_lemma a n k1 = let d = n * k1 / pow2 (a - 1) in let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in calc (==) { n * k1; (==) { Math.Lemmas.euclidean_division_definition (n * k1) (pow2 (a - 1)) } 1 + d * pow2 (a - 1); (==) { Math.Lemmas.euclidean_division_definition d 2 } 1 + (d / 2 * 2 + d % 2) * pow2 (a - 1); (==) { Math.Lemmas.distributivity_add_left (d / 2 * 2) (d % 2) (pow2 (a - 1)) } 1 + d / 2 * 2 * pow2 (a - 1) + d % 2 * pow2 (a - 1); (==) { Math.Lemmas.pow2_plus 1 (a - 1) } 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1); }; assert (n * k1 == 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1)); if n * k1 % pow2 a < pow2 (a - 1) then begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 0); calc (==) { n * k % pow2 a; (==) { } (1 + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) (d / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a = 1); () end else begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 1); assert (n * k1 == 1 + d / 2 * pow2 a + pow2 (a - 1)); //assert (n * k == 1 + d / 2 * pow2 a + pow2 (a - 1) + n * pow2 (a - 1)); calc (==) { n * k % pow2 a; (==) { Math.Lemmas.distributivity_add_right n k1 (pow2 (a - 1)) } (n * k1 + n * pow2 (a - 1)) % pow2 a; (==) { } (1 + pow2 (a - 1) + n * pow2 (a - 1) + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma (1 + pow2 (a - 1) + n * pow2 (a - 1)) (pow2 a) (d / 2) } (1 + pow2 (a - 1) + n * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.distributivity_add_left 1 n (pow2 (a - 1)) } (1 + (1 + n) * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.lemma_div_exact (1 + n) 2 } (1 + (1 + n) / 2 * 2 * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.paren_mul_right ((1 + n) / 2) 2 (pow2 (a - 1)) } (1 + (1 + n) / 2 * (2 * pow2 (a - 1))) % pow2 a; (==) { Math.Lemmas.pow2_plus 1 (a - 1)} (1 + (1 + n) / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) ((1 + n) / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a == 1); () end #pop-options val eea_pow2_odd_k_lemma_bound: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1 /\ k1 < pow2 (a - 1)) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in k < pow2 a)) let eea_pow2_odd_k_lemma_bound a n k1 = if n * k1 % pow2 a < pow2 (a - 1) then Math.Lemmas.pow2_lt_compat a (a - 1) else Math.Lemmas.pow2_double_sum (a - 1) val eea_pow2_odd_k: a:pos -> n:pos -> Pure pos (requires n % 2 = 1) (ensures fun k -> n * k % pow2 a == 1 /\ k < pow2 a) let rec eea_pow2_odd_k a n = if a = 1 then 1 else begin let k1 = eea_pow2_odd_k (a - 1) n in assert (n * k1 % pow2 (a - 1) == 1); let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in eea_pow2_odd_k_lemma a n k1; eea_pow2_odd_k_lemma_bound a n k1; assert (n * k % pow2 a == 1); k end val eea_pow2_odd: a:pos -> n:pos -> Pure (tuple2 int int) (requires n % 2 = 1) (ensures fun (d, k) -> pow2 a * d == 1 + k * n /\ - d < n) let eea_pow2_odd a n = let k = eea_pow2_odd_k a n in assert (n * k % pow2 a == 1); assert (n * k == n * k / pow2 a * pow2 a + 1); let d = n * k / pow2 a in Math.Lemmas.lemma_mult_lt_left n k (pow2 a); assert (n * k < n * pow2 a); Math.Lemmas.cancel_mul_div n (pow2 a); assert (d < n); assert (n * k == d * pow2 a + 1); (- d, - k) val mont_preconditions_d: pbits:pos -> rLen:pos -> n:pos{1 < n} -> Lemma (requires n % 2 = 1) (ensures (let d, k = eea_pow2_odd (pbits * rLen) n in pow2 (pbits * rLen) * d % n == 1)) let mont_preconditions_d pbits rLen n = let d, k = eea_pow2_odd (pbits * rLen) n in calc (==) { pow2 (pbits * rLen) * d % n; (==) { } (1 + k * n) % n; (==) { Math.Lemmas.modulo_addition_lemma 1 n k } 1 % n; (==) { Math.Lemmas.small_mod 1 n } 1; }; assert (pow2 (pbits * rLen) * d % n == 1) val mont_preconditions_n0: pbits:pos -> n:pos{n > 1} -> mu:nat -> Lemma (requires (1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) (ensures (1 + n * mu) % pow2 pbits == 0) let mont_preconditions_n0 pbits n mu = calc (==) { (1 + n * mu) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_plus_distr_r 1 (n * mu) (pow2 pbits) } (1 + n * mu % pow2 pbits) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_mul_distr_l n mu (pow2 pbits) } (1 + n % pow2 pbits * mu % pow2 pbits) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_plus_distr_r 1 (n % pow2 pbits * mu) (pow2 pbits) } (1 + n % pow2 pbits * mu) % pow2 pbits; (==) { assert ((1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) } 0; }; assert ((1 + n * mu) % pow2 pbits == 0) val mont_preconditions: pbits:pos -> rLen:pos -> n:pos{1 < n} -> mu:nat -> Lemma (requires n % 2 = 1 /\ (1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) (ensures (let r = pow2 (pbits * rLen) in let d, _ = eea_pow2_odd (pbits * rLen) n in r * d % n == 1 /\ (1 + n * mu) % pow2 pbits == 0)) let mont_preconditions pbits rLen n mu = mont_preconditions_d pbits rLen n; mont_preconditions_n0 pbits n mu /// High-level specification of Montgomery arithmetic val mont_reduction_f: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> i:nat{i < rLen} -> c:nat -> nat let mont_reduction_f pbits rLen n mu i c = let c_i = c / pow2 (pbits * i) % pow2 pbits in let q_i = mu * c_i % pow2 pbits in let res = c + n * q_i * pow2 (pbits * i) in res val mont_reduction_loop_div_r: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> c:nat -> nat let mont_reduction_loop_div_r pbits rLen n mu c = let res = repeati rLen (mont_reduction_f pbits rLen n mu) c in let res = res / pow2 (pbits * rLen) in res val mont_reduction: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> c:nat -> nat let mont_reduction pbits rLen n mu c = let res = mont_reduction_loop_div_r pbits rLen n mu c in if res < n then res else res - n val to_mont: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> a:nat -> nat let to_mont pbits rLen n mu a = let r2 = pow2 (2 * pbits * rLen) % n in let c = a * r2 in mont_reduction pbits rLen n mu c val from_mont: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> aM:nat -> nat let from_mont pbits rLen n mu aM = mont_reduction pbits rLen n mu aM val mont_mul: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> a:nat -> b:nat -> nat let mont_mul pbits rLen n mu a b = let c = a * b in mont_reduction pbits rLen n mu c
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Montgomery.Lemmas.fst" }
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
pbits: Prims.pos -> rLen: Prims.nat -> n: Prims.pos -> mu: Prims.nat -> a: Prims.nat -> Prims.nat
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "Prims.nat", "Hacl.Spec.Montgomery.Lemmas.mont_mul" ]
[]
false
false
false
true
false
let mont_sqr pbits rLen n mu a =
mont_mul pbits rLen n mu a a
false
Hacl.Bignum.MontArithmetic.fsti
Hacl.Bignum.MontArithmetic.bn_v_n
val bn_v_n : h: FStar.Monotonic.HyperStack.mem -> k: Hacl.Bignum.MontArithmetic.pbn_mont_ctx t -> Prims.GTot Prims.nat
let bn_v_n (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = let k1 = B.deref h k in let n : lbignum t k1.len = k1.n in bn_v h n
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 10, "end_line": 81, "start_col": 0, "start_line": 78 }
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module Euclid = FStar.Math.Euclid module S = Hacl.Spec.Bignum.MontArithmetic module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val _align_fsti : unit inline_for_extraction noextract let lb (t:limb_t) = match t with | U32 -> buffer uint32 | U64 -> buffer uint64 inline_for_extraction noextract let ll (t:limb_t) = match t with | U32 -> uint32 | U64 -> uint64 inline_for_extraction noeq type bn_mont_ctx' (t:limb_t) (a:Type0{a == lb t}) (b:Type0{b == ll t}) = { len: BN.meta_len t; n: x:a{length #MUT #(limb t) x == v len}; mu: b; r2: x:a{length #MUT #(limb t) x == v len}; } inline_for_extraction noextract let bn_mont_ctx (t:limb_t) = bn_mont_ctx' t (lb t) (ll t) let bn_mont_ctx_u32 = bn_mont_ctx' U32 (lb U32) (ll U32) let bn_mont_ctx_u64 = bn_mont_ctx' U64 (lb U64) (ll U64) inline_for_extraction noextract let pbn_mont_ctx (t:limb_t) = B.pointer (bn_mont_ctx t) inline_for_extraction noextract let pbn_mont_ctx_u32 = B.pointer bn_mont_ctx_u32 inline_for_extraction noextract let pbn_mont_ctx_u64 = B.pointer bn_mont_ctx_u64 inline_for_extraction noextract let as_ctx (#t:limb_t) (h:mem) (k:bn_mont_ctx t) : GTot (S.bn_mont_ctx t) = { S.len = v k.len; S.n = as_seq h (k.n <: lbignum t k.len); S.mu = k.mu; S.r2 = as_seq h (k.r2 <: lbignum t k.len); } inline_for_extraction noextract let bn_mont_ctx_inv (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in live h n /\ live h r2 /\ disjoint n r2 /\ S.bn_mont_ctx_inv (as_ctx h k)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontArithmetic.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "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
h: FStar.Monotonic.HyperStack.mem -> k: Hacl.Bignum.MontArithmetic.pbn_mont_ctx t -> Prims.GTot Prims.nat
Prims.GTot
[ "sometrivial" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "FStar.Monotonic.HyperStack.mem", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.Bignum.Definitions.bn_v", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__len", "Hacl.Bignum.MontArithmetic.lb", "Hacl.Bignum.MontArithmetic.ll", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__n", "Hacl.Bignum.MontArithmetic.bn_mont_ctx", "LowStar.Monotonic.Buffer.deref", "LowStar.Buffer.trivial_preorder", "Prims.nat" ]
[]
false
false
false
false
false
let bn_v_n (#t: limb_t) (h: mem) (k: pbn_mont_ctx t) =
let k1 = B.deref h k in let n:lbignum t k1.len = k1.n in bn_v h n
false
Hacl.Impl.P256.Verify.fst
Hacl.Impl.P256.Verify.lbytes
val lbytes : len: Lib.IntTypes.size_t -> Type0
let lbytes len = lbuffer uint8 len
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.Verify.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 34, "end_line": 26, "start_col": 0, "start_line": 26 }
module Hacl.Impl.P256.Verify open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack module ST = FStar.HyperStack.ST open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum open Hacl.Impl.P256.Point open Hacl.Impl.P256.Scalar open Hacl.Impl.P256.PointMul module BSeq = Lib.ByteSequence module S = Spec.P256 module SL = Spec.P256.Lemmas module SM = Hacl.Spec.P256.Montgomery module QI = Hacl.Impl.P256.Qinv #set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
{ "checked_file": "/", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Impl.P256.Scalar.fsti.checked", "Hacl.Impl.P256.Qinv.fsti.checked", "Hacl.Impl.P256.PointMul.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "Hacl.Bignum.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.P256.Verify.fst" }
[ { "abbrev": true, "full_module": "Hacl.Impl.P256.Qinv", "short_module": "QI" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.PointMul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Scalar", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
len: Lib.IntTypes.size_t -> Type0
Prims.Tot
[ "total" ]
[]
[ "Lib.IntTypes.size_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8" ]
[]
false
false
false
true
true
let lbytes len =
lbuffer uint8 len
false
Hacl.Bignum.MontArithmetic.fsti
Hacl.Bignum.MontArithmetic.as_ctx
val as_ctx (#t: limb_t) (h: mem) (k: bn_mont_ctx t) : GTot (S.bn_mont_ctx t)
val as_ctx (#t: limb_t) (h: mem) (k: bn_mont_ctx t) : GTot (S.bn_mont_ctx t)
let as_ctx (#t:limb_t) (h:mem) (k:bn_mont_ctx t) : GTot (S.bn_mont_ctx t) = { S.len = v k.len; S.n = as_seq h (k.n <: lbignum t k.len); S.mu = k.mu; S.r2 = as_seq h (k.r2 <: lbignum t k.len); }
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 67, "start_col": 0, "start_line": 62 }
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module Euclid = FStar.Math.Euclid module S = Hacl.Spec.Bignum.MontArithmetic module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val _align_fsti : unit inline_for_extraction noextract let lb (t:limb_t) = match t with | U32 -> buffer uint32 | U64 -> buffer uint64 inline_for_extraction noextract let ll (t:limb_t) = match t with | U32 -> uint32 | U64 -> uint64 inline_for_extraction noeq type bn_mont_ctx' (t:limb_t) (a:Type0{a == lb t}) (b:Type0{b == ll t}) = { len: BN.meta_len t; n: x:a{length #MUT #(limb t) x == v len}; mu: b; r2: x:a{length #MUT #(limb t) x == v len}; } inline_for_extraction noextract let bn_mont_ctx (t:limb_t) = bn_mont_ctx' t (lb t) (ll t) let bn_mont_ctx_u32 = bn_mont_ctx' U32 (lb U32) (ll U32) let bn_mont_ctx_u64 = bn_mont_ctx' U64 (lb U64) (ll U64) inline_for_extraction noextract let pbn_mont_ctx (t:limb_t) = B.pointer (bn_mont_ctx t) inline_for_extraction noextract let pbn_mont_ctx_u32 = B.pointer bn_mont_ctx_u32 inline_for_extraction noextract let pbn_mont_ctx_u64 = B.pointer bn_mont_ctx_u64
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontArithmetic.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "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
h: FStar.Monotonic.HyperStack.mem -> k: Hacl.Bignum.MontArithmetic.bn_mont_ctx t -> Prims.GTot (Hacl.Spec.Bignum.MontArithmetic.bn_mont_ctx t)
Prims.GTot
[ "sometrivial" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "FStar.Monotonic.HyperStack.mem", "Hacl.Bignum.MontArithmetic.bn_mont_ctx", "Hacl.Spec.Bignum.MontArithmetic.Mkbn_mont_ctx", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__len", "Hacl.Bignum.MontArithmetic.lb", "Hacl.Bignum.MontArithmetic.ll", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__n", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__mu", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__r2", "Hacl.Spec.Bignum.MontArithmetic.bn_mont_ctx" ]
[]
false
false
false
false
false
let as_ctx (#t: limb_t) (h: mem) (k: bn_mont_ctx t) : GTot (S.bn_mont_ctx t) =
{ S.len = v k.len; S.n = as_seq h (k.n <: lbignum t k.len); S.mu = k.mu; S.r2 = as_seq h (k.r2 <: lbignum t k.len) }
false
Hacl.Bignum.MontArithmetic.fsti
Hacl.Bignum.MontArithmetic.footprint_s
val footprint_s : h: FStar.Monotonic.HyperStack.mem -> k: Hacl.Bignum.MontArithmetic.bn_mont_ctx t -> Prims.GTot LowStar.Monotonic.Buffer.loc
let footprint_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.(loc_union (loc_addr_of_buffer n) (loc_addr_of_buffer r2))
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 62, "end_line": 97, "start_col": 0, "start_line": 94 }
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module Euclid = FStar.Math.Euclid module S = Hacl.Spec.Bignum.MontArithmetic module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val _align_fsti : unit inline_for_extraction noextract let lb (t:limb_t) = match t with | U32 -> buffer uint32 | U64 -> buffer uint64 inline_for_extraction noextract let ll (t:limb_t) = match t with | U32 -> uint32 | U64 -> uint64 inline_for_extraction noeq type bn_mont_ctx' (t:limb_t) (a:Type0{a == lb t}) (b:Type0{b == ll t}) = { len: BN.meta_len t; n: x:a{length #MUT #(limb t) x == v len}; mu: b; r2: x:a{length #MUT #(limb t) x == v len}; } inline_for_extraction noextract let bn_mont_ctx (t:limb_t) = bn_mont_ctx' t (lb t) (ll t) let bn_mont_ctx_u32 = bn_mont_ctx' U32 (lb U32) (ll U32) let bn_mont_ctx_u64 = bn_mont_ctx' U64 (lb U64) (ll U64) inline_for_extraction noextract let pbn_mont_ctx (t:limb_t) = B.pointer (bn_mont_ctx t) inline_for_extraction noextract let pbn_mont_ctx_u32 = B.pointer bn_mont_ctx_u32 inline_for_extraction noextract let pbn_mont_ctx_u64 = B.pointer bn_mont_ctx_u64 inline_for_extraction noextract let as_ctx (#t:limb_t) (h:mem) (k:bn_mont_ctx t) : GTot (S.bn_mont_ctx t) = { S.len = v k.len; S.n = as_seq h (k.n <: lbignum t k.len); S.mu = k.mu; S.r2 = as_seq h (k.r2 <: lbignum t k.len); } inline_for_extraction noextract let bn_mont_ctx_inv (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in live h n /\ live h r2 /\ disjoint n r2 /\ S.bn_mont_ctx_inv (as_ctx h k) inline_for_extraction noextract let bn_v_n (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = let k1 = B.deref h k in let n : lbignum t k1.len = k1.n in bn_v h n inline_for_extraction noextract let freeable_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.freeable n /\ B.freeable r2 inline_for_extraction noextract let freeable (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.freeable k /\ freeable_s h (B.deref h k)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontArithmetic.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "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
h: FStar.Monotonic.HyperStack.mem -> k: Hacl.Bignum.MontArithmetic.bn_mont_ctx t -> Prims.GTot LowStar.Monotonic.Buffer.loc
Prims.GTot
[ "sometrivial" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "FStar.Monotonic.HyperStack.mem", "Hacl.Bignum.MontArithmetic.bn_mont_ctx", "LowStar.Monotonic.Buffer.loc_union", "LowStar.Monotonic.Buffer.loc_addr_of_buffer", "Hacl.Bignum.Definitions.limb", "LowStar.Buffer.trivial_preorder", "Lib.Buffer.buffer_t", "Lib.Buffer.MUT", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__r2", "Hacl.Bignum.MontArithmetic.lb", "Hacl.Bignum.MontArithmetic.ll", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__n", "LowStar.Monotonic.Buffer.loc" ]
[]
false
false
false
false
false
let footprint_s (#t: limb_t) (h: mem) (k: bn_mont_ctx t) =
let n:buffer (limb t) = k.n in let r2:buffer (limb t) = k.r2 in let open B in loc_union (loc_addr_of_buffer n) (loc_addr_of_buffer r2)
false
Hacl.Spec.Montgomery.Lemmas.fst
Hacl.Spec.Montgomery.Lemmas.eea_pow2_odd_k_lemma_d
val eea_pow2_odd_k_lemma_d: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let d = n * k1 / pow2 (a - 1) in d % 2 == (if n * k1 % pow2 a < pow2 (a - 1) then 0 else 1)))
val eea_pow2_odd_k_lemma_d: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let d = n * k1 / pow2 (a - 1) in d % 2 == (if n * k1 % pow2 a < pow2 (a - 1) then 0 else 1)))
let eea_pow2_odd_k_lemma_d a n k1 = let d = n * k1 / pow2 (a - 1) in Math.Lemmas.pow2_modulo_division_lemma_1 (n * k1) (a - 1) a; assert (d % 2 == n * k1 % pow2 a / pow2 (a - 1)); if d % 2 = 0 then begin Math.Lemmas.small_division_lemma_2 (n * k1 % pow2 a) (pow2 (a - 1)); assert (n * k1 % pow2 a < pow2 (a - 1)); () end
{ "file_name": "code/bignum/Hacl.Spec.Montgomery.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 10, "end_line": 28, "start_col": 0, "start_line": 21 }
module Hacl.Spec.Montgomery.Lemmas open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators (** https://members.loria.fr/PZimmermann/mca/mca-cup-0.5.9.pdf https://eprint.iacr.org/2011/239.pdf https://eprint.iacr.org/2017/1057.pdf *) #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val eea_pow2_odd_k_lemma_d: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let d = n * k1 / pow2 (a - 1) in d % 2 == (if n * k1 % pow2 a < pow2 (a - 1) then 0 else 1)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Montgomery.Lemmas.fst" }
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: Prims.pos -> n: Prims.pos -> k1: Prims.pos -> FStar.Pervasives.Lemma (requires n * k1 % Prims.pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let d = n * k1 / Prims.pow2 (a - 1) in d % 2 == (match n * k1 % Prims.pow2 a < Prims.pow2 (a - 1) with | true -> 0 | _ -> 1)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.pos", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "Prims.unit", "Prims._assert", "Prims.b2t", "Prims.op_LessThan", "FStar.Mul.op_Star", "Prims.pow2", "Prims.op_Subtraction", "FStar.Math.Lemmas.small_division_lemma_2", "Prims.bool", "Prims.eq2", "Prims.op_Division", "FStar.Math.Lemmas.pow2_modulo_division_lemma_1" ]
[]
false
false
true
false
false
let eea_pow2_odd_k_lemma_d a n k1 =
let d = n * k1 / pow2 (a - 1) in Math.Lemmas.pow2_modulo_division_lemma_1 (n * k1) (a - 1) a; assert (d % 2 == n * k1 % pow2 a / pow2 (a - 1)); if d % 2 = 0 then (Math.Lemmas.small_division_lemma_2 (n * k1 % pow2 a) (pow2 (a - 1)); assert (n * k1 % pow2 a < pow2 (a - 1)); ())
false
Hacl.Spec.Montgomery.Lemmas.fst
Hacl.Spec.Montgomery.Lemmas.mont_reduction
val mont_reduction: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> c:nat -> nat
val mont_reduction: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> c:nat -> nat
let mont_reduction pbits rLen n mu c = let res = mont_reduction_loop_div_r pbits rLen n mu c in if res < n then res else res - n
{ "file_name": "code/bignum/Hacl.Spec.Montgomery.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 34, "end_line": 215, "start_col": 0, "start_line": 213 }
module Hacl.Spec.Montgomery.Lemmas open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators (** https://members.loria.fr/PZimmermann/mca/mca-cup-0.5.9.pdf https://eprint.iacr.org/2011/239.pdf https://eprint.iacr.org/2017/1057.pdf *) #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val eea_pow2_odd_k_lemma_d: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let d = n * k1 / pow2 (a - 1) in d % 2 == (if n * k1 % pow2 a < pow2 (a - 1) then 0 else 1))) let eea_pow2_odd_k_lemma_d a n k1 = let d = n * k1 / pow2 (a - 1) in Math.Lemmas.pow2_modulo_division_lemma_1 (n * k1) (a - 1) a; assert (d % 2 == n * k1 % pow2 a / pow2 (a - 1)); if d % 2 = 0 then begin Math.Lemmas.small_division_lemma_2 (n * k1 % pow2 a) (pow2 (a - 1)); assert (n * k1 % pow2 a < pow2 (a - 1)); () end #push-options "--z3rlimit 100" val eea_pow2_odd_k_lemma: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in n * k % pow2 a == 1)) let eea_pow2_odd_k_lemma a n k1 = let d = n * k1 / pow2 (a - 1) in let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in calc (==) { n * k1; (==) { Math.Lemmas.euclidean_division_definition (n * k1) (pow2 (a - 1)) } 1 + d * pow2 (a - 1); (==) { Math.Lemmas.euclidean_division_definition d 2 } 1 + (d / 2 * 2 + d % 2) * pow2 (a - 1); (==) { Math.Lemmas.distributivity_add_left (d / 2 * 2) (d % 2) (pow2 (a - 1)) } 1 + d / 2 * 2 * pow2 (a - 1) + d % 2 * pow2 (a - 1); (==) { Math.Lemmas.pow2_plus 1 (a - 1) } 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1); }; assert (n * k1 == 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1)); if n * k1 % pow2 a < pow2 (a - 1) then begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 0); calc (==) { n * k % pow2 a; (==) { } (1 + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) (d / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a = 1); () end else begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 1); assert (n * k1 == 1 + d / 2 * pow2 a + pow2 (a - 1)); //assert (n * k == 1 + d / 2 * pow2 a + pow2 (a - 1) + n * pow2 (a - 1)); calc (==) { n * k % pow2 a; (==) { Math.Lemmas.distributivity_add_right n k1 (pow2 (a - 1)) } (n * k1 + n * pow2 (a - 1)) % pow2 a; (==) { } (1 + pow2 (a - 1) + n * pow2 (a - 1) + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma (1 + pow2 (a - 1) + n * pow2 (a - 1)) (pow2 a) (d / 2) } (1 + pow2 (a - 1) + n * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.distributivity_add_left 1 n (pow2 (a - 1)) } (1 + (1 + n) * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.lemma_div_exact (1 + n) 2 } (1 + (1 + n) / 2 * 2 * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.paren_mul_right ((1 + n) / 2) 2 (pow2 (a - 1)) } (1 + (1 + n) / 2 * (2 * pow2 (a - 1))) % pow2 a; (==) { Math.Lemmas.pow2_plus 1 (a - 1)} (1 + (1 + n) / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) ((1 + n) / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a == 1); () end #pop-options val eea_pow2_odd_k_lemma_bound: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1 /\ k1 < pow2 (a - 1)) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in k < pow2 a)) let eea_pow2_odd_k_lemma_bound a n k1 = if n * k1 % pow2 a < pow2 (a - 1) then Math.Lemmas.pow2_lt_compat a (a - 1) else Math.Lemmas.pow2_double_sum (a - 1) val eea_pow2_odd_k: a:pos -> n:pos -> Pure pos (requires n % 2 = 1) (ensures fun k -> n * k % pow2 a == 1 /\ k < pow2 a) let rec eea_pow2_odd_k a n = if a = 1 then 1 else begin let k1 = eea_pow2_odd_k (a - 1) n in assert (n * k1 % pow2 (a - 1) == 1); let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in eea_pow2_odd_k_lemma a n k1; eea_pow2_odd_k_lemma_bound a n k1; assert (n * k % pow2 a == 1); k end val eea_pow2_odd: a:pos -> n:pos -> Pure (tuple2 int int) (requires n % 2 = 1) (ensures fun (d, k) -> pow2 a * d == 1 + k * n /\ - d < n) let eea_pow2_odd a n = let k = eea_pow2_odd_k a n in assert (n * k % pow2 a == 1); assert (n * k == n * k / pow2 a * pow2 a + 1); let d = n * k / pow2 a in Math.Lemmas.lemma_mult_lt_left n k (pow2 a); assert (n * k < n * pow2 a); Math.Lemmas.cancel_mul_div n (pow2 a); assert (d < n); assert (n * k == d * pow2 a + 1); (- d, - k) val mont_preconditions_d: pbits:pos -> rLen:pos -> n:pos{1 < n} -> Lemma (requires n % 2 = 1) (ensures (let d, k = eea_pow2_odd (pbits * rLen) n in pow2 (pbits * rLen) * d % n == 1)) let mont_preconditions_d pbits rLen n = let d, k = eea_pow2_odd (pbits * rLen) n in calc (==) { pow2 (pbits * rLen) * d % n; (==) { } (1 + k * n) % n; (==) { Math.Lemmas.modulo_addition_lemma 1 n k } 1 % n; (==) { Math.Lemmas.small_mod 1 n } 1; }; assert (pow2 (pbits * rLen) * d % n == 1) val mont_preconditions_n0: pbits:pos -> n:pos{n > 1} -> mu:nat -> Lemma (requires (1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) (ensures (1 + n * mu) % pow2 pbits == 0) let mont_preconditions_n0 pbits n mu = calc (==) { (1 + n * mu) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_plus_distr_r 1 (n * mu) (pow2 pbits) } (1 + n * mu % pow2 pbits) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_mul_distr_l n mu (pow2 pbits) } (1 + n % pow2 pbits * mu % pow2 pbits) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_plus_distr_r 1 (n % pow2 pbits * mu) (pow2 pbits) } (1 + n % pow2 pbits * mu) % pow2 pbits; (==) { assert ((1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) } 0; }; assert ((1 + n * mu) % pow2 pbits == 0) val mont_preconditions: pbits:pos -> rLen:pos -> n:pos{1 < n} -> mu:nat -> Lemma (requires n % 2 = 1 /\ (1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) (ensures (let r = pow2 (pbits * rLen) in let d, _ = eea_pow2_odd (pbits * rLen) n in r * d % n == 1 /\ (1 + n * mu) % pow2 pbits == 0)) let mont_preconditions pbits rLen n mu = mont_preconditions_d pbits rLen n; mont_preconditions_n0 pbits n mu /// High-level specification of Montgomery arithmetic val mont_reduction_f: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> i:nat{i < rLen} -> c:nat -> nat let mont_reduction_f pbits rLen n mu i c = let c_i = c / pow2 (pbits * i) % pow2 pbits in let q_i = mu * c_i % pow2 pbits in let res = c + n * q_i * pow2 (pbits * i) in res val mont_reduction_loop_div_r: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> c:nat -> nat let mont_reduction_loop_div_r pbits rLen n mu c = let res = repeati rLen (mont_reduction_f pbits rLen n mu) c in let res = res / pow2 (pbits * rLen) in res
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Montgomery.Lemmas.fst" }
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
pbits: Prims.pos -> rLen: Prims.nat -> n: Prims.pos -> mu: Prims.nat -> c: Prims.nat -> Prims.nat
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "Prims.nat", "Prims.op_LessThan", "Prims.bool", "Prims.op_Subtraction", "Hacl.Spec.Montgomery.Lemmas.mont_reduction_loop_div_r" ]
[]
false
false
false
true
false
let mont_reduction pbits rLen n mu c =
let res = mont_reduction_loop_div_r pbits rLen n mu c in if res < n then res else res - n
false
Hacl.Spec.Montgomery.Lemmas.fst
Hacl.Spec.Montgomery.Lemmas.to_mont
val to_mont: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> a:nat -> nat
val to_mont: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> a:nat -> nat
let to_mont pbits rLen n mu a = let r2 = pow2 (2 * pbits * rLen) % n in let c = a * r2 in mont_reduction pbits rLen n mu c
{ "file_name": "code/bignum/Hacl.Spec.Montgomery.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 34, "end_line": 221, "start_col": 0, "start_line": 218 }
module Hacl.Spec.Montgomery.Lemmas open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators (** https://members.loria.fr/PZimmermann/mca/mca-cup-0.5.9.pdf https://eprint.iacr.org/2011/239.pdf https://eprint.iacr.org/2017/1057.pdf *) #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val eea_pow2_odd_k_lemma_d: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let d = n * k1 / pow2 (a - 1) in d % 2 == (if n * k1 % pow2 a < pow2 (a - 1) then 0 else 1))) let eea_pow2_odd_k_lemma_d a n k1 = let d = n * k1 / pow2 (a - 1) in Math.Lemmas.pow2_modulo_division_lemma_1 (n * k1) (a - 1) a; assert (d % 2 == n * k1 % pow2 a / pow2 (a - 1)); if d % 2 = 0 then begin Math.Lemmas.small_division_lemma_2 (n * k1 % pow2 a) (pow2 (a - 1)); assert (n * k1 % pow2 a < pow2 (a - 1)); () end #push-options "--z3rlimit 100" val eea_pow2_odd_k_lemma: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in n * k % pow2 a == 1)) let eea_pow2_odd_k_lemma a n k1 = let d = n * k1 / pow2 (a - 1) in let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in calc (==) { n * k1; (==) { Math.Lemmas.euclidean_division_definition (n * k1) (pow2 (a - 1)) } 1 + d * pow2 (a - 1); (==) { Math.Lemmas.euclidean_division_definition d 2 } 1 + (d / 2 * 2 + d % 2) * pow2 (a - 1); (==) { Math.Lemmas.distributivity_add_left (d / 2 * 2) (d % 2) (pow2 (a - 1)) } 1 + d / 2 * 2 * pow2 (a - 1) + d % 2 * pow2 (a - 1); (==) { Math.Lemmas.pow2_plus 1 (a - 1) } 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1); }; assert (n * k1 == 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1)); if n * k1 % pow2 a < pow2 (a - 1) then begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 0); calc (==) { n * k % pow2 a; (==) { } (1 + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) (d / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a = 1); () end else begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 1); assert (n * k1 == 1 + d / 2 * pow2 a + pow2 (a - 1)); //assert (n * k == 1 + d / 2 * pow2 a + pow2 (a - 1) + n * pow2 (a - 1)); calc (==) { n * k % pow2 a; (==) { Math.Lemmas.distributivity_add_right n k1 (pow2 (a - 1)) } (n * k1 + n * pow2 (a - 1)) % pow2 a; (==) { } (1 + pow2 (a - 1) + n * pow2 (a - 1) + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma (1 + pow2 (a - 1) + n * pow2 (a - 1)) (pow2 a) (d / 2) } (1 + pow2 (a - 1) + n * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.distributivity_add_left 1 n (pow2 (a - 1)) } (1 + (1 + n) * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.lemma_div_exact (1 + n) 2 } (1 + (1 + n) / 2 * 2 * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.paren_mul_right ((1 + n) / 2) 2 (pow2 (a - 1)) } (1 + (1 + n) / 2 * (2 * pow2 (a - 1))) % pow2 a; (==) { Math.Lemmas.pow2_plus 1 (a - 1)} (1 + (1 + n) / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) ((1 + n) / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a == 1); () end #pop-options val eea_pow2_odd_k_lemma_bound: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1 /\ k1 < pow2 (a - 1)) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in k < pow2 a)) let eea_pow2_odd_k_lemma_bound a n k1 = if n * k1 % pow2 a < pow2 (a - 1) then Math.Lemmas.pow2_lt_compat a (a - 1) else Math.Lemmas.pow2_double_sum (a - 1) val eea_pow2_odd_k: a:pos -> n:pos -> Pure pos (requires n % 2 = 1) (ensures fun k -> n * k % pow2 a == 1 /\ k < pow2 a) let rec eea_pow2_odd_k a n = if a = 1 then 1 else begin let k1 = eea_pow2_odd_k (a - 1) n in assert (n * k1 % pow2 (a - 1) == 1); let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in eea_pow2_odd_k_lemma a n k1; eea_pow2_odd_k_lemma_bound a n k1; assert (n * k % pow2 a == 1); k end val eea_pow2_odd: a:pos -> n:pos -> Pure (tuple2 int int) (requires n % 2 = 1) (ensures fun (d, k) -> pow2 a * d == 1 + k * n /\ - d < n) let eea_pow2_odd a n = let k = eea_pow2_odd_k a n in assert (n * k % pow2 a == 1); assert (n * k == n * k / pow2 a * pow2 a + 1); let d = n * k / pow2 a in Math.Lemmas.lemma_mult_lt_left n k (pow2 a); assert (n * k < n * pow2 a); Math.Lemmas.cancel_mul_div n (pow2 a); assert (d < n); assert (n * k == d * pow2 a + 1); (- d, - k) val mont_preconditions_d: pbits:pos -> rLen:pos -> n:pos{1 < n} -> Lemma (requires n % 2 = 1) (ensures (let d, k = eea_pow2_odd (pbits * rLen) n in pow2 (pbits * rLen) * d % n == 1)) let mont_preconditions_d pbits rLen n = let d, k = eea_pow2_odd (pbits * rLen) n in calc (==) { pow2 (pbits * rLen) * d % n; (==) { } (1 + k * n) % n; (==) { Math.Lemmas.modulo_addition_lemma 1 n k } 1 % n; (==) { Math.Lemmas.small_mod 1 n } 1; }; assert (pow2 (pbits * rLen) * d % n == 1) val mont_preconditions_n0: pbits:pos -> n:pos{n > 1} -> mu:nat -> Lemma (requires (1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) (ensures (1 + n * mu) % pow2 pbits == 0) let mont_preconditions_n0 pbits n mu = calc (==) { (1 + n * mu) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_plus_distr_r 1 (n * mu) (pow2 pbits) } (1 + n * mu % pow2 pbits) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_mul_distr_l n mu (pow2 pbits) } (1 + n % pow2 pbits * mu % pow2 pbits) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_plus_distr_r 1 (n % pow2 pbits * mu) (pow2 pbits) } (1 + n % pow2 pbits * mu) % pow2 pbits; (==) { assert ((1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) } 0; }; assert ((1 + n * mu) % pow2 pbits == 0) val mont_preconditions: pbits:pos -> rLen:pos -> n:pos{1 < n} -> mu:nat -> Lemma (requires n % 2 = 1 /\ (1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) (ensures (let r = pow2 (pbits * rLen) in let d, _ = eea_pow2_odd (pbits * rLen) n in r * d % n == 1 /\ (1 + n * mu) % pow2 pbits == 0)) let mont_preconditions pbits rLen n mu = mont_preconditions_d pbits rLen n; mont_preconditions_n0 pbits n mu /// High-level specification of Montgomery arithmetic val mont_reduction_f: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> i:nat{i < rLen} -> c:nat -> nat let mont_reduction_f pbits rLen n mu i c = let c_i = c / pow2 (pbits * i) % pow2 pbits in let q_i = mu * c_i % pow2 pbits in let res = c + n * q_i * pow2 (pbits * i) in res val mont_reduction_loop_div_r: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> c:nat -> nat let mont_reduction_loop_div_r pbits rLen n mu c = let res = repeati rLen (mont_reduction_f pbits rLen n mu) c in let res = res / pow2 (pbits * rLen) in res val mont_reduction: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> c:nat -> nat let mont_reduction pbits rLen n mu c = let res = mont_reduction_loop_div_r pbits rLen n mu c in if res < n then res else res - n
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Montgomery.Lemmas.fst" }
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
pbits: Prims.pos -> rLen: Prims.nat -> n: Prims.pos -> mu: Prims.nat -> a: Prims.nat -> Prims.nat
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "Prims.nat", "Hacl.Spec.Montgomery.Lemmas.mont_reduction", "Prims.int", "FStar.Mul.op_Star", "Prims.op_Modulus", "Prims.pow2" ]
[]
false
false
false
true
false
let to_mont pbits rLen n mu a =
let r2 = pow2 ((2 * pbits) * rLen) % n in let c = a * r2 in mont_reduction pbits rLen n mu c
false
Hacl.Bignum.MontArithmetic.fsti
Hacl.Bignum.MontArithmetic.bn_to_field_st
val bn_to_field_st : t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0
let bn_to_field_st (t:limb_t) (len:BN.meta_len t) = k:pbn_mont_ctx t -> a:lbignum t len -> aM:lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ live h a /\ live h aM /\ disjoint a aM /\ B.(loc_disjoint (footprint h k) (loc_buffer (a <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc aM) h0 h1 /\ bn_v h1 aM < bn_v_n h0 k /\ as_seq h1 aM == S.bn_to_field (as_pctx h0 k) (as_seq h0 a))
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 63, "end_line": 195, "start_col": 0, "start_line": 181 }
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module Euclid = FStar.Math.Euclid module S = Hacl.Spec.Bignum.MontArithmetic module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val _align_fsti : unit inline_for_extraction noextract let lb (t:limb_t) = match t with | U32 -> buffer uint32 | U64 -> buffer uint64 inline_for_extraction noextract let ll (t:limb_t) = match t with | U32 -> uint32 | U64 -> uint64 inline_for_extraction noeq type bn_mont_ctx' (t:limb_t) (a:Type0{a == lb t}) (b:Type0{b == ll t}) = { len: BN.meta_len t; n: x:a{length #MUT #(limb t) x == v len}; mu: b; r2: x:a{length #MUT #(limb t) x == v len}; } inline_for_extraction noextract let bn_mont_ctx (t:limb_t) = bn_mont_ctx' t (lb t) (ll t) let bn_mont_ctx_u32 = bn_mont_ctx' U32 (lb U32) (ll U32) let bn_mont_ctx_u64 = bn_mont_ctx' U64 (lb U64) (ll U64) inline_for_extraction noextract let pbn_mont_ctx (t:limb_t) = B.pointer (bn_mont_ctx t) inline_for_extraction noextract let pbn_mont_ctx_u32 = B.pointer bn_mont_ctx_u32 inline_for_extraction noextract let pbn_mont_ctx_u64 = B.pointer bn_mont_ctx_u64 inline_for_extraction noextract let as_ctx (#t:limb_t) (h:mem) (k:bn_mont_ctx t) : GTot (S.bn_mont_ctx t) = { S.len = v k.len; S.n = as_seq h (k.n <: lbignum t k.len); S.mu = k.mu; S.r2 = as_seq h (k.r2 <: lbignum t k.len); } inline_for_extraction noextract let bn_mont_ctx_inv (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in live h n /\ live h r2 /\ disjoint n r2 /\ S.bn_mont_ctx_inv (as_ctx h k) inline_for_extraction noextract let bn_v_n (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = let k1 = B.deref h k in let n : lbignum t k1.len = k1.n in bn_v h n inline_for_extraction noextract let freeable_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.freeable n /\ B.freeable r2 inline_for_extraction noextract let freeable (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.freeable k /\ freeable_s h (B.deref h k) inline_for_extraction noextract let footprint_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.(loc_union (loc_addr_of_buffer n) (loc_addr_of_buffer r2)) inline_for_extraction noextract let footprint (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.(loc_union (loc_addr_of_buffer k) (footprint_s h (B.deref h k))) inline_for_extraction noextract let as_pctx (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) : GTot (S.bn_mont_ctx t) = as_ctx h (B.deref h k) inline_for_extraction noextract let pbn_mont_ctx_inv (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.live h k /\ B.(loc_disjoint (loc_addr_of_buffer k) (footprint_s h (B.deref h k))) /\ bn_mont_ctx_inv h (B.deref h k) inline_for_extraction noextract let bn_field_get_len_st (t:limb_t) = k:pbn_mont_ctx t -> Stack (BN.meta_len t) (requires fun h -> pbn_mont_ctx_inv h k) (ensures fun h0 r h1 -> h0 == h1 /\ r == (B.deref h0 k).len /\ v r == S.bn_field_get_len (as_pctx h0 k)) inline_for_extraction noextract val bn_field_get_len: #t:limb_t -> bn_field_get_len_st t inline_for_extraction noextract let bn_field_check_modulus_st (t:limb_t) (len:BN.meta_len t) = n:lbignum t len -> Stack bool (requires fun h -> live h n) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_field_check_modulus (as_seq h0 n)) inline_for_extraction noextract val bn_field_check_modulus: #t:limb_t -> km:BM.mont t -> bn_field_check_modulus_st t km.BM.bn.BN.len inline_for_extraction noextract let bn_field_init_st (t:limb_t) (len:BN.meta_len t) = r:HS.rid -> n:lbignum t len -> ST (pbn_mont_ctx t) (requires fun h -> S.bn_mont_ctx_pre (as_seq h n) /\ live h n /\ ST.is_eternal_region r) (ensures fun h0 res h1 -> B.(modifies loc_none h0 h1) /\ B.(fresh_loc (footprint h1 res) h0 h1) /\ B.(loc_includes (loc_region_only true r) (footprint h1 res)) /\ freeable h1 res /\ (B.deref h1 res).len == len /\ bn_v_n h1 res == bn_v h0 n /\ S.bn_mont_ctx_inv (as_pctx h1 res) /\ as_pctx h1 res == S.bn_field_init (as_seq h0 n)) inline_for_extraction noextract val bn_field_init: #t:limb_t -> len:BN.meta_len t -> precomp_r2:BM.bn_precomp_r2_mod_n_st t len -> bn_field_init_st t len inline_for_extraction noextract let bn_field_free_st (t:limb_t) = k:pbn_mont_ctx t -> ST unit (requires fun h -> freeable h k /\ pbn_mont_ctx_inv h k) (ensures fun h0 _ h1 -> B.(modifies (footprint h0 k) h0 h1)) inline_for_extraction noextract val bn_field_free: #t:limb_t -> bn_field_free_st t
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontArithmetic.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.meta_len", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.Bignum.Definitions.lbignum", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.eq2", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__len", "Hacl.Bignum.MontArithmetic.lb", "Hacl.Bignum.MontArithmetic.ll", "LowStar.Monotonic.Buffer.deref", "Hacl.Bignum.MontArithmetic.bn_mont_ctx", "LowStar.Buffer.trivial_preorder", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx_inv", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.disjoint", "LowStar.Monotonic.Buffer.loc_disjoint", "Hacl.Bignum.MontArithmetic.footprint", "LowStar.Monotonic.Buffer.loc_buffer", "LowStar.Buffer.buffer", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Prims.b2t", "Prims.op_LessThan", "Hacl.Bignum.Definitions.bn_v", "Hacl.Bignum.MontArithmetic.bn_v_n", "Lib.Sequence.seq", "Prims.l_or", "Prims.nat", "FStar.Seq.Base.length", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx__item__len", "Hacl.Bignum.MontArithmetic.as_pctx", "Hacl.Spec.Bignum.Definitions.bn_v", "Hacl.Spec.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx__item__n", "Lib.Buffer.as_seq", "Hacl.Spec.Bignum.MontArithmetic.bn_to_field" ]
[]
false
false
false
false
true
let bn_to_field_st (t: limb_t) (len: BN.meta_len t) =
k: pbn_mont_ctx t -> a: lbignum t len -> aM: lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ live h a /\ live h aM /\ disjoint a aM /\ B.(loc_disjoint (footprint h k) (loc_buffer (a <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc aM) h0 h1 /\ bn_v h1 aM < bn_v_n h0 k /\ as_seq h1 aM == S.bn_to_field (as_pctx h0 k) (as_seq h0 a))
false
Hacl.Spec.Montgomery.Lemmas.fst
Hacl.Spec.Montgomery.Lemmas.eea_pow2_odd_k_lemma_bound
val eea_pow2_odd_k_lemma_bound: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1 /\ k1 < pow2 (a - 1)) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in k < pow2 a))
val eea_pow2_odd_k_lemma_bound: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1 /\ k1 < pow2 (a - 1)) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in k < pow2 a))
let eea_pow2_odd_k_lemma_bound a n k1 = if n * k1 % pow2 a < pow2 (a - 1) then Math.Lemmas.pow2_lt_compat a (a - 1) else Math.Lemmas.pow2_double_sum (a - 1)
{ "file_name": "code/bignum/Hacl.Spec.Montgomery.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 39, "end_line": 107, "start_col": 0, "start_line": 103 }
module Hacl.Spec.Montgomery.Lemmas open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators (** https://members.loria.fr/PZimmermann/mca/mca-cup-0.5.9.pdf https://eprint.iacr.org/2011/239.pdf https://eprint.iacr.org/2017/1057.pdf *) #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val eea_pow2_odd_k_lemma_d: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let d = n * k1 / pow2 (a - 1) in d % 2 == (if n * k1 % pow2 a < pow2 (a - 1) then 0 else 1))) let eea_pow2_odd_k_lemma_d a n k1 = let d = n * k1 / pow2 (a - 1) in Math.Lemmas.pow2_modulo_division_lemma_1 (n * k1) (a - 1) a; assert (d % 2 == n * k1 % pow2 a / pow2 (a - 1)); if d % 2 = 0 then begin Math.Lemmas.small_division_lemma_2 (n * k1 % pow2 a) (pow2 (a - 1)); assert (n * k1 % pow2 a < pow2 (a - 1)); () end #push-options "--z3rlimit 100" val eea_pow2_odd_k_lemma: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in n * k % pow2 a == 1)) let eea_pow2_odd_k_lemma a n k1 = let d = n * k1 / pow2 (a - 1) in let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in calc (==) { n * k1; (==) { Math.Lemmas.euclidean_division_definition (n * k1) (pow2 (a - 1)) } 1 + d * pow2 (a - 1); (==) { Math.Lemmas.euclidean_division_definition d 2 } 1 + (d / 2 * 2 + d % 2) * pow2 (a - 1); (==) { Math.Lemmas.distributivity_add_left (d / 2 * 2) (d % 2) (pow2 (a - 1)) } 1 + d / 2 * 2 * pow2 (a - 1) + d % 2 * pow2 (a - 1); (==) { Math.Lemmas.pow2_plus 1 (a - 1) } 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1); }; assert (n * k1 == 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1)); if n * k1 % pow2 a < pow2 (a - 1) then begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 0); calc (==) { n * k % pow2 a; (==) { } (1 + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) (d / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a = 1); () end else begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 1); assert (n * k1 == 1 + d / 2 * pow2 a + pow2 (a - 1)); //assert (n * k == 1 + d / 2 * pow2 a + pow2 (a - 1) + n * pow2 (a - 1)); calc (==) { n * k % pow2 a; (==) { Math.Lemmas.distributivity_add_right n k1 (pow2 (a - 1)) } (n * k1 + n * pow2 (a - 1)) % pow2 a; (==) { } (1 + pow2 (a - 1) + n * pow2 (a - 1) + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma (1 + pow2 (a - 1) + n * pow2 (a - 1)) (pow2 a) (d / 2) } (1 + pow2 (a - 1) + n * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.distributivity_add_left 1 n (pow2 (a - 1)) } (1 + (1 + n) * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.lemma_div_exact (1 + n) 2 } (1 + (1 + n) / 2 * 2 * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.paren_mul_right ((1 + n) / 2) 2 (pow2 (a - 1)) } (1 + (1 + n) / 2 * (2 * pow2 (a - 1))) % pow2 a; (==) { Math.Lemmas.pow2_plus 1 (a - 1)} (1 + (1 + n) / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) ((1 + n) / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a == 1); () end #pop-options val eea_pow2_odd_k_lemma_bound: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1 /\ k1 < pow2 (a - 1)) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in k < pow2 a))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Montgomery.Lemmas.fst" }
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: Prims.pos -> n: Prims.pos -> k1: Prims.pos -> FStar.Pervasives.Lemma (requires n * k1 % Prims.pow2 (a - 1) == 1 /\ n % 2 = 1 /\ k1 < Prims.pow2 (a - 1)) (ensures (let k = (match n * k1 % Prims.pow2 a < Prims.pow2 (a - 1) with | true -> k1 | _ -> k1 + Prims.pow2 (a - 1)) <: Prims.int in k < Prims.pow2 a))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.pos", "Prims.op_LessThan", "Prims.op_Modulus", "FStar.Mul.op_Star", "Prims.pow2", "Prims.op_Subtraction", "FStar.Math.Lemmas.pow2_lt_compat", "Prims.bool", "FStar.Math.Lemmas.pow2_double_sum", "Prims.unit" ]
[]
false
false
true
false
false
let eea_pow2_odd_k_lemma_bound a n k1 =
if n * k1 % pow2 a < pow2 (a - 1) then Math.Lemmas.pow2_lt_compat a (a - 1) else Math.Lemmas.pow2_double_sum (a - 1)
false
Hacl.Bignum.MontArithmetic.fsti
Hacl.Bignum.MontArithmetic.freeable_s
val freeable_s : h: FStar.Monotonic.HyperStack.mem -> k: Hacl.Bignum.MontArithmetic.bn_mont_ctx t -> Prims.logical
let freeable_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.freeable n /\ B.freeable r2
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 31, "end_line": 87, "start_col": 0, "start_line": 84 }
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module Euclid = FStar.Math.Euclid module S = Hacl.Spec.Bignum.MontArithmetic module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val _align_fsti : unit inline_for_extraction noextract let lb (t:limb_t) = match t with | U32 -> buffer uint32 | U64 -> buffer uint64 inline_for_extraction noextract let ll (t:limb_t) = match t with | U32 -> uint32 | U64 -> uint64 inline_for_extraction noeq type bn_mont_ctx' (t:limb_t) (a:Type0{a == lb t}) (b:Type0{b == ll t}) = { len: BN.meta_len t; n: x:a{length #MUT #(limb t) x == v len}; mu: b; r2: x:a{length #MUT #(limb t) x == v len}; } inline_for_extraction noextract let bn_mont_ctx (t:limb_t) = bn_mont_ctx' t (lb t) (ll t) let bn_mont_ctx_u32 = bn_mont_ctx' U32 (lb U32) (ll U32) let bn_mont_ctx_u64 = bn_mont_ctx' U64 (lb U64) (ll U64) inline_for_extraction noextract let pbn_mont_ctx (t:limb_t) = B.pointer (bn_mont_ctx t) inline_for_extraction noextract let pbn_mont_ctx_u32 = B.pointer bn_mont_ctx_u32 inline_for_extraction noextract let pbn_mont_ctx_u64 = B.pointer bn_mont_ctx_u64 inline_for_extraction noextract let as_ctx (#t:limb_t) (h:mem) (k:bn_mont_ctx t) : GTot (S.bn_mont_ctx t) = { S.len = v k.len; S.n = as_seq h (k.n <: lbignum t k.len); S.mu = k.mu; S.r2 = as_seq h (k.r2 <: lbignum t k.len); } inline_for_extraction noextract let bn_mont_ctx_inv (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in live h n /\ live h r2 /\ disjoint n r2 /\ S.bn_mont_ctx_inv (as_ctx h k) inline_for_extraction noextract let bn_v_n (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = let k1 = B.deref h k in let n : lbignum t k1.len = k1.n in bn_v h n
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontArithmetic.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "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
h: FStar.Monotonic.HyperStack.mem -> k: Hacl.Bignum.MontArithmetic.bn_mont_ctx t -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "FStar.Monotonic.HyperStack.mem", "Hacl.Bignum.MontArithmetic.bn_mont_ctx", "Prims.l_and", "LowStar.Monotonic.Buffer.freeable", "Hacl.Bignum.Definitions.limb", "LowStar.Buffer.trivial_preorder", "Lib.Buffer.buffer_t", "Lib.Buffer.MUT", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__r2", "Hacl.Bignum.MontArithmetic.lb", "Hacl.Bignum.MontArithmetic.ll", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__n", "Prims.logical" ]
[]
false
false
false
false
true
let freeable_s (#t: limb_t) (h: mem) (k: bn_mont_ctx t) =
let n:buffer (limb t) = k.n in let r2:buffer (limb t) = k.r2 in B.freeable n /\ B.freeable r2
false
Hacl.Bignum.MontArithmetic.fsti
Hacl.Bignum.MontArithmetic.bn_field_sqr_st
val bn_field_sqr_st : t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0
let bn_field_sqr_st (t:limb_t) (len:BN.meta_len t) = k:pbn_mont_ctx t -> aM:lbignum t len -> cM:lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ bn_v h aM < bn_v_n h k /\ live h aM /\ live h cM /\ eq_or_disjoint aM cM /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (cM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc cM) h0 h1 /\ bn_v h1 cM < bn_v_n h0 k /\ as_seq h1 cM == S.bn_field_sqr (as_pctx h0 k) (as_seq h0 aM))
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 65, "end_line": 321, "start_col": 0, "start_line": 306 }
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module Euclid = FStar.Math.Euclid module S = Hacl.Spec.Bignum.MontArithmetic module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val _align_fsti : unit inline_for_extraction noextract let lb (t:limb_t) = match t with | U32 -> buffer uint32 | U64 -> buffer uint64 inline_for_extraction noextract let ll (t:limb_t) = match t with | U32 -> uint32 | U64 -> uint64 inline_for_extraction noeq type bn_mont_ctx' (t:limb_t) (a:Type0{a == lb t}) (b:Type0{b == ll t}) = { len: BN.meta_len t; n: x:a{length #MUT #(limb t) x == v len}; mu: b; r2: x:a{length #MUT #(limb t) x == v len}; } inline_for_extraction noextract let bn_mont_ctx (t:limb_t) = bn_mont_ctx' t (lb t) (ll t) let bn_mont_ctx_u32 = bn_mont_ctx' U32 (lb U32) (ll U32) let bn_mont_ctx_u64 = bn_mont_ctx' U64 (lb U64) (ll U64) inline_for_extraction noextract let pbn_mont_ctx (t:limb_t) = B.pointer (bn_mont_ctx t) inline_for_extraction noextract let pbn_mont_ctx_u32 = B.pointer bn_mont_ctx_u32 inline_for_extraction noextract let pbn_mont_ctx_u64 = B.pointer bn_mont_ctx_u64 inline_for_extraction noextract let as_ctx (#t:limb_t) (h:mem) (k:bn_mont_ctx t) : GTot (S.bn_mont_ctx t) = { S.len = v k.len; S.n = as_seq h (k.n <: lbignum t k.len); S.mu = k.mu; S.r2 = as_seq h (k.r2 <: lbignum t k.len); } inline_for_extraction noextract let bn_mont_ctx_inv (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in live h n /\ live h r2 /\ disjoint n r2 /\ S.bn_mont_ctx_inv (as_ctx h k) inline_for_extraction noextract let bn_v_n (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = let k1 = B.deref h k in let n : lbignum t k1.len = k1.n in bn_v h n inline_for_extraction noextract let freeable_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.freeable n /\ B.freeable r2 inline_for_extraction noextract let freeable (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.freeable k /\ freeable_s h (B.deref h k) inline_for_extraction noextract let footprint_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.(loc_union (loc_addr_of_buffer n) (loc_addr_of_buffer r2)) inline_for_extraction noextract let footprint (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.(loc_union (loc_addr_of_buffer k) (footprint_s h (B.deref h k))) inline_for_extraction noextract let as_pctx (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) : GTot (S.bn_mont_ctx t) = as_ctx h (B.deref h k) inline_for_extraction noextract let pbn_mont_ctx_inv (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.live h k /\ B.(loc_disjoint (loc_addr_of_buffer k) (footprint_s h (B.deref h k))) /\ bn_mont_ctx_inv h (B.deref h k) inline_for_extraction noextract let bn_field_get_len_st (t:limb_t) = k:pbn_mont_ctx t -> Stack (BN.meta_len t) (requires fun h -> pbn_mont_ctx_inv h k) (ensures fun h0 r h1 -> h0 == h1 /\ r == (B.deref h0 k).len /\ v r == S.bn_field_get_len (as_pctx h0 k)) inline_for_extraction noextract val bn_field_get_len: #t:limb_t -> bn_field_get_len_st t inline_for_extraction noextract let bn_field_check_modulus_st (t:limb_t) (len:BN.meta_len t) = n:lbignum t len -> Stack bool (requires fun h -> live h n) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_field_check_modulus (as_seq h0 n)) inline_for_extraction noextract val bn_field_check_modulus: #t:limb_t -> km:BM.mont t -> bn_field_check_modulus_st t km.BM.bn.BN.len inline_for_extraction noextract let bn_field_init_st (t:limb_t) (len:BN.meta_len t) = r:HS.rid -> n:lbignum t len -> ST (pbn_mont_ctx t) (requires fun h -> S.bn_mont_ctx_pre (as_seq h n) /\ live h n /\ ST.is_eternal_region r) (ensures fun h0 res h1 -> B.(modifies loc_none h0 h1) /\ B.(fresh_loc (footprint h1 res) h0 h1) /\ B.(loc_includes (loc_region_only true r) (footprint h1 res)) /\ freeable h1 res /\ (B.deref h1 res).len == len /\ bn_v_n h1 res == bn_v h0 n /\ S.bn_mont_ctx_inv (as_pctx h1 res) /\ as_pctx h1 res == S.bn_field_init (as_seq h0 n)) inline_for_extraction noextract val bn_field_init: #t:limb_t -> len:BN.meta_len t -> precomp_r2:BM.bn_precomp_r2_mod_n_st t len -> bn_field_init_st t len inline_for_extraction noextract let bn_field_free_st (t:limb_t) = k:pbn_mont_ctx t -> ST unit (requires fun h -> freeable h k /\ pbn_mont_ctx_inv h k) (ensures fun h0 _ h1 -> B.(modifies (footprint h0 k) h0 h1)) inline_for_extraction noextract val bn_field_free: #t:limb_t -> bn_field_free_st t inline_for_extraction noextract let bn_to_field_st (t:limb_t) (len:BN.meta_len t) = k:pbn_mont_ctx t -> a:lbignum t len -> aM:lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ live h a /\ live h aM /\ disjoint a aM /\ B.(loc_disjoint (footprint h k) (loc_buffer (a <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc aM) h0 h1 /\ bn_v h1 aM < bn_v_n h0 k /\ as_seq h1 aM == S.bn_to_field (as_pctx h0 k) (as_seq h0 a)) inline_for_extraction noextract val bn_to_field: #t:limb_t -> km:BM.mont t -> bn_to_field_st t km.BM.bn.BN.len inline_for_extraction noextract let bn_from_field_st (t:limb_t) (len:BN.meta_len t) = k:pbn_mont_ctx t -> aM:lbignum t len -> a:lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ bn_v h aM < bn_v_n h k /\ live h a /\ live h aM /\ disjoint a aM /\ B.(loc_disjoint (footprint h k) (loc_buffer (a <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc a) h0 h1 /\ bn_v h1 a < bn_v_n h0 k /\ as_seq h1 a == S.bn_from_field (as_pctx h0 k) (as_seq h0 aM)) inline_for_extraction noextract val bn_from_field: #t:limb_t -> km:BM.mont t -> bn_from_field_st t km.BM.bn.BN.len inline_for_extraction noextract let bn_field_add_st (t:limb_t) (len:BN.meta_len t) = k:pbn_mont_ctx t -> aM:lbignum t len -> bM:lbignum t len -> cM:lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ bn_v h aM < bn_v_n h k /\ bn_v h bM < bn_v_n h k /\ live h aM /\ live h bM /\ live h cM /\ eq_or_disjoint aM bM /\ eq_or_disjoint aM cM /\ eq_or_disjoint bM cM /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (bM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (cM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc cM) h0 h1 /\ bn_v h1 cM < bn_v_n h0 k /\ as_seq h1 cM == S.bn_field_add (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM)) inline_for_extraction noextract val bn_field_add: #t:limb_t -> km:BM.mont t -> bn_field_add_st t km.BM.bn.BN.len inline_for_extraction noextract let bn_field_sub_st (t:limb_t) (len:BN.meta_len t) = k:pbn_mont_ctx t -> aM:lbignum t len -> bM:lbignum t len -> cM:lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ bn_v h aM < bn_v_n h k /\ bn_v h bM < bn_v_n h k /\ live h aM /\ live h bM /\ live h cM /\ eq_or_disjoint aM bM /\ eq_or_disjoint aM cM /\ eq_or_disjoint bM cM /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (bM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (cM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc cM) h0 h1 /\ bn_v h1 cM < bn_v_n h0 k /\ as_seq h1 cM == S.bn_field_sub (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM)) inline_for_extraction noextract val bn_field_sub: #t:limb_t -> km:BM.mont t -> bn_field_sub_st t km.BM.bn.BN.len inline_for_extraction noextract let bn_field_mul_st (t:limb_t) (len:BN.meta_len t) = k:pbn_mont_ctx t -> aM:lbignum t len -> bM:lbignum t len -> cM:lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ bn_v h aM < bn_v_n h k /\ bn_v h bM < bn_v_n h k /\ live h aM /\ live h bM /\ live h cM /\ eq_or_disjoint aM bM /\ eq_or_disjoint aM cM /\ eq_or_disjoint bM cM /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (bM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (cM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc cM) h0 h1 /\ bn_v h1 cM < bn_v_n h0 k /\ as_seq h1 cM == S.bn_field_mul (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM)) inline_for_extraction noextract val bn_field_mul: #t:limb_t -> km:BM.mont t -> bn_field_mul_st t km.BM.bn.BN.len
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontArithmetic.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.meta_len", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.Bignum.Definitions.lbignum", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.eq2", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__len", "Hacl.Bignum.MontArithmetic.lb", "Hacl.Bignum.MontArithmetic.ll", "LowStar.Monotonic.Buffer.deref", "Hacl.Bignum.MontArithmetic.bn_mont_ctx", "LowStar.Buffer.trivial_preorder", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx_inv", "Prims.b2t", "Prims.op_LessThan", "Hacl.Bignum.Definitions.bn_v", "Hacl.Bignum.MontArithmetic.bn_v_n", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.eq_or_disjoint", "LowStar.Monotonic.Buffer.loc_disjoint", "Hacl.Bignum.MontArithmetic.footprint", "LowStar.Monotonic.Buffer.loc_buffer", "LowStar.Buffer.buffer", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Lib.Sequence.seq", "Prims.l_or", "Prims.nat", "FStar.Seq.Base.length", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx__item__len", "Hacl.Bignum.MontArithmetic.as_pctx", "Hacl.Spec.Bignum.Definitions.bn_v", "Hacl.Spec.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx__item__n", "Lib.Buffer.as_seq", "Hacl.Spec.Bignum.MontArithmetic.bn_field_sqr" ]
[]
false
false
false
false
true
let bn_field_sqr_st (t: limb_t) (len: BN.meta_len t) =
k: pbn_mont_ctx t -> aM: lbignum t len -> cM: lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ bn_v h aM < bn_v_n h k /\ live h aM /\ live h cM /\ eq_or_disjoint aM cM /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (cM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc cM) h0 h1 /\ bn_v h1 cM < bn_v_n h0 k /\ as_seq h1 cM == S.bn_field_sqr (as_pctx h0 k) (as_seq h0 aM))
false
Hacl.Bignum.MontArithmetic.fsti
Hacl.Bignum.MontArithmetic.bn_field_add_st
val bn_field_add_st : t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0
let bn_field_add_st (t:limb_t) (len:BN.meta_len t) = k:pbn_mont_ctx t -> aM:lbignum t len -> bM:lbignum t len -> cM:lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ bn_v h aM < bn_v_n h k /\ bn_v h bM < bn_v_n h k /\ live h aM /\ live h bM /\ live h cM /\ eq_or_disjoint aM bM /\ eq_or_disjoint aM cM /\ eq_or_disjoint bM cM /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (bM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (cM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc cM) h0 h1 /\ bn_v h1 cM < bn_v_n h0 k /\ as_seq h1 cM == S.bn_field_add (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM))
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 80, "end_line": 244, "start_col": 0, "start_line": 225 }
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module Euclid = FStar.Math.Euclid module S = Hacl.Spec.Bignum.MontArithmetic module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val _align_fsti : unit inline_for_extraction noextract let lb (t:limb_t) = match t with | U32 -> buffer uint32 | U64 -> buffer uint64 inline_for_extraction noextract let ll (t:limb_t) = match t with | U32 -> uint32 | U64 -> uint64 inline_for_extraction noeq type bn_mont_ctx' (t:limb_t) (a:Type0{a == lb t}) (b:Type0{b == ll t}) = { len: BN.meta_len t; n: x:a{length #MUT #(limb t) x == v len}; mu: b; r2: x:a{length #MUT #(limb t) x == v len}; } inline_for_extraction noextract let bn_mont_ctx (t:limb_t) = bn_mont_ctx' t (lb t) (ll t) let bn_mont_ctx_u32 = bn_mont_ctx' U32 (lb U32) (ll U32) let bn_mont_ctx_u64 = bn_mont_ctx' U64 (lb U64) (ll U64) inline_for_extraction noextract let pbn_mont_ctx (t:limb_t) = B.pointer (bn_mont_ctx t) inline_for_extraction noextract let pbn_mont_ctx_u32 = B.pointer bn_mont_ctx_u32 inline_for_extraction noextract let pbn_mont_ctx_u64 = B.pointer bn_mont_ctx_u64 inline_for_extraction noextract let as_ctx (#t:limb_t) (h:mem) (k:bn_mont_ctx t) : GTot (S.bn_mont_ctx t) = { S.len = v k.len; S.n = as_seq h (k.n <: lbignum t k.len); S.mu = k.mu; S.r2 = as_seq h (k.r2 <: lbignum t k.len); } inline_for_extraction noextract let bn_mont_ctx_inv (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in live h n /\ live h r2 /\ disjoint n r2 /\ S.bn_mont_ctx_inv (as_ctx h k) inline_for_extraction noextract let bn_v_n (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = let k1 = B.deref h k in let n : lbignum t k1.len = k1.n in bn_v h n inline_for_extraction noextract let freeable_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.freeable n /\ B.freeable r2 inline_for_extraction noextract let freeable (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.freeable k /\ freeable_s h (B.deref h k) inline_for_extraction noextract let footprint_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.(loc_union (loc_addr_of_buffer n) (loc_addr_of_buffer r2)) inline_for_extraction noextract let footprint (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.(loc_union (loc_addr_of_buffer k) (footprint_s h (B.deref h k))) inline_for_extraction noextract let as_pctx (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) : GTot (S.bn_mont_ctx t) = as_ctx h (B.deref h k) inline_for_extraction noextract let pbn_mont_ctx_inv (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.live h k /\ B.(loc_disjoint (loc_addr_of_buffer k) (footprint_s h (B.deref h k))) /\ bn_mont_ctx_inv h (B.deref h k) inline_for_extraction noextract let bn_field_get_len_st (t:limb_t) = k:pbn_mont_ctx t -> Stack (BN.meta_len t) (requires fun h -> pbn_mont_ctx_inv h k) (ensures fun h0 r h1 -> h0 == h1 /\ r == (B.deref h0 k).len /\ v r == S.bn_field_get_len (as_pctx h0 k)) inline_for_extraction noextract val bn_field_get_len: #t:limb_t -> bn_field_get_len_st t inline_for_extraction noextract let bn_field_check_modulus_st (t:limb_t) (len:BN.meta_len t) = n:lbignum t len -> Stack bool (requires fun h -> live h n) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_field_check_modulus (as_seq h0 n)) inline_for_extraction noextract val bn_field_check_modulus: #t:limb_t -> km:BM.mont t -> bn_field_check_modulus_st t km.BM.bn.BN.len inline_for_extraction noextract let bn_field_init_st (t:limb_t) (len:BN.meta_len t) = r:HS.rid -> n:lbignum t len -> ST (pbn_mont_ctx t) (requires fun h -> S.bn_mont_ctx_pre (as_seq h n) /\ live h n /\ ST.is_eternal_region r) (ensures fun h0 res h1 -> B.(modifies loc_none h0 h1) /\ B.(fresh_loc (footprint h1 res) h0 h1) /\ B.(loc_includes (loc_region_only true r) (footprint h1 res)) /\ freeable h1 res /\ (B.deref h1 res).len == len /\ bn_v_n h1 res == bn_v h0 n /\ S.bn_mont_ctx_inv (as_pctx h1 res) /\ as_pctx h1 res == S.bn_field_init (as_seq h0 n)) inline_for_extraction noextract val bn_field_init: #t:limb_t -> len:BN.meta_len t -> precomp_r2:BM.bn_precomp_r2_mod_n_st t len -> bn_field_init_st t len inline_for_extraction noextract let bn_field_free_st (t:limb_t) = k:pbn_mont_ctx t -> ST unit (requires fun h -> freeable h k /\ pbn_mont_ctx_inv h k) (ensures fun h0 _ h1 -> B.(modifies (footprint h0 k) h0 h1)) inline_for_extraction noextract val bn_field_free: #t:limb_t -> bn_field_free_st t inline_for_extraction noextract let bn_to_field_st (t:limb_t) (len:BN.meta_len t) = k:pbn_mont_ctx t -> a:lbignum t len -> aM:lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ live h a /\ live h aM /\ disjoint a aM /\ B.(loc_disjoint (footprint h k) (loc_buffer (a <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc aM) h0 h1 /\ bn_v h1 aM < bn_v_n h0 k /\ as_seq h1 aM == S.bn_to_field (as_pctx h0 k) (as_seq h0 a)) inline_for_extraction noextract val bn_to_field: #t:limb_t -> km:BM.mont t -> bn_to_field_st t km.BM.bn.BN.len inline_for_extraction noextract let bn_from_field_st (t:limb_t) (len:BN.meta_len t) = k:pbn_mont_ctx t -> aM:lbignum t len -> a:lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ bn_v h aM < bn_v_n h k /\ live h a /\ live h aM /\ disjoint a aM /\ B.(loc_disjoint (footprint h k) (loc_buffer (a <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc a) h0 h1 /\ bn_v h1 a < bn_v_n h0 k /\ as_seq h1 a == S.bn_from_field (as_pctx h0 k) (as_seq h0 aM)) inline_for_extraction noextract val bn_from_field: #t:limb_t -> km:BM.mont t -> bn_from_field_st t km.BM.bn.BN.len
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontArithmetic.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.meta_len", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.Bignum.Definitions.lbignum", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.eq2", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__len", "Hacl.Bignum.MontArithmetic.lb", "Hacl.Bignum.MontArithmetic.ll", "LowStar.Monotonic.Buffer.deref", "Hacl.Bignum.MontArithmetic.bn_mont_ctx", "LowStar.Buffer.trivial_preorder", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx_inv", "Prims.b2t", "Prims.op_LessThan", "Hacl.Bignum.Definitions.bn_v", "Hacl.Bignum.MontArithmetic.bn_v_n", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.eq_or_disjoint", "LowStar.Monotonic.Buffer.loc_disjoint", "Hacl.Bignum.MontArithmetic.footprint", "LowStar.Monotonic.Buffer.loc_buffer", "LowStar.Buffer.buffer", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Lib.Sequence.seq", "Prims.l_or", "Prims.nat", "FStar.Seq.Base.length", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx__item__len", "Hacl.Bignum.MontArithmetic.as_pctx", "Hacl.Spec.Bignum.Definitions.bn_v", "Hacl.Spec.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx__item__n", "Lib.Buffer.as_seq", "Hacl.Spec.Bignum.MontArithmetic.bn_field_add" ]
[]
false
false
false
false
true
let bn_field_add_st (t: limb_t) (len: BN.meta_len t) =
k: pbn_mont_ctx t -> aM: lbignum t len -> bM: lbignum t len -> cM: lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ bn_v h aM < bn_v_n h k /\ bn_v h bM < bn_v_n h k /\ live h aM /\ live h bM /\ live h cM /\ eq_or_disjoint aM bM /\ eq_or_disjoint aM cM /\ eq_or_disjoint bM cM /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (bM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (cM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc cM) h0 h1 /\ bn_v h1 cM < bn_v_n h0 k /\ as_seq h1 cM == S.bn_field_add (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM))
false
Hacl.Spec.Montgomery.Lemmas.fst
Hacl.Spec.Montgomery.Lemmas.mont_preconditions_n0
val mont_preconditions_n0: pbits:pos -> n:pos{n > 1} -> mu:nat -> Lemma (requires (1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) (ensures (1 + n * mu) % pow2 pbits == 0)
val mont_preconditions_n0: pbits:pos -> n:pos{n > 1} -> mu:nat -> Lemma (requires (1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) (ensures (1 + n * mu) % pow2 pbits == 0)
let mont_preconditions_n0 pbits n mu = calc (==) { (1 + n * mu) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_plus_distr_r 1 (n * mu) (pow2 pbits) } (1 + n * mu % pow2 pbits) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_mul_distr_l n mu (pow2 pbits) } (1 + n % pow2 pbits * mu % pow2 pbits) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_plus_distr_r 1 (n % pow2 pbits * mu) (pow2 pbits) } (1 + n % pow2 pbits * mu) % pow2 pbits; (==) { assert ((1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) } 0; }; assert ((1 + n * mu) % pow2 pbits == 0)
{ "file_name": "code/bignum/Hacl.Spec.Montgomery.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 41, "end_line": 181, "start_col": 0, "start_line": 169 }
module Hacl.Spec.Montgomery.Lemmas open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators (** https://members.loria.fr/PZimmermann/mca/mca-cup-0.5.9.pdf https://eprint.iacr.org/2011/239.pdf https://eprint.iacr.org/2017/1057.pdf *) #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val eea_pow2_odd_k_lemma_d: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let d = n * k1 / pow2 (a - 1) in d % 2 == (if n * k1 % pow2 a < pow2 (a - 1) then 0 else 1))) let eea_pow2_odd_k_lemma_d a n k1 = let d = n * k1 / pow2 (a - 1) in Math.Lemmas.pow2_modulo_division_lemma_1 (n * k1) (a - 1) a; assert (d % 2 == n * k1 % pow2 a / pow2 (a - 1)); if d % 2 = 0 then begin Math.Lemmas.small_division_lemma_2 (n * k1 % pow2 a) (pow2 (a - 1)); assert (n * k1 % pow2 a < pow2 (a - 1)); () end #push-options "--z3rlimit 100" val eea_pow2_odd_k_lemma: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in n * k % pow2 a == 1)) let eea_pow2_odd_k_lemma a n k1 = let d = n * k1 / pow2 (a - 1) in let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in calc (==) { n * k1; (==) { Math.Lemmas.euclidean_division_definition (n * k1) (pow2 (a - 1)) } 1 + d * pow2 (a - 1); (==) { Math.Lemmas.euclidean_division_definition d 2 } 1 + (d / 2 * 2 + d % 2) * pow2 (a - 1); (==) { Math.Lemmas.distributivity_add_left (d / 2 * 2) (d % 2) (pow2 (a - 1)) } 1 + d / 2 * 2 * pow2 (a - 1) + d % 2 * pow2 (a - 1); (==) { Math.Lemmas.pow2_plus 1 (a - 1) } 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1); }; assert (n * k1 == 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1)); if n * k1 % pow2 a < pow2 (a - 1) then begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 0); calc (==) { n * k % pow2 a; (==) { } (1 + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) (d / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a = 1); () end else begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 1); assert (n * k1 == 1 + d / 2 * pow2 a + pow2 (a - 1)); //assert (n * k == 1 + d / 2 * pow2 a + pow2 (a - 1) + n * pow2 (a - 1)); calc (==) { n * k % pow2 a; (==) { Math.Lemmas.distributivity_add_right n k1 (pow2 (a - 1)) } (n * k1 + n * pow2 (a - 1)) % pow2 a; (==) { } (1 + pow2 (a - 1) + n * pow2 (a - 1) + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma (1 + pow2 (a - 1) + n * pow2 (a - 1)) (pow2 a) (d / 2) } (1 + pow2 (a - 1) + n * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.distributivity_add_left 1 n (pow2 (a - 1)) } (1 + (1 + n) * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.lemma_div_exact (1 + n) 2 } (1 + (1 + n) / 2 * 2 * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.paren_mul_right ((1 + n) / 2) 2 (pow2 (a - 1)) } (1 + (1 + n) / 2 * (2 * pow2 (a - 1))) % pow2 a; (==) { Math.Lemmas.pow2_plus 1 (a - 1)} (1 + (1 + n) / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) ((1 + n) / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a == 1); () end #pop-options val eea_pow2_odd_k_lemma_bound: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1 /\ k1 < pow2 (a - 1)) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in k < pow2 a)) let eea_pow2_odd_k_lemma_bound a n k1 = if n * k1 % pow2 a < pow2 (a - 1) then Math.Lemmas.pow2_lt_compat a (a - 1) else Math.Lemmas.pow2_double_sum (a - 1) val eea_pow2_odd_k: a:pos -> n:pos -> Pure pos (requires n % 2 = 1) (ensures fun k -> n * k % pow2 a == 1 /\ k < pow2 a) let rec eea_pow2_odd_k a n = if a = 1 then 1 else begin let k1 = eea_pow2_odd_k (a - 1) n in assert (n * k1 % pow2 (a - 1) == 1); let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in eea_pow2_odd_k_lemma a n k1; eea_pow2_odd_k_lemma_bound a n k1; assert (n * k % pow2 a == 1); k end val eea_pow2_odd: a:pos -> n:pos -> Pure (tuple2 int int) (requires n % 2 = 1) (ensures fun (d, k) -> pow2 a * d == 1 + k * n /\ - d < n) let eea_pow2_odd a n = let k = eea_pow2_odd_k a n in assert (n * k % pow2 a == 1); assert (n * k == n * k / pow2 a * pow2 a + 1); let d = n * k / pow2 a in Math.Lemmas.lemma_mult_lt_left n k (pow2 a); assert (n * k < n * pow2 a); Math.Lemmas.cancel_mul_div n (pow2 a); assert (d < n); assert (n * k == d * pow2 a + 1); (- d, - k) val mont_preconditions_d: pbits:pos -> rLen:pos -> n:pos{1 < n} -> Lemma (requires n % 2 = 1) (ensures (let d, k = eea_pow2_odd (pbits * rLen) n in pow2 (pbits * rLen) * d % n == 1)) let mont_preconditions_d pbits rLen n = let d, k = eea_pow2_odd (pbits * rLen) n in calc (==) { pow2 (pbits * rLen) * d % n; (==) { } (1 + k * n) % n; (==) { Math.Lemmas.modulo_addition_lemma 1 n k } 1 % n; (==) { Math.Lemmas.small_mod 1 n } 1; }; assert (pow2 (pbits * rLen) * d % n == 1) val mont_preconditions_n0: pbits:pos -> n:pos{n > 1} -> mu:nat -> Lemma (requires (1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) (ensures (1 + n * mu) % pow2 pbits == 0)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Montgomery.Lemmas.fst" }
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
pbits: Prims.pos -> n: Prims.pos{n > 1} -> mu: Prims.nat -> FStar.Pervasives.Lemma (requires (1 + (n % Prims.pow2 pbits) * mu) % Prims.pow2 pbits == 0) (ensures (1 + n * mu) % Prims.pow2 pbits == 0)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.pos", "Prims.b2t", "Prims.op_GreaterThan", "Prims.nat", "Prims._assert", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.pow2", "Prims.unit", "FStar.Calc.calc_finish", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "FStar.Math.Lemmas.lemma_mod_plus_distr_r", "Prims.squash", "FStar.Math.Lemmas.lemma_mod_mul_distr_l" ]
[]
false
false
true
false
false
let mont_preconditions_n0 pbits n mu =
calc ( == ) { (1 + n * mu) % pow2 pbits; ( == ) { Math.Lemmas.lemma_mod_plus_distr_r 1 (n * mu) (pow2 pbits) } (1 + n * mu % pow2 pbits) % pow2 pbits; ( == ) { Math.Lemmas.lemma_mod_mul_distr_l n mu (pow2 pbits) } (1 + (n % pow2 pbits) * mu % pow2 pbits) % pow2 pbits; ( == ) { Math.Lemmas.lemma_mod_plus_distr_r 1 ((n % pow2 pbits) * mu) (pow2 pbits) } (1 + (n % pow2 pbits) * mu) % pow2 pbits; ( == ) { assert ((1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) } 0; }; assert ((1 + n * mu) % pow2 pbits == 0)
false
Hacl.Spec.Montgomery.Lemmas.fst
Hacl.Spec.Montgomery.Lemmas.mont_one
val mont_one: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> nat
val mont_one: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> nat
let mont_one pbits rLen n mu = let r2 = pow2 (2 * pbits * rLen) % n in mont_reduction pbits rLen n mu r2
{ "file_name": "code/bignum/Hacl.Spec.Montgomery.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 35, "end_line": 239, "start_col": 0, "start_line": 237 }
module Hacl.Spec.Montgomery.Lemmas open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators (** https://members.loria.fr/PZimmermann/mca/mca-cup-0.5.9.pdf https://eprint.iacr.org/2011/239.pdf https://eprint.iacr.org/2017/1057.pdf *) #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val eea_pow2_odd_k_lemma_d: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let d = n * k1 / pow2 (a - 1) in d % 2 == (if n * k1 % pow2 a < pow2 (a - 1) then 0 else 1))) let eea_pow2_odd_k_lemma_d a n k1 = let d = n * k1 / pow2 (a - 1) in Math.Lemmas.pow2_modulo_division_lemma_1 (n * k1) (a - 1) a; assert (d % 2 == n * k1 % pow2 a / pow2 (a - 1)); if d % 2 = 0 then begin Math.Lemmas.small_division_lemma_2 (n * k1 % pow2 a) (pow2 (a - 1)); assert (n * k1 % pow2 a < pow2 (a - 1)); () end #push-options "--z3rlimit 100" val eea_pow2_odd_k_lemma: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in n * k % pow2 a == 1)) let eea_pow2_odd_k_lemma a n k1 = let d = n * k1 / pow2 (a - 1) in let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in calc (==) { n * k1; (==) { Math.Lemmas.euclidean_division_definition (n * k1) (pow2 (a - 1)) } 1 + d * pow2 (a - 1); (==) { Math.Lemmas.euclidean_division_definition d 2 } 1 + (d / 2 * 2 + d % 2) * pow2 (a - 1); (==) { Math.Lemmas.distributivity_add_left (d / 2 * 2) (d % 2) (pow2 (a - 1)) } 1 + d / 2 * 2 * pow2 (a - 1) + d % 2 * pow2 (a - 1); (==) { Math.Lemmas.pow2_plus 1 (a - 1) } 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1); }; assert (n * k1 == 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1)); if n * k1 % pow2 a < pow2 (a - 1) then begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 0); calc (==) { n * k % pow2 a; (==) { } (1 + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) (d / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a = 1); () end else begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 1); assert (n * k1 == 1 + d / 2 * pow2 a + pow2 (a - 1)); //assert (n * k == 1 + d / 2 * pow2 a + pow2 (a - 1) + n * pow2 (a - 1)); calc (==) { n * k % pow2 a; (==) { Math.Lemmas.distributivity_add_right n k1 (pow2 (a - 1)) } (n * k1 + n * pow2 (a - 1)) % pow2 a; (==) { } (1 + pow2 (a - 1) + n * pow2 (a - 1) + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma (1 + pow2 (a - 1) + n * pow2 (a - 1)) (pow2 a) (d / 2) } (1 + pow2 (a - 1) + n * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.distributivity_add_left 1 n (pow2 (a - 1)) } (1 + (1 + n) * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.lemma_div_exact (1 + n) 2 } (1 + (1 + n) / 2 * 2 * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.paren_mul_right ((1 + n) / 2) 2 (pow2 (a - 1)) } (1 + (1 + n) / 2 * (2 * pow2 (a - 1))) % pow2 a; (==) { Math.Lemmas.pow2_plus 1 (a - 1)} (1 + (1 + n) / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) ((1 + n) / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a == 1); () end #pop-options val eea_pow2_odd_k_lemma_bound: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1 /\ k1 < pow2 (a - 1)) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in k < pow2 a)) let eea_pow2_odd_k_lemma_bound a n k1 = if n * k1 % pow2 a < pow2 (a - 1) then Math.Lemmas.pow2_lt_compat a (a - 1) else Math.Lemmas.pow2_double_sum (a - 1) val eea_pow2_odd_k: a:pos -> n:pos -> Pure pos (requires n % 2 = 1) (ensures fun k -> n * k % pow2 a == 1 /\ k < pow2 a) let rec eea_pow2_odd_k a n = if a = 1 then 1 else begin let k1 = eea_pow2_odd_k (a - 1) n in assert (n * k1 % pow2 (a - 1) == 1); let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in eea_pow2_odd_k_lemma a n k1; eea_pow2_odd_k_lemma_bound a n k1; assert (n * k % pow2 a == 1); k end val eea_pow2_odd: a:pos -> n:pos -> Pure (tuple2 int int) (requires n % 2 = 1) (ensures fun (d, k) -> pow2 a * d == 1 + k * n /\ - d < n) let eea_pow2_odd a n = let k = eea_pow2_odd_k a n in assert (n * k % pow2 a == 1); assert (n * k == n * k / pow2 a * pow2 a + 1); let d = n * k / pow2 a in Math.Lemmas.lemma_mult_lt_left n k (pow2 a); assert (n * k < n * pow2 a); Math.Lemmas.cancel_mul_div n (pow2 a); assert (d < n); assert (n * k == d * pow2 a + 1); (- d, - k) val mont_preconditions_d: pbits:pos -> rLen:pos -> n:pos{1 < n} -> Lemma (requires n % 2 = 1) (ensures (let d, k = eea_pow2_odd (pbits * rLen) n in pow2 (pbits * rLen) * d % n == 1)) let mont_preconditions_d pbits rLen n = let d, k = eea_pow2_odd (pbits * rLen) n in calc (==) { pow2 (pbits * rLen) * d % n; (==) { } (1 + k * n) % n; (==) { Math.Lemmas.modulo_addition_lemma 1 n k } 1 % n; (==) { Math.Lemmas.small_mod 1 n } 1; }; assert (pow2 (pbits * rLen) * d % n == 1) val mont_preconditions_n0: pbits:pos -> n:pos{n > 1} -> mu:nat -> Lemma (requires (1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) (ensures (1 + n * mu) % pow2 pbits == 0) let mont_preconditions_n0 pbits n mu = calc (==) { (1 + n * mu) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_plus_distr_r 1 (n * mu) (pow2 pbits) } (1 + n * mu % pow2 pbits) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_mul_distr_l n mu (pow2 pbits) } (1 + n % pow2 pbits * mu % pow2 pbits) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_plus_distr_r 1 (n % pow2 pbits * mu) (pow2 pbits) } (1 + n % pow2 pbits * mu) % pow2 pbits; (==) { assert ((1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) } 0; }; assert ((1 + n * mu) % pow2 pbits == 0) val mont_preconditions: pbits:pos -> rLen:pos -> n:pos{1 < n} -> mu:nat -> Lemma (requires n % 2 = 1 /\ (1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) (ensures (let r = pow2 (pbits * rLen) in let d, _ = eea_pow2_odd (pbits * rLen) n in r * d % n == 1 /\ (1 + n * mu) % pow2 pbits == 0)) let mont_preconditions pbits rLen n mu = mont_preconditions_d pbits rLen n; mont_preconditions_n0 pbits n mu /// High-level specification of Montgomery arithmetic val mont_reduction_f: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> i:nat{i < rLen} -> c:nat -> nat let mont_reduction_f pbits rLen n mu i c = let c_i = c / pow2 (pbits * i) % pow2 pbits in let q_i = mu * c_i % pow2 pbits in let res = c + n * q_i * pow2 (pbits * i) in res val mont_reduction_loop_div_r: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> c:nat -> nat let mont_reduction_loop_div_r pbits rLen n mu c = let res = repeati rLen (mont_reduction_f pbits rLen n mu) c in let res = res / pow2 (pbits * rLen) in res val mont_reduction: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> c:nat -> nat let mont_reduction pbits rLen n mu c = let res = mont_reduction_loop_div_r pbits rLen n mu c in if res < n then res else res - n val to_mont: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> a:nat -> nat let to_mont pbits rLen n mu a = let r2 = pow2 (2 * pbits * rLen) % n in let c = a * r2 in mont_reduction pbits rLen n mu c val from_mont: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> aM:nat -> nat let from_mont pbits rLen n mu aM = mont_reduction pbits rLen n mu aM val mont_mul: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> a:nat -> b:nat -> nat let mont_mul pbits rLen n mu a b = let c = a * b in mont_reduction pbits rLen n mu c val mont_sqr: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> a:nat -> nat let mont_sqr pbits rLen n mu a = mont_mul pbits rLen n mu a a
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Montgomery.Lemmas.fst" }
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
pbits: Prims.pos -> rLen: Prims.nat -> n: Prims.pos -> mu: Prims.nat -> Prims.nat
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "Prims.nat", "Hacl.Spec.Montgomery.Lemmas.mont_reduction", "Prims.int", "Prims.op_Modulus", "Prims.pow2", "FStar.Mul.op_Star" ]
[]
false
false
false
true
false
let mont_one pbits rLen n mu =
let r2 = pow2 ((2 * pbits) * rLen) % n in mont_reduction pbits rLen n mu r2
false
Hacl.Bignum.MontArithmetic.fsti
Hacl.Bignum.MontArithmetic.bn_field_init_st
val bn_field_init_st : t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0
let bn_field_init_st (t:limb_t) (len:BN.meta_len t) = r:HS.rid -> n:lbignum t len -> ST (pbn_mont_ctx t) (requires fun h -> S.bn_mont_ctx_pre (as_seq h n) /\ live h n /\ ST.is_eternal_region r) (ensures fun h0 res h1 -> B.(modifies loc_none h0 h1) /\ B.(fresh_loc (footprint h1 res) h0 h1) /\ B.(loc_includes (loc_region_only true r) (footprint h1 res)) /\ freeable h1 res /\ (B.deref h1 res).len == len /\ bn_v_n h1 res == bn_v h0 n /\ S.bn_mont_ctx_inv (as_pctx h1 res) /\ as_pctx h1 res == S.bn_field_init (as_seq h0 n))
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 52, "end_line": 155, "start_col": 0, "start_line": 140 }
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module Euclid = FStar.Math.Euclid module S = Hacl.Spec.Bignum.MontArithmetic module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val _align_fsti : unit inline_for_extraction noextract let lb (t:limb_t) = match t with | U32 -> buffer uint32 | U64 -> buffer uint64 inline_for_extraction noextract let ll (t:limb_t) = match t with | U32 -> uint32 | U64 -> uint64 inline_for_extraction noeq type bn_mont_ctx' (t:limb_t) (a:Type0{a == lb t}) (b:Type0{b == ll t}) = { len: BN.meta_len t; n: x:a{length #MUT #(limb t) x == v len}; mu: b; r2: x:a{length #MUT #(limb t) x == v len}; } inline_for_extraction noextract let bn_mont_ctx (t:limb_t) = bn_mont_ctx' t (lb t) (ll t) let bn_mont_ctx_u32 = bn_mont_ctx' U32 (lb U32) (ll U32) let bn_mont_ctx_u64 = bn_mont_ctx' U64 (lb U64) (ll U64) inline_for_extraction noextract let pbn_mont_ctx (t:limb_t) = B.pointer (bn_mont_ctx t) inline_for_extraction noextract let pbn_mont_ctx_u32 = B.pointer bn_mont_ctx_u32 inline_for_extraction noextract let pbn_mont_ctx_u64 = B.pointer bn_mont_ctx_u64 inline_for_extraction noextract let as_ctx (#t:limb_t) (h:mem) (k:bn_mont_ctx t) : GTot (S.bn_mont_ctx t) = { S.len = v k.len; S.n = as_seq h (k.n <: lbignum t k.len); S.mu = k.mu; S.r2 = as_seq h (k.r2 <: lbignum t k.len); } inline_for_extraction noextract let bn_mont_ctx_inv (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in live h n /\ live h r2 /\ disjoint n r2 /\ S.bn_mont_ctx_inv (as_ctx h k) inline_for_extraction noextract let bn_v_n (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = let k1 = B.deref h k in let n : lbignum t k1.len = k1.n in bn_v h n inline_for_extraction noextract let freeable_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.freeable n /\ B.freeable r2 inline_for_extraction noextract let freeable (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.freeable k /\ freeable_s h (B.deref h k) inline_for_extraction noextract let footprint_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.(loc_union (loc_addr_of_buffer n) (loc_addr_of_buffer r2)) inline_for_extraction noextract let footprint (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.(loc_union (loc_addr_of_buffer k) (footprint_s h (B.deref h k))) inline_for_extraction noextract let as_pctx (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) : GTot (S.bn_mont_ctx t) = as_ctx h (B.deref h k) inline_for_extraction noextract let pbn_mont_ctx_inv (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.live h k /\ B.(loc_disjoint (loc_addr_of_buffer k) (footprint_s h (B.deref h k))) /\ bn_mont_ctx_inv h (B.deref h k) inline_for_extraction noextract let bn_field_get_len_st (t:limb_t) = k:pbn_mont_ctx t -> Stack (BN.meta_len t) (requires fun h -> pbn_mont_ctx_inv h k) (ensures fun h0 r h1 -> h0 == h1 /\ r == (B.deref h0 k).len /\ v r == S.bn_field_get_len (as_pctx h0 k)) inline_for_extraction noextract val bn_field_get_len: #t:limb_t -> bn_field_get_len_st t inline_for_extraction noextract let bn_field_check_modulus_st (t:limb_t) (len:BN.meta_len t) = n:lbignum t len -> Stack bool (requires fun h -> live h n) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_field_check_modulus (as_seq h0 n)) inline_for_extraction noextract val bn_field_check_modulus: #t:limb_t -> km:BM.mont t -> bn_field_check_modulus_st t km.BM.bn.BN.len
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontArithmetic.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.meta_len", "FStar.Monotonic.HyperHeap.rid", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Hacl.Spec.Bignum.MontArithmetic.bn_mont_ctx_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.live", "FStar.HyperStack.ST.is_eternal_region", "LowStar.Monotonic.Buffer.modifies", "LowStar.Monotonic.Buffer.loc_none", "LowStar.Monotonic.Buffer.fresh_loc", "Hacl.Bignum.MontArithmetic.footprint", "LowStar.Monotonic.Buffer.loc_includes", "LowStar.Monotonic.Buffer.loc_region_only", "Hacl.Bignum.MontArithmetic.freeable", "Prims.eq2", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__len", "Hacl.Bignum.MontArithmetic.lb", "Hacl.Bignum.MontArithmetic.ll", "LowStar.Monotonic.Buffer.deref", "Hacl.Bignum.MontArithmetic.bn_mont_ctx", "LowStar.Buffer.trivial_preorder", "Prims.nat", "Hacl.Bignum.MontArithmetic.bn_v_n", "Hacl.Bignum.Definitions.bn_v", "Hacl.Spec.Bignum.MontArithmetic.bn_mont_ctx_inv", "Hacl.Bignum.MontArithmetic.as_pctx", "Hacl.Spec.Bignum.MontArithmetic.bn_mont_ctx", "Hacl.Spec.Bignum.MontArithmetic.bn_field_init" ]
[]
false
false
false
false
true
let bn_field_init_st (t: limb_t) (len: BN.meta_len t) =
r: HS.rid -> n: lbignum t len -> ST (pbn_mont_ctx t) (requires fun h -> S.bn_mont_ctx_pre (as_seq h n) /\ live h n /\ ST.is_eternal_region r) (ensures fun h0 res h1 -> B.(modifies loc_none h0 h1) /\ B.(fresh_loc (footprint h1 res) h0 h1) /\ B.(loc_includes (loc_region_only true r) (footprint h1 res)) /\ freeable h1 res /\ (B.deref h1 res).len == len /\ bn_v_n h1 res == bn_v h0 n /\ S.bn_mont_ctx_inv (as_pctx h1 res) /\ as_pctx h1 res == S.bn_field_init (as_seq h0 n))
false
Hacl.Spec.Montgomery.Lemmas.fst
Hacl.Spec.Montgomery.Lemmas.mont_preconditions_d
val mont_preconditions_d: pbits:pos -> rLen:pos -> n:pos{1 < n} -> Lemma (requires n % 2 = 1) (ensures (let d, k = eea_pow2_odd (pbits * rLen) n in pow2 (pbits * rLen) * d % n == 1))
val mont_preconditions_d: pbits:pos -> rLen:pos -> n:pos{1 < n} -> Lemma (requires n % 2 = 1) (ensures (let d, k = eea_pow2_odd (pbits * rLen) n in pow2 (pbits * rLen) * d % n == 1))
let mont_preconditions_d pbits rLen n = let d, k = eea_pow2_odd (pbits * rLen) n in calc (==) { pow2 (pbits * rLen) * d % n; (==) { } (1 + k * n) % n; (==) { Math.Lemmas.modulo_addition_lemma 1 n k } 1 % n; (==) { Math.Lemmas.small_mod 1 n } 1; }; assert (pow2 (pbits * rLen) * d % n == 1)
{ "file_name": "code/bignum/Hacl.Spec.Montgomery.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 43, "end_line": 162, "start_col": 0, "start_line": 151 }
module Hacl.Spec.Montgomery.Lemmas open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators (** https://members.loria.fr/PZimmermann/mca/mca-cup-0.5.9.pdf https://eprint.iacr.org/2011/239.pdf https://eprint.iacr.org/2017/1057.pdf *) #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val eea_pow2_odd_k_lemma_d: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let d = n * k1 / pow2 (a - 1) in d % 2 == (if n * k1 % pow2 a < pow2 (a - 1) then 0 else 1))) let eea_pow2_odd_k_lemma_d a n k1 = let d = n * k1 / pow2 (a - 1) in Math.Lemmas.pow2_modulo_division_lemma_1 (n * k1) (a - 1) a; assert (d % 2 == n * k1 % pow2 a / pow2 (a - 1)); if d % 2 = 0 then begin Math.Lemmas.small_division_lemma_2 (n * k1 % pow2 a) (pow2 (a - 1)); assert (n * k1 % pow2 a < pow2 (a - 1)); () end #push-options "--z3rlimit 100" val eea_pow2_odd_k_lemma: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in n * k % pow2 a == 1)) let eea_pow2_odd_k_lemma a n k1 = let d = n * k1 / pow2 (a - 1) in let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in calc (==) { n * k1; (==) { Math.Lemmas.euclidean_division_definition (n * k1) (pow2 (a - 1)) } 1 + d * pow2 (a - 1); (==) { Math.Lemmas.euclidean_division_definition d 2 } 1 + (d / 2 * 2 + d % 2) * pow2 (a - 1); (==) { Math.Lemmas.distributivity_add_left (d / 2 * 2) (d % 2) (pow2 (a - 1)) } 1 + d / 2 * 2 * pow2 (a - 1) + d % 2 * pow2 (a - 1); (==) { Math.Lemmas.pow2_plus 1 (a - 1) } 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1); }; assert (n * k1 == 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1)); if n * k1 % pow2 a < pow2 (a - 1) then begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 0); calc (==) { n * k % pow2 a; (==) { } (1 + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) (d / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a = 1); () end else begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 1); assert (n * k1 == 1 + d / 2 * pow2 a + pow2 (a - 1)); //assert (n * k == 1 + d / 2 * pow2 a + pow2 (a - 1) + n * pow2 (a - 1)); calc (==) { n * k % pow2 a; (==) { Math.Lemmas.distributivity_add_right n k1 (pow2 (a - 1)) } (n * k1 + n * pow2 (a - 1)) % pow2 a; (==) { } (1 + pow2 (a - 1) + n * pow2 (a - 1) + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma (1 + pow2 (a - 1) + n * pow2 (a - 1)) (pow2 a) (d / 2) } (1 + pow2 (a - 1) + n * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.distributivity_add_left 1 n (pow2 (a - 1)) } (1 + (1 + n) * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.lemma_div_exact (1 + n) 2 } (1 + (1 + n) / 2 * 2 * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.paren_mul_right ((1 + n) / 2) 2 (pow2 (a - 1)) } (1 + (1 + n) / 2 * (2 * pow2 (a - 1))) % pow2 a; (==) { Math.Lemmas.pow2_plus 1 (a - 1)} (1 + (1 + n) / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) ((1 + n) / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a == 1); () end #pop-options val eea_pow2_odd_k_lemma_bound: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1 /\ k1 < pow2 (a - 1)) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in k < pow2 a)) let eea_pow2_odd_k_lemma_bound a n k1 = if n * k1 % pow2 a < pow2 (a - 1) then Math.Lemmas.pow2_lt_compat a (a - 1) else Math.Lemmas.pow2_double_sum (a - 1) val eea_pow2_odd_k: a:pos -> n:pos -> Pure pos (requires n % 2 = 1) (ensures fun k -> n * k % pow2 a == 1 /\ k < pow2 a) let rec eea_pow2_odd_k a n = if a = 1 then 1 else begin let k1 = eea_pow2_odd_k (a - 1) n in assert (n * k1 % pow2 (a - 1) == 1); let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in eea_pow2_odd_k_lemma a n k1; eea_pow2_odd_k_lemma_bound a n k1; assert (n * k % pow2 a == 1); k end val eea_pow2_odd: a:pos -> n:pos -> Pure (tuple2 int int) (requires n % 2 = 1) (ensures fun (d, k) -> pow2 a * d == 1 + k * n /\ - d < n) let eea_pow2_odd a n = let k = eea_pow2_odd_k a n in assert (n * k % pow2 a == 1); assert (n * k == n * k / pow2 a * pow2 a + 1); let d = n * k / pow2 a in Math.Lemmas.lemma_mult_lt_left n k (pow2 a); assert (n * k < n * pow2 a); Math.Lemmas.cancel_mul_div n (pow2 a); assert (d < n); assert (n * k == d * pow2 a + 1); (- d, - k) val mont_preconditions_d: pbits:pos -> rLen:pos -> n:pos{1 < n} -> Lemma (requires n % 2 = 1) (ensures (let d, k = eea_pow2_odd (pbits * rLen) n in pow2 (pbits * rLen) * d % n == 1))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Montgomery.Lemmas.fst" }
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
pbits: Prims.pos -> rLen: Prims.pos -> n: Prims.pos{1 < n} -> FStar.Pervasives.Lemma (requires n % 2 = 1) (ensures (let _ = Hacl.Spec.Montgomery.Lemmas.eea_pow2_odd (pbits * rLen) n in (let FStar.Pervasives.Native.Mktuple2 #_ #_ d _ = _ in Prims.pow2 (pbits * rLen) * d % n == 1) <: Type0))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.pos", "Prims.b2t", "Prims.op_LessThan", "Prims.int", "Prims._assert", "Prims.eq2", "Prims.op_Modulus", "FStar.Mul.op_Star", "Prims.pow2", "Prims.unit", "FStar.Calc.calc_finish", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "FStar.Calc.calc_step", "Prims.op_Addition", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.squash", "FStar.Math.Lemmas.modulo_addition_lemma", "FStar.Math.Lemmas.small_mod", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Montgomery.Lemmas.eea_pow2_odd" ]
[]
false
false
true
false
false
let mont_preconditions_d pbits rLen n =
let d, k = eea_pow2_odd (pbits * rLen) n in calc ( == ) { pow2 (pbits * rLen) * d % n; ( == ) { () } (1 + k * n) % n; ( == ) { Math.Lemmas.modulo_addition_lemma 1 n k } 1 % n; ( == ) { Math.Lemmas.small_mod 1 n } 1; }; assert (pow2 (pbits * rLen) * d % n == 1)
false
Hacl.Spec.Montgomery.Lemmas.fst
Hacl.Spec.Montgomery.Lemmas.mont_preconditions
val mont_preconditions: pbits:pos -> rLen:pos -> n:pos{1 < n} -> mu:nat -> Lemma (requires n % 2 = 1 /\ (1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) (ensures (let r = pow2 (pbits * rLen) in let d, _ = eea_pow2_odd (pbits * rLen) n in r * d % n == 1 /\ (1 + n * mu) % pow2 pbits == 0))
val mont_preconditions: pbits:pos -> rLen:pos -> n:pos{1 < n} -> mu:nat -> Lemma (requires n % 2 = 1 /\ (1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) (ensures (let r = pow2 (pbits * rLen) in let d, _ = eea_pow2_odd (pbits * rLen) n in r * d % n == 1 /\ (1 + n * mu) % pow2 pbits == 0))
let mont_preconditions pbits rLen n mu = mont_preconditions_d pbits rLen n; mont_preconditions_n0 pbits n mu
{ "file_name": "code/bignum/Hacl.Spec.Montgomery.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 34, "end_line": 194, "start_col": 0, "start_line": 192 }
module Hacl.Spec.Montgomery.Lemmas open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators (** https://members.loria.fr/PZimmermann/mca/mca-cup-0.5.9.pdf https://eprint.iacr.org/2011/239.pdf https://eprint.iacr.org/2017/1057.pdf *) #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val eea_pow2_odd_k_lemma_d: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let d = n * k1 / pow2 (a - 1) in d % 2 == (if n * k1 % pow2 a < pow2 (a - 1) then 0 else 1))) let eea_pow2_odd_k_lemma_d a n k1 = let d = n * k1 / pow2 (a - 1) in Math.Lemmas.pow2_modulo_division_lemma_1 (n * k1) (a - 1) a; assert (d % 2 == n * k1 % pow2 a / pow2 (a - 1)); if d % 2 = 0 then begin Math.Lemmas.small_division_lemma_2 (n * k1 % pow2 a) (pow2 (a - 1)); assert (n * k1 % pow2 a < pow2 (a - 1)); () end #push-options "--z3rlimit 100" val eea_pow2_odd_k_lemma: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in n * k % pow2 a == 1)) let eea_pow2_odd_k_lemma a n k1 = let d = n * k1 / pow2 (a - 1) in let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in calc (==) { n * k1; (==) { Math.Lemmas.euclidean_division_definition (n * k1) (pow2 (a - 1)) } 1 + d * pow2 (a - 1); (==) { Math.Lemmas.euclidean_division_definition d 2 } 1 + (d / 2 * 2 + d % 2) * pow2 (a - 1); (==) { Math.Lemmas.distributivity_add_left (d / 2 * 2) (d % 2) (pow2 (a - 1)) } 1 + d / 2 * 2 * pow2 (a - 1) + d % 2 * pow2 (a - 1); (==) { Math.Lemmas.pow2_plus 1 (a - 1) } 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1); }; assert (n * k1 == 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1)); if n * k1 % pow2 a < pow2 (a - 1) then begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 0); calc (==) { n * k % pow2 a; (==) { } (1 + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) (d / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a = 1); () end else begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 1); assert (n * k1 == 1 + d / 2 * pow2 a + pow2 (a - 1)); //assert (n * k == 1 + d / 2 * pow2 a + pow2 (a - 1) + n * pow2 (a - 1)); calc (==) { n * k % pow2 a; (==) { Math.Lemmas.distributivity_add_right n k1 (pow2 (a - 1)) } (n * k1 + n * pow2 (a - 1)) % pow2 a; (==) { } (1 + pow2 (a - 1) + n * pow2 (a - 1) + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma (1 + pow2 (a - 1) + n * pow2 (a - 1)) (pow2 a) (d / 2) } (1 + pow2 (a - 1) + n * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.distributivity_add_left 1 n (pow2 (a - 1)) } (1 + (1 + n) * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.lemma_div_exact (1 + n) 2 } (1 + (1 + n) / 2 * 2 * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.paren_mul_right ((1 + n) / 2) 2 (pow2 (a - 1)) } (1 + (1 + n) / 2 * (2 * pow2 (a - 1))) % pow2 a; (==) { Math.Lemmas.pow2_plus 1 (a - 1)} (1 + (1 + n) / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) ((1 + n) / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a == 1); () end #pop-options val eea_pow2_odd_k_lemma_bound: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1 /\ k1 < pow2 (a - 1)) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in k < pow2 a)) let eea_pow2_odd_k_lemma_bound a n k1 = if n * k1 % pow2 a < pow2 (a - 1) then Math.Lemmas.pow2_lt_compat a (a - 1) else Math.Lemmas.pow2_double_sum (a - 1) val eea_pow2_odd_k: a:pos -> n:pos -> Pure pos (requires n % 2 = 1) (ensures fun k -> n * k % pow2 a == 1 /\ k < pow2 a) let rec eea_pow2_odd_k a n = if a = 1 then 1 else begin let k1 = eea_pow2_odd_k (a - 1) n in assert (n * k1 % pow2 (a - 1) == 1); let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in eea_pow2_odd_k_lemma a n k1; eea_pow2_odd_k_lemma_bound a n k1; assert (n * k % pow2 a == 1); k end val eea_pow2_odd: a:pos -> n:pos -> Pure (tuple2 int int) (requires n % 2 = 1) (ensures fun (d, k) -> pow2 a * d == 1 + k * n /\ - d < n) let eea_pow2_odd a n = let k = eea_pow2_odd_k a n in assert (n * k % pow2 a == 1); assert (n * k == n * k / pow2 a * pow2 a + 1); let d = n * k / pow2 a in Math.Lemmas.lemma_mult_lt_left n k (pow2 a); assert (n * k < n * pow2 a); Math.Lemmas.cancel_mul_div n (pow2 a); assert (d < n); assert (n * k == d * pow2 a + 1); (- d, - k) val mont_preconditions_d: pbits:pos -> rLen:pos -> n:pos{1 < n} -> Lemma (requires n % 2 = 1) (ensures (let d, k = eea_pow2_odd (pbits * rLen) n in pow2 (pbits * rLen) * d % n == 1)) let mont_preconditions_d pbits rLen n = let d, k = eea_pow2_odd (pbits * rLen) n in calc (==) { pow2 (pbits * rLen) * d % n; (==) { } (1 + k * n) % n; (==) { Math.Lemmas.modulo_addition_lemma 1 n k } 1 % n; (==) { Math.Lemmas.small_mod 1 n } 1; }; assert (pow2 (pbits * rLen) * d % n == 1) val mont_preconditions_n0: pbits:pos -> n:pos{n > 1} -> mu:nat -> Lemma (requires (1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) (ensures (1 + n * mu) % pow2 pbits == 0) let mont_preconditions_n0 pbits n mu = calc (==) { (1 + n * mu) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_plus_distr_r 1 (n * mu) (pow2 pbits) } (1 + n * mu % pow2 pbits) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_mul_distr_l n mu (pow2 pbits) } (1 + n % pow2 pbits * mu % pow2 pbits) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_plus_distr_r 1 (n % pow2 pbits * mu) (pow2 pbits) } (1 + n % pow2 pbits * mu) % pow2 pbits; (==) { assert ((1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) } 0; }; assert ((1 + n * mu) % pow2 pbits == 0) val mont_preconditions: pbits:pos -> rLen:pos -> n:pos{1 < n} -> mu:nat -> Lemma (requires n % 2 = 1 /\ (1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) (ensures (let r = pow2 (pbits * rLen) in let d, _ = eea_pow2_odd (pbits * rLen) n in r * d % n == 1 /\ (1 + n * mu) % pow2 pbits == 0))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Montgomery.Lemmas.fst" }
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
pbits: Prims.pos -> rLen: Prims.pos -> n: Prims.pos{1 < n} -> mu: Prims.nat -> FStar.Pervasives.Lemma (requires n % 2 = 1 /\ (1 + (n % Prims.pow2 pbits) * mu) % Prims.pow2 pbits == 0) (ensures (let r = Prims.pow2 (pbits * rLen) in let _ = Hacl.Spec.Montgomery.Lemmas.eea_pow2_odd (pbits * rLen) n in (let FStar.Pervasives.Native.Mktuple2 #_ #_ d _ = _ in r * d % n == 1 /\ (1 + n * mu) % Prims.pow2 pbits == 0) <: Type0))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.pos", "Prims.b2t", "Prims.op_LessThan", "Prims.nat", "Hacl.Spec.Montgomery.Lemmas.mont_preconditions_n0", "Prims.unit", "Hacl.Spec.Montgomery.Lemmas.mont_preconditions_d" ]
[]
true
false
true
false
false
let mont_preconditions pbits rLen n mu =
mont_preconditions_d pbits rLen n; mont_preconditions_n0 pbits n mu
false
Hacl.Spec.Montgomery.Lemmas.fst
Hacl.Spec.Montgomery.Lemmas.mont_reduction_f
val mont_reduction_f: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> i:nat{i < rLen} -> c:nat -> nat
val mont_reduction_f: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> i:nat{i < rLen} -> c:nat -> nat
let mont_reduction_f pbits rLen n mu i c = let c_i = c / pow2 (pbits * i) % pow2 pbits in let q_i = mu * c_i % pow2 pbits in let res = c + n * q_i * pow2 (pbits * i) in res
{ "file_name": "code/bignum/Hacl.Spec.Montgomery.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 204, "start_col": 0, "start_line": 200 }
module Hacl.Spec.Montgomery.Lemmas open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators (** https://members.loria.fr/PZimmermann/mca/mca-cup-0.5.9.pdf https://eprint.iacr.org/2011/239.pdf https://eprint.iacr.org/2017/1057.pdf *) #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val eea_pow2_odd_k_lemma_d: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let d = n * k1 / pow2 (a - 1) in d % 2 == (if n * k1 % pow2 a < pow2 (a - 1) then 0 else 1))) let eea_pow2_odd_k_lemma_d a n k1 = let d = n * k1 / pow2 (a - 1) in Math.Lemmas.pow2_modulo_division_lemma_1 (n * k1) (a - 1) a; assert (d % 2 == n * k1 % pow2 a / pow2 (a - 1)); if d % 2 = 0 then begin Math.Lemmas.small_division_lemma_2 (n * k1 % pow2 a) (pow2 (a - 1)); assert (n * k1 % pow2 a < pow2 (a - 1)); () end #push-options "--z3rlimit 100" val eea_pow2_odd_k_lemma: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in n * k % pow2 a == 1)) let eea_pow2_odd_k_lemma a n k1 = let d = n * k1 / pow2 (a - 1) in let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in calc (==) { n * k1; (==) { Math.Lemmas.euclidean_division_definition (n * k1) (pow2 (a - 1)) } 1 + d * pow2 (a - 1); (==) { Math.Lemmas.euclidean_division_definition d 2 } 1 + (d / 2 * 2 + d % 2) * pow2 (a - 1); (==) { Math.Lemmas.distributivity_add_left (d / 2 * 2) (d % 2) (pow2 (a - 1)) } 1 + d / 2 * 2 * pow2 (a - 1) + d % 2 * pow2 (a - 1); (==) { Math.Lemmas.pow2_plus 1 (a - 1) } 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1); }; assert (n * k1 == 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1)); if n * k1 % pow2 a < pow2 (a - 1) then begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 0); calc (==) { n * k % pow2 a; (==) { } (1 + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) (d / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a = 1); () end else begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 1); assert (n * k1 == 1 + d / 2 * pow2 a + pow2 (a - 1)); //assert (n * k == 1 + d / 2 * pow2 a + pow2 (a - 1) + n * pow2 (a - 1)); calc (==) { n * k % pow2 a; (==) { Math.Lemmas.distributivity_add_right n k1 (pow2 (a - 1)) } (n * k1 + n * pow2 (a - 1)) % pow2 a; (==) { } (1 + pow2 (a - 1) + n * pow2 (a - 1) + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma (1 + pow2 (a - 1) + n * pow2 (a - 1)) (pow2 a) (d / 2) } (1 + pow2 (a - 1) + n * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.distributivity_add_left 1 n (pow2 (a - 1)) } (1 + (1 + n) * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.lemma_div_exact (1 + n) 2 } (1 + (1 + n) / 2 * 2 * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.paren_mul_right ((1 + n) / 2) 2 (pow2 (a - 1)) } (1 + (1 + n) / 2 * (2 * pow2 (a - 1))) % pow2 a; (==) { Math.Lemmas.pow2_plus 1 (a - 1)} (1 + (1 + n) / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) ((1 + n) / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a == 1); () end #pop-options val eea_pow2_odd_k_lemma_bound: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1 /\ k1 < pow2 (a - 1)) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in k < pow2 a)) let eea_pow2_odd_k_lemma_bound a n k1 = if n * k1 % pow2 a < pow2 (a - 1) then Math.Lemmas.pow2_lt_compat a (a - 1) else Math.Lemmas.pow2_double_sum (a - 1) val eea_pow2_odd_k: a:pos -> n:pos -> Pure pos (requires n % 2 = 1) (ensures fun k -> n * k % pow2 a == 1 /\ k < pow2 a) let rec eea_pow2_odd_k a n = if a = 1 then 1 else begin let k1 = eea_pow2_odd_k (a - 1) n in assert (n * k1 % pow2 (a - 1) == 1); let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in eea_pow2_odd_k_lemma a n k1; eea_pow2_odd_k_lemma_bound a n k1; assert (n * k % pow2 a == 1); k end val eea_pow2_odd: a:pos -> n:pos -> Pure (tuple2 int int) (requires n % 2 = 1) (ensures fun (d, k) -> pow2 a * d == 1 + k * n /\ - d < n) let eea_pow2_odd a n = let k = eea_pow2_odd_k a n in assert (n * k % pow2 a == 1); assert (n * k == n * k / pow2 a * pow2 a + 1); let d = n * k / pow2 a in Math.Lemmas.lemma_mult_lt_left n k (pow2 a); assert (n * k < n * pow2 a); Math.Lemmas.cancel_mul_div n (pow2 a); assert (d < n); assert (n * k == d * pow2 a + 1); (- d, - k) val mont_preconditions_d: pbits:pos -> rLen:pos -> n:pos{1 < n} -> Lemma (requires n % 2 = 1) (ensures (let d, k = eea_pow2_odd (pbits * rLen) n in pow2 (pbits * rLen) * d % n == 1)) let mont_preconditions_d pbits rLen n = let d, k = eea_pow2_odd (pbits * rLen) n in calc (==) { pow2 (pbits * rLen) * d % n; (==) { } (1 + k * n) % n; (==) { Math.Lemmas.modulo_addition_lemma 1 n k } 1 % n; (==) { Math.Lemmas.small_mod 1 n } 1; }; assert (pow2 (pbits * rLen) * d % n == 1) val mont_preconditions_n0: pbits:pos -> n:pos{n > 1} -> mu:nat -> Lemma (requires (1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) (ensures (1 + n * mu) % pow2 pbits == 0) let mont_preconditions_n0 pbits n mu = calc (==) { (1 + n * mu) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_plus_distr_r 1 (n * mu) (pow2 pbits) } (1 + n * mu % pow2 pbits) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_mul_distr_l n mu (pow2 pbits) } (1 + n % pow2 pbits * mu % pow2 pbits) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_plus_distr_r 1 (n % pow2 pbits * mu) (pow2 pbits) } (1 + n % pow2 pbits * mu) % pow2 pbits; (==) { assert ((1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) } 0; }; assert ((1 + n * mu) % pow2 pbits == 0) val mont_preconditions: pbits:pos -> rLen:pos -> n:pos{1 < n} -> mu:nat -> Lemma (requires n % 2 = 1 /\ (1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) (ensures (let r = pow2 (pbits * rLen) in let d, _ = eea_pow2_odd (pbits * rLen) n in r * d % n == 1 /\ (1 + n * mu) % pow2 pbits == 0)) let mont_preconditions pbits rLen n mu = mont_preconditions_d pbits rLen n; mont_preconditions_n0 pbits n mu /// High-level specification of Montgomery arithmetic
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Montgomery.Lemmas.fst" }
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
pbits: Prims.pos -> rLen: Prims.nat -> n: Prims.pos -> mu: Prims.nat -> i: Prims.nat{i < rLen} -> c: Prims.nat -> Prims.nat
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.int", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.pow2", "Prims.op_Modulus", "Prims.op_Division" ]
[]
false
false
false
false
false
let mont_reduction_f pbits rLen n mu i c =
let c_i = c / pow2 (pbits * i) % pow2 pbits in let q_i = mu * c_i % pow2 pbits in let res = c + (n * q_i) * pow2 (pbits * i) in res
false
Hacl.Bignum.MontArithmetic.fsti
Hacl.Bignum.MontArithmetic.bn_field_get_len_st
val bn_field_get_len_st : t: Hacl.Bignum.Definitions.limb_t -> Type0
let bn_field_get_len_st (t:limb_t) = k:pbn_mont_ctx t -> Stack (BN.meta_len t) (requires fun h -> pbn_mont_ctx_inv h k) (ensures fun h0 r h1 -> h0 == h1 /\ r == (B.deref h0 k).len /\ v r == S.bn_field_get_len (as_pctx h0 k))
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 45, "end_line": 120, "start_col": 0, "start_line": 115 }
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module Euclid = FStar.Math.Euclid module S = Hacl.Spec.Bignum.MontArithmetic module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val _align_fsti : unit inline_for_extraction noextract let lb (t:limb_t) = match t with | U32 -> buffer uint32 | U64 -> buffer uint64 inline_for_extraction noextract let ll (t:limb_t) = match t with | U32 -> uint32 | U64 -> uint64 inline_for_extraction noeq type bn_mont_ctx' (t:limb_t) (a:Type0{a == lb t}) (b:Type0{b == ll t}) = { len: BN.meta_len t; n: x:a{length #MUT #(limb t) x == v len}; mu: b; r2: x:a{length #MUT #(limb t) x == v len}; } inline_for_extraction noextract let bn_mont_ctx (t:limb_t) = bn_mont_ctx' t (lb t) (ll t) let bn_mont_ctx_u32 = bn_mont_ctx' U32 (lb U32) (ll U32) let bn_mont_ctx_u64 = bn_mont_ctx' U64 (lb U64) (ll U64) inline_for_extraction noextract let pbn_mont_ctx (t:limb_t) = B.pointer (bn_mont_ctx t) inline_for_extraction noextract let pbn_mont_ctx_u32 = B.pointer bn_mont_ctx_u32 inline_for_extraction noextract let pbn_mont_ctx_u64 = B.pointer bn_mont_ctx_u64 inline_for_extraction noextract let as_ctx (#t:limb_t) (h:mem) (k:bn_mont_ctx t) : GTot (S.bn_mont_ctx t) = { S.len = v k.len; S.n = as_seq h (k.n <: lbignum t k.len); S.mu = k.mu; S.r2 = as_seq h (k.r2 <: lbignum t k.len); } inline_for_extraction noextract let bn_mont_ctx_inv (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in live h n /\ live h r2 /\ disjoint n r2 /\ S.bn_mont_ctx_inv (as_ctx h k) inline_for_extraction noextract let bn_v_n (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = let k1 = B.deref h k in let n : lbignum t k1.len = k1.n in bn_v h n inline_for_extraction noextract let freeable_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.freeable n /\ B.freeable r2 inline_for_extraction noextract let freeable (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.freeable k /\ freeable_s h (B.deref h k) inline_for_extraction noextract let footprint_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.(loc_union (loc_addr_of_buffer n) (loc_addr_of_buffer r2)) inline_for_extraction noextract let footprint (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.(loc_union (loc_addr_of_buffer k) (footprint_s h (B.deref h k))) inline_for_extraction noextract let as_pctx (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) : GTot (S.bn_mont_ctx t) = as_ctx h (B.deref h k) inline_for_extraction noextract let pbn_mont_ctx_inv (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.live h k /\ B.(loc_disjoint (loc_addr_of_buffer k) (footprint_s h (B.deref h k))) /\ bn_mont_ctx_inv h (B.deref h k)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontArithmetic.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Hacl.Bignum.Definitions.limb_t -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.Bignum.meta_len", "FStar.Monotonic.HyperStack.mem", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx_inv", "Prims.l_and", "Prims.eq2", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__len", "Hacl.Bignum.MontArithmetic.lb", "Hacl.Bignum.MontArithmetic.ll", "LowStar.Monotonic.Buffer.deref", "Hacl.Bignum.MontArithmetic.bn_mont_ctx", "LowStar.Buffer.trivial_preorder", "Prims.int", "Prims.l_or", "Prims.b2t", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "FStar.Mul.op_Star", "Lib.IntTypes.bits", "Lib.IntTypes.range", "Lib.IntTypes.U32", "Lib.IntTypes.v", "Lib.IntTypes.PUB", "Hacl.Spec.Bignum.MontArithmetic.bn_field_get_len", "Hacl.Bignum.MontArithmetic.as_pctx" ]
[]
false
false
false
true
true
let bn_field_get_len_st (t: limb_t) =
k: pbn_mont_ctx t -> Stack (BN.meta_len t) (requires fun h -> pbn_mont_ctx_inv h k) (ensures fun h0 r h1 -> h0 == h1 /\ r == (B.deref h0 k).len /\ v r == S.bn_field_get_len (as_pctx h0 k))
false
Hacl.Spec.Montgomery.Lemmas.fst
Hacl.Spec.Montgomery.Lemmas.mont_reduction_loop_div_r
val mont_reduction_loop_div_r: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> c:nat -> nat
val mont_reduction_loop_div_r: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> c:nat -> nat
let mont_reduction_loop_div_r pbits rLen n mu c = let res = repeati rLen (mont_reduction_f pbits rLen n mu) c in let res = res / pow2 (pbits * rLen) in res
{ "file_name": "code/bignum/Hacl.Spec.Montgomery.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 210, "start_col": 0, "start_line": 207 }
module Hacl.Spec.Montgomery.Lemmas open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators (** https://members.loria.fr/PZimmermann/mca/mca-cup-0.5.9.pdf https://eprint.iacr.org/2011/239.pdf https://eprint.iacr.org/2017/1057.pdf *) #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val eea_pow2_odd_k_lemma_d: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let d = n * k1 / pow2 (a - 1) in d % 2 == (if n * k1 % pow2 a < pow2 (a - 1) then 0 else 1))) let eea_pow2_odd_k_lemma_d a n k1 = let d = n * k1 / pow2 (a - 1) in Math.Lemmas.pow2_modulo_division_lemma_1 (n * k1) (a - 1) a; assert (d % 2 == n * k1 % pow2 a / pow2 (a - 1)); if d % 2 = 0 then begin Math.Lemmas.small_division_lemma_2 (n * k1 % pow2 a) (pow2 (a - 1)); assert (n * k1 % pow2 a < pow2 (a - 1)); () end #push-options "--z3rlimit 100" val eea_pow2_odd_k_lemma: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in n * k % pow2 a == 1)) let eea_pow2_odd_k_lemma a n k1 = let d = n * k1 / pow2 (a - 1) in let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in calc (==) { n * k1; (==) { Math.Lemmas.euclidean_division_definition (n * k1) (pow2 (a - 1)) } 1 + d * pow2 (a - 1); (==) { Math.Lemmas.euclidean_division_definition d 2 } 1 + (d / 2 * 2 + d % 2) * pow2 (a - 1); (==) { Math.Lemmas.distributivity_add_left (d / 2 * 2) (d % 2) (pow2 (a - 1)) } 1 + d / 2 * 2 * pow2 (a - 1) + d % 2 * pow2 (a - 1); (==) { Math.Lemmas.pow2_plus 1 (a - 1) } 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1); }; assert (n * k1 == 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1)); if n * k1 % pow2 a < pow2 (a - 1) then begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 0); calc (==) { n * k % pow2 a; (==) { } (1 + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) (d / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a = 1); () end else begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 1); assert (n * k1 == 1 + d / 2 * pow2 a + pow2 (a - 1)); //assert (n * k == 1 + d / 2 * pow2 a + pow2 (a - 1) + n * pow2 (a - 1)); calc (==) { n * k % pow2 a; (==) { Math.Lemmas.distributivity_add_right n k1 (pow2 (a - 1)) } (n * k1 + n * pow2 (a - 1)) % pow2 a; (==) { } (1 + pow2 (a - 1) + n * pow2 (a - 1) + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma (1 + pow2 (a - 1) + n * pow2 (a - 1)) (pow2 a) (d / 2) } (1 + pow2 (a - 1) + n * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.distributivity_add_left 1 n (pow2 (a - 1)) } (1 + (1 + n) * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.lemma_div_exact (1 + n) 2 } (1 + (1 + n) / 2 * 2 * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.paren_mul_right ((1 + n) / 2) 2 (pow2 (a - 1)) } (1 + (1 + n) / 2 * (2 * pow2 (a - 1))) % pow2 a; (==) { Math.Lemmas.pow2_plus 1 (a - 1)} (1 + (1 + n) / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) ((1 + n) / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a == 1); () end #pop-options val eea_pow2_odd_k_lemma_bound: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1 /\ k1 < pow2 (a - 1)) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in k < pow2 a)) let eea_pow2_odd_k_lemma_bound a n k1 = if n * k1 % pow2 a < pow2 (a - 1) then Math.Lemmas.pow2_lt_compat a (a - 1) else Math.Lemmas.pow2_double_sum (a - 1) val eea_pow2_odd_k: a:pos -> n:pos -> Pure pos (requires n % 2 = 1) (ensures fun k -> n * k % pow2 a == 1 /\ k < pow2 a) let rec eea_pow2_odd_k a n = if a = 1 then 1 else begin let k1 = eea_pow2_odd_k (a - 1) n in assert (n * k1 % pow2 (a - 1) == 1); let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in eea_pow2_odd_k_lemma a n k1; eea_pow2_odd_k_lemma_bound a n k1; assert (n * k % pow2 a == 1); k end val eea_pow2_odd: a:pos -> n:pos -> Pure (tuple2 int int) (requires n % 2 = 1) (ensures fun (d, k) -> pow2 a * d == 1 + k * n /\ - d < n) let eea_pow2_odd a n = let k = eea_pow2_odd_k a n in assert (n * k % pow2 a == 1); assert (n * k == n * k / pow2 a * pow2 a + 1); let d = n * k / pow2 a in Math.Lemmas.lemma_mult_lt_left n k (pow2 a); assert (n * k < n * pow2 a); Math.Lemmas.cancel_mul_div n (pow2 a); assert (d < n); assert (n * k == d * pow2 a + 1); (- d, - k) val mont_preconditions_d: pbits:pos -> rLen:pos -> n:pos{1 < n} -> Lemma (requires n % 2 = 1) (ensures (let d, k = eea_pow2_odd (pbits * rLen) n in pow2 (pbits * rLen) * d % n == 1)) let mont_preconditions_d pbits rLen n = let d, k = eea_pow2_odd (pbits * rLen) n in calc (==) { pow2 (pbits * rLen) * d % n; (==) { } (1 + k * n) % n; (==) { Math.Lemmas.modulo_addition_lemma 1 n k } 1 % n; (==) { Math.Lemmas.small_mod 1 n } 1; }; assert (pow2 (pbits * rLen) * d % n == 1) val mont_preconditions_n0: pbits:pos -> n:pos{n > 1} -> mu:nat -> Lemma (requires (1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) (ensures (1 + n * mu) % pow2 pbits == 0) let mont_preconditions_n0 pbits n mu = calc (==) { (1 + n * mu) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_plus_distr_r 1 (n * mu) (pow2 pbits) } (1 + n * mu % pow2 pbits) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_mul_distr_l n mu (pow2 pbits) } (1 + n % pow2 pbits * mu % pow2 pbits) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_plus_distr_r 1 (n % pow2 pbits * mu) (pow2 pbits) } (1 + n % pow2 pbits * mu) % pow2 pbits; (==) { assert ((1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) } 0; }; assert ((1 + n * mu) % pow2 pbits == 0) val mont_preconditions: pbits:pos -> rLen:pos -> n:pos{1 < n} -> mu:nat -> Lemma (requires n % 2 = 1 /\ (1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) (ensures (let r = pow2 (pbits * rLen) in let d, _ = eea_pow2_odd (pbits * rLen) n in r * d % n == 1 /\ (1 + n * mu) % pow2 pbits == 0)) let mont_preconditions pbits rLen n mu = mont_preconditions_d pbits rLen n; mont_preconditions_n0 pbits n mu /// High-level specification of Montgomery arithmetic val mont_reduction_f: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> i:nat{i < rLen} -> c:nat -> nat let mont_reduction_f pbits rLen n mu i c = let c_i = c / pow2 (pbits * i) % pow2 pbits in let q_i = mu * c_i % pow2 pbits in let res = c + n * q_i * pow2 (pbits * i) in res
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Montgomery.Lemmas.fst" }
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
pbits: Prims.pos -> rLen: Prims.nat -> n: Prims.pos -> mu: Prims.nat -> c: Prims.nat -> Prims.nat
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "Prims.nat", "Prims.int", "Prims.op_Division", "Prims.pow2", "FStar.Mul.op_Star", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Lib.LoopCombinators.repeati", "Hacl.Spec.Montgomery.Lemmas.mont_reduction_f" ]
[]
false
false
false
true
false
let mont_reduction_loop_div_r pbits rLen n mu c =
let res = repeati rLen (mont_reduction_f pbits rLen n mu) c in let res = res / pow2 (pbits * rLen) in res
false
Hacl.Spec.Montgomery.Lemmas.fst
Hacl.Spec.Montgomery.Lemmas.mont_mul
val mont_mul: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> a:nat -> b:nat -> nat
val mont_mul: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> a:nat -> b:nat -> nat
let mont_mul pbits rLen n mu a b = let c = a * b in mont_reduction pbits rLen n mu c
{ "file_name": "code/bignum/Hacl.Spec.Montgomery.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 34, "end_line": 230, "start_col": 0, "start_line": 228 }
module Hacl.Spec.Montgomery.Lemmas open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators (** https://members.loria.fr/PZimmermann/mca/mca-cup-0.5.9.pdf https://eprint.iacr.org/2011/239.pdf https://eprint.iacr.org/2017/1057.pdf *) #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val eea_pow2_odd_k_lemma_d: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let d = n * k1 / pow2 (a - 1) in d % 2 == (if n * k1 % pow2 a < pow2 (a - 1) then 0 else 1))) let eea_pow2_odd_k_lemma_d a n k1 = let d = n * k1 / pow2 (a - 1) in Math.Lemmas.pow2_modulo_division_lemma_1 (n * k1) (a - 1) a; assert (d % 2 == n * k1 % pow2 a / pow2 (a - 1)); if d % 2 = 0 then begin Math.Lemmas.small_division_lemma_2 (n * k1 % pow2 a) (pow2 (a - 1)); assert (n * k1 % pow2 a < pow2 (a - 1)); () end #push-options "--z3rlimit 100" val eea_pow2_odd_k_lemma: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in n * k % pow2 a == 1)) let eea_pow2_odd_k_lemma a n k1 = let d = n * k1 / pow2 (a - 1) in let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in calc (==) { n * k1; (==) { Math.Lemmas.euclidean_division_definition (n * k1) (pow2 (a - 1)) } 1 + d * pow2 (a - 1); (==) { Math.Lemmas.euclidean_division_definition d 2 } 1 + (d / 2 * 2 + d % 2) * pow2 (a - 1); (==) { Math.Lemmas.distributivity_add_left (d / 2 * 2) (d % 2) (pow2 (a - 1)) } 1 + d / 2 * 2 * pow2 (a - 1) + d % 2 * pow2 (a - 1); (==) { Math.Lemmas.pow2_plus 1 (a - 1) } 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1); }; assert (n * k1 == 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1)); if n * k1 % pow2 a < pow2 (a - 1) then begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 0); calc (==) { n * k % pow2 a; (==) { } (1 + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) (d / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a = 1); () end else begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 1); assert (n * k1 == 1 + d / 2 * pow2 a + pow2 (a - 1)); //assert (n * k == 1 + d / 2 * pow2 a + pow2 (a - 1) + n * pow2 (a - 1)); calc (==) { n * k % pow2 a; (==) { Math.Lemmas.distributivity_add_right n k1 (pow2 (a - 1)) } (n * k1 + n * pow2 (a - 1)) % pow2 a; (==) { } (1 + pow2 (a - 1) + n * pow2 (a - 1) + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma (1 + pow2 (a - 1) + n * pow2 (a - 1)) (pow2 a) (d / 2) } (1 + pow2 (a - 1) + n * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.distributivity_add_left 1 n (pow2 (a - 1)) } (1 + (1 + n) * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.lemma_div_exact (1 + n) 2 } (1 + (1 + n) / 2 * 2 * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.paren_mul_right ((1 + n) / 2) 2 (pow2 (a - 1)) } (1 + (1 + n) / 2 * (2 * pow2 (a - 1))) % pow2 a; (==) { Math.Lemmas.pow2_plus 1 (a - 1)} (1 + (1 + n) / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) ((1 + n) / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a == 1); () end #pop-options val eea_pow2_odd_k_lemma_bound: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1 /\ k1 < pow2 (a - 1)) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in k < pow2 a)) let eea_pow2_odd_k_lemma_bound a n k1 = if n * k1 % pow2 a < pow2 (a - 1) then Math.Lemmas.pow2_lt_compat a (a - 1) else Math.Lemmas.pow2_double_sum (a - 1) val eea_pow2_odd_k: a:pos -> n:pos -> Pure pos (requires n % 2 = 1) (ensures fun k -> n * k % pow2 a == 1 /\ k < pow2 a) let rec eea_pow2_odd_k a n = if a = 1 then 1 else begin let k1 = eea_pow2_odd_k (a - 1) n in assert (n * k1 % pow2 (a - 1) == 1); let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in eea_pow2_odd_k_lemma a n k1; eea_pow2_odd_k_lemma_bound a n k1; assert (n * k % pow2 a == 1); k end val eea_pow2_odd: a:pos -> n:pos -> Pure (tuple2 int int) (requires n % 2 = 1) (ensures fun (d, k) -> pow2 a * d == 1 + k * n /\ - d < n) let eea_pow2_odd a n = let k = eea_pow2_odd_k a n in assert (n * k % pow2 a == 1); assert (n * k == n * k / pow2 a * pow2 a + 1); let d = n * k / pow2 a in Math.Lemmas.lemma_mult_lt_left n k (pow2 a); assert (n * k < n * pow2 a); Math.Lemmas.cancel_mul_div n (pow2 a); assert (d < n); assert (n * k == d * pow2 a + 1); (- d, - k) val mont_preconditions_d: pbits:pos -> rLen:pos -> n:pos{1 < n} -> Lemma (requires n % 2 = 1) (ensures (let d, k = eea_pow2_odd (pbits * rLen) n in pow2 (pbits * rLen) * d % n == 1)) let mont_preconditions_d pbits rLen n = let d, k = eea_pow2_odd (pbits * rLen) n in calc (==) { pow2 (pbits * rLen) * d % n; (==) { } (1 + k * n) % n; (==) { Math.Lemmas.modulo_addition_lemma 1 n k } 1 % n; (==) { Math.Lemmas.small_mod 1 n } 1; }; assert (pow2 (pbits * rLen) * d % n == 1) val mont_preconditions_n0: pbits:pos -> n:pos{n > 1} -> mu:nat -> Lemma (requires (1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) (ensures (1 + n * mu) % pow2 pbits == 0) let mont_preconditions_n0 pbits n mu = calc (==) { (1 + n * mu) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_plus_distr_r 1 (n * mu) (pow2 pbits) } (1 + n * mu % pow2 pbits) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_mul_distr_l n mu (pow2 pbits) } (1 + n % pow2 pbits * mu % pow2 pbits) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_plus_distr_r 1 (n % pow2 pbits * mu) (pow2 pbits) } (1 + n % pow2 pbits * mu) % pow2 pbits; (==) { assert ((1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) } 0; }; assert ((1 + n * mu) % pow2 pbits == 0) val mont_preconditions: pbits:pos -> rLen:pos -> n:pos{1 < n} -> mu:nat -> Lemma (requires n % 2 = 1 /\ (1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) (ensures (let r = pow2 (pbits * rLen) in let d, _ = eea_pow2_odd (pbits * rLen) n in r * d % n == 1 /\ (1 + n * mu) % pow2 pbits == 0)) let mont_preconditions pbits rLen n mu = mont_preconditions_d pbits rLen n; mont_preconditions_n0 pbits n mu /// High-level specification of Montgomery arithmetic val mont_reduction_f: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> i:nat{i < rLen} -> c:nat -> nat let mont_reduction_f pbits rLen n mu i c = let c_i = c / pow2 (pbits * i) % pow2 pbits in let q_i = mu * c_i % pow2 pbits in let res = c + n * q_i * pow2 (pbits * i) in res val mont_reduction_loop_div_r: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> c:nat -> nat let mont_reduction_loop_div_r pbits rLen n mu c = let res = repeati rLen (mont_reduction_f pbits rLen n mu) c in let res = res / pow2 (pbits * rLen) in res val mont_reduction: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> c:nat -> nat let mont_reduction pbits rLen n mu c = let res = mont_reduction_loop_div_r pbits rLen n mu c in if res < n then res else res - n val to_mont: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> a:nat -> nat let to_mont pbits rLen n mu a = let r2 = pow2 (2 * pbits * rLen) % n in let c = a * r2 in mont_reduction pbits rLen n mu c val from_mont: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> aM:nat -> nat let from_mont pbits rLen n mu aM = mont_reduction pbits rLen n mu aM
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Montgomery.Lemmas.fst" }
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
pbits: Prims.pos -> rLen: Prims.nat -> n: Prims.pos -> mu: Prims.nat -> a: Prims.nat -> b: Prims.nat -> Prims.nat
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "Prims.nat", "Hacl.Spec.Montgomery.Lemmas.mont_reduction", "Prims.int", "FStar.Mul.op_Star" ]
[]
false
false
false
true
false
let mont_mul pbits rLen n mu a b =
let c = a * b in mont_reduction pbits rLen n mu c
false
Hacl.Impl.Frodo.Encode.fst
Hacl.Impl.Frodo.Encode.frodo_key_decode1
val frodo_key_decode1: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b < v logq} -> n:size_t{v n == 8} -> i:size_t{v i < v n} -> templong:uint64 -> res:lbytes (n *! n *! b /. size 8) -> Stack unit (requires fun h -> live h res) (ensures fun h0 _ h1 -> modifies1 res h0 h1 /\ as_seq h1 res == S.frodo_key_decode1 (v logq) (v b) (v n) (v i) templong (as_seq h0 res))
val frodo_key_decode1: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b < v logq} -> n:size_t{v n == 8} -> i:size_t{v i < v n} -> templong:uint64 -> res:lbytes (n *! n *! b /. size 8) -> Stack unit (requires fun h -> live h res) (ensures fun h0 _ h1 -> modifies1 res h0 h1 /\ as_seq h1 res == S.frodo_key_decode1 (v logq) (v b) (v n) (v i) templong (as_seq h0 res))
let frodo_key_decode1 logq b n i templong res = push_frame(); let v8 = create (size 8) (u8 0) in uint_to_bytes_le v8 templong; let tmp = sub v8 (size 0) b in update_sub res (i *! b) b tmp; pop_frame()
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Encode.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 13, "end_line": 156, "start_col": 0, "start_line": 150 }
module Hacl.Impl.Frodo.Encode open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Impl.Matrix module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module S = Spec.Frodo.Encode #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract private val ec: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= v logq} -> k:uint16{v k < pow2 (v b)} -> r:uint16{r == S.ec (v logq) (v b) k} let ec logq b a = a <<. (logq -. b) inline_for_extraction noextract private val dc: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b < v logq} -> c:uint16 -> r:uint16{r == S.dc (v logq) (v b) c} let dc logq b c = let res1 = (c +. (u16 1 <<. (logq -. b -. size 1))) >>. (logq -. b) in res1 &. ((u16 1 <<. b) -. u16 1) inline_for_extraction noextract private val ec1: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b <= v logq} -> x:uint64 -> k:size_t{v k < 8} -> res:uint16{res == S.ec1 (v logq) (v b) x (v k)} let ec1 logq b x k = Spec.Frodo.Lemmas.modulo_pow2_u64 (x >>. (b *! k)) (v b); let rk = (x >>. (b *! k)) &. ((u64 1 <<. b) -. u64 1) in ec logq b (to_u16 rk) inline_for_extraction noextract private val frodo_key_encode1: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b <= v logq} -> n:size_t{v n == 8} -> a:lbytes (n *! n *! b /. size 8) -> i:size_t{v i < v n} -> Stack uint64 (requires fun h -> live h a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.frodo_key_encode1 (v logq) (v b) (v n) (as_seq h0 a) (v i)) let frodo_key_encode1 logq b n a i = let h0 = ST.get() in push_frame(); let v8 = create (size 8) (u8 0) in let chunk = sub a (i *! b) b in let h1 = ST.get() in assert (as_seq h1 chunk == LSeq.sub (as_seq h0 a) (v (i *! b)) (v b)); update_sub v8 (size 0) b chunk; let x = uint_from_bytes_le #U64 v8 in pop_frame(); x inline_for_extraction noextract private val frodo_key_encode2: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b <= v logq} -> n:size_t{v n == 8} -> a:lbytes (n *! n *! b /. size 8) -> i:size_t{v i < v n} -> x:uint64 -> res:matrix_t n n -> Stack unit (requires fun h -> live h a /\ live h res /\ disjoint a res) (ensures fun h0 _ h1 -> modifies1 res h0 h1 /\ as_matrix h1 res == Loops.repeati 8 (S.frodo_key_encode0 (v logq) (v b) (v n) (as_seq h0 a) x (v i)) (as_matrix h0 res)) let frodo_key_encode2 logq b n a i x res = [@ inline_let] let spec h0 = S.frodo_key_encode0 (v logq) (v b) (v n) (as_seq h0 a) x (v i) in let h0 = ST.get () in loop1 h0 (size 8) res spec (fun k -> Loops.unfold_repeati 8 (spec h0) (as_seq h0 res) (v k); mset res i k (ec1 logq b x k) ) val frodo_key_encode: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b <= v logq} -> n:size_t{v n == 8} -> a:lbytes (n *! n *! b /. size 8) -> res:matrix_t n n -> Stack unit (requires fun h -> live h a /\ live h res /\ disjoint a res /\ as_seq h res == Spec.Matrix.create (v n) (v n)) (ensures fun h0 _ h1 -> modifies1 res h0 h1 /\ as_matrix h1 res == S.frodo_key_encode (v logq) (v b) (v n) (as_seq h0 a)) [@"c_inline"] let frodo_key_encode logq b n a res = let h0 = ST.get () in [@ inline_let] let spec h0 = S.frodo_key_encode2 (v logq) (v b) (v n) (as_seq h0 a) in loop1 h0 n res spec (fun i -> Loops.unfold_repeati (v n) (spec h0) (as_seq h0 res) (v i); let x = frodo_key_encode1 logq b n a i in frodo_key_encode2 logq b n a i x res ) inline_for_extraction noextract private val frodo_key_decode1: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b < v logq} -> n:size_t{v n == 8} -> i:size_t{v i < v n} -> templong:uint64 -> res:lbytes (n *! n *! b /. size 8) -> Stack unit (requires fun h -> live h res) (ensures fun h0 _ h1 -> modifies1 res h0 h1 /\ as_seq h1 res == S.frodo_key_decode1 (v logq) (v b) (v n) (v i) templong (as_seq h0 res))
{ "checked_file": "/", "dependencies": [ "Spec.Matrix.fst.checked", "Spec.Frodo.Lemmas.fst.checked", "Spec.Frodo.Encode.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Matrix.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.Frodo.Encode.fst" }
[ { "abbrev": true, "full_module": "Spec.Frodo.Encode", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "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.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
logq: Lib.IntTypes.size_t{0 < Lib.IntTypes.v logq /\ Lib.IntTypes.v logq <= 16} -> b: Lib.IntTypes.size_t {0 < Lib.IntTypes.v b /\ Lib.IntTypes.v b <= 8 /\ Lib.IntTypes.v b < Lib.IntTypes.v logq} -> n: Lib.IntTypes.size_t{Lib.IntTypes.v n == 8} -> i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v n} -> templong: Lib.IntTypes.uint64 -> res: Hacl.Impl.Matrix.lbytes (n *! n *! b /. Lib.IntTypes.size 8) -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "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.eq2", "Prims.int", "Lib.IntTypes.uint64", "Hacl.Impl.Matrix.lbytes", "Lib.IntTypes.op_Slash_Dot", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.size", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Lib.Buffer.update_sub", "Lib.Buffer.MUT", "Lib.IntTypes.uint8", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.sub", "Lib.IntTypes.uint_t", "Lib.ByteBuffer.uint_to_bytes_le", "Lib.IntTypes.U64", "Lib.IntTypes.mk_int", "Lib.Buffer.create", "Lib.IntTypes.u8", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let frodo_key_decode1 logq b n i templong res =
push_frame (); let v8 = create (size 8) (u8 0) in uint_to_bytes_le v8 templong; let tmp = sub v8 (size 0) b in update_sub res (i *! b) b tmp; pop_frame ()
false
Hacl.Bignum.MontArithmetic.fsti
Hacl.Bignum.MontArithmetic.bn_from_field_st
val bn_from_field_st : t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0
let bn_from_field_st (t:limb_t) (len:BN.meta_len t) = k:pbn_mont_ctx t -> aM:lbignum t len -> a:lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ bn_v h aM < bn_v_n h k /\ live h a /\ live h aM /\ disjoint a aM /\ B.(loc_disjoint (footprint h k) (loc_buffer (a <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc a) h0 h1 /\ bn_v h1 a < bn_v_n h0 k /\ as_seq h1 a == S.bn_from_field (as_pctx h0 k) (as_seq h0 aM))
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 65, "end_line": 217, "start_col": 0, "start_line": 203 }
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module Euclid = FStar.Math.Euclid module S = Hacl.Spec.Bignum.MontArithmetic module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val _align_fsti : unit inline_for_extraction noextract let lb (t:limb_t) = match t with | U32 -> buffer uint32 | U64 -> buffer uint64 inline_for_extraction noextract let ll (t:limb_t) = match t with | U32 -> uint32 | U64 -> uint64 inline_for_extraction noeq type bn_mont_ctx' (t:limb_t) (a:Type0{a == lb t}) (b:Type0{b == ll t}) = { len: BN.meta_len t; n: x:a{length #MUT #(limb t) x == v len}; mu: b; r2: x:a{length #MUT #(limb t) x == v len}; } inline_for_extraction noextract let bn_mont_ctx (t:limb_t) = bn_mont_ctx' t (lb t) (ll t) let bn_mont_ctx_u32 = bn_mont_ctx' U32 (lb U32) (ll U32) let bn_mont_ctx_u64 = bn_mont_ctx' U64 (lb U64) (ll U64) inline_for_extraction noextract let pbn_mont_ctx (t:limb_t) = B.pointer (bn_mont_ctx t) inline_for_extraction noextract let pbn_mont_ctx_u32 = B.pointer bn_mont_ctx_u32 inline_for_extraction noextract let pbn_mont_ctx_u64 = B.pointer bn_mont_ctx_u64 inline_for_extraction noextract let as_ctx (#t:limb_t) (h:mem) (k:bn_mont_ctx t) : GTot (S.bn_mont_ctx t) = { S.len = v k.len; S.n = as_seq h (k.n <: lbignum t k.len); S.mu = k.mu; S.r2 = as_seq h (k.r2 <: lbignum t k.len); } inline_for_extraction noextract let bn_mont_ctx_inv (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in live h n /\ live h r2 /\ disjoint n r2 /\ S.bn_mont_ctx_inv (as_ctx h k) inline_for_extraction noextract let bn_v_n (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = let k1 = B.deref h k in let n : lbignum t k1.len = k1.n in bn_v h n inline_for_extraction noextract let freeable_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.freeable n /\ B.freeable r2 inline_for_extraction noextract let freeable (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.freeable k /\ freeable_s h (B.deref h k) inline_for_extraction noextract let footprint_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.(loc_union (loc_addr_of_buffer n) (loc_addr_of_buffer r2)) inline_for_extraction noextract let footprint (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.(loc_union (loc_addr_of_buffer k) (footprint_s h (B.deref h k))) inline_for_extraction noextract let as_pctx (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) : GTot (S.bn_mont_ctx t) = as_ctx h (B.deref h k) inline_for_extraction noextract let pbn_mont_ctx_inv (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.live h k /\ B.(loc_disjoint (loc_addr_of_buffer k) (footprint_s h (B.deref h k))) /\ bn_mont_ctx_inv h (B.deref h k) inline_for_extraction noextract let bn_field_get_len_st (t:limb_t) = k:pbn_mont_ctx t -> Stack (BN.meta_len t) (requires fun h -> pbn_mont_ctx_inv h k) (ensures fun h0 r h1 -> h0 == h1 /\ r == (B.deref h0 k).len /\ v r == S.bn_field_get_len (as_pctx h0 k)) inline_for_extraction noextract val bn_field_get_len: #t:limb_t -> bn_field_get_len_st t inline_for_extraction noextract let bn_field_check_modulus_st (t:limb_t) (len:BN.meta_len t) = n:lbignum t len -> Stack bool (requires fun h -> live h n) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_field_check_modulus (as_seq h0 n)) inline_for_extraction noextract val bn_field_check_modulus: #t:limb_t -> km:BM.mont t -> bn_field_check_modulus_st t km.BM.bn.BN.len inline_for_extraction noextract let bn_field_init_st (t:limb_t) (len:BN.meta_len t) = r:HS.rid -> n:lbignum t len -> ST (pbn_mont_ctx t) (requires fun h -> S.bn_mont_ctx_pre (as_seq h n) /\ live h n /\ ST.is_eternal_region r) (ensures fun h0 res h1 -> B.(modifies loc_none h0 h1) /\ B.(fresh_loc (footprint h1 res) h0 h1) /\ B.(loc_includes (loc_region_only true r) (footprint h1 res)) /\ freeable h1 res /\ (B.deref h1 res).len == len /\ bn_v_n h1 res == bn_v h0 n /\ S.bn_mont_ctx_inv (as_pctx h1 res) /\ as_pctx h1 res == S.bn_field_init (as_seq h0 n)) inline_for_extraction noextract val bn_field_init: #t:limb_t -> len:BN.meta_len t -> precomp_r2:BM.bn_precomp_r2_mod_n_st t len -> bn_field_init_st t len inline_for_extraction noextract let bn_field_free_st (t:limb_t) = k:pbn_mont_ctx t -> ST unit (requires fun h -> freeable h k /\ pbn_mont_ctx_inv h k) (ensures fun h0 _ h1 -> B.(modifies (footprint h0 k) h0 h1)) inline_for_extraction noextract val bn_field_free: #t:limb_t -> bn_field_free_st t inline_for_extraction noextract let bn_to_field_st (t:limb_t) (len:BN.meta_len t) = k:pbn_mont_ctx t -> a:lbignum t len -> aM:lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ live h a /\ live h aM /\ disjoint a aM /\ B.(loc_disjoint (footprint h k) (loc_buffer (a <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc aM) h0 h1 /\ bn_v h1 aM < bn_v_n h0 k /\ as_seq h1 aM == S.bn_to_field (as_pctx h0 k) (as_seq h0 a)) inline_for_extraction noextract val bn_to_field: #t:limb_t -> km:BM.mont t -> bn_to_field_st t km.BM.bn.BN.len
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontArithmetic.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.meta_len", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.Bignum.Definitions.lbignum", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.eq2", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__len", "Hacl.Bignum.MontArithmetic.lb", "Hacl.Bignum.MontArithmetic.ll", "LowStar.Monotonic.Buffer.deref", "Hacl.Bignum.MontArithmetic.bn_mont_ctx", "LowStar.Buffer.trivial_preorder", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx_inv", "Prims.b2t", "Prims.op_LessThan", "Hacl.Bignum.Definitions.bn_v", "Hacl.Bignum.MontArithmetic.bn_v_n", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.disjoint", "LowStar.Monotonic.Buffer.loc_disjoint", "Hacl.Bignum.MontArithmetic.footprint", "LowStar.Monotonic.Buffer.loc_buffer", "LowStar.Buffer.buffer", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Lib.Sequence.seq", "Prims.l_or", "Prims.nat", "FStar.Seq.Base.length", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx__item__len", "Hacl.Bignum.MontArithmetic.as_pctx", "Lib.Buffer.as_seq", "Hacl.Spec.Bignum.MontArithmetic.bn_from_field" ]
[]
false
false
false
false
true
let bn_from_field_st (t: limb_t) (len: BN.meta_len t) =
k: pbn_mont_ctx t -> aM: lbignum t len -> a: lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ bn_v h aM < bn_v_n h k /\ live h a /\ live h aM /\ disjoint a aM /\ B.(loc_disjoint (footprint h k) (loc_buffer (a <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc a) h0 h1 /\ bn_v h1 a < bn_v_n h0 k /\ as_seq h1 a == S.bn_from_field (as_pctx h0 k) (as_seq h0 aM))
false
Hacl.Impl.Frodo.Encode.fst
Hacl.Impl.Frodo.Encode.frodo_key_decode2
val frodo_key_decode2: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b < v logq} -> n:size_t{v n == 8} -> a:matrix_t n n -> i:size_t{v i < v n} -> Stack uint64 (requires fun h -> live h a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == Loops.repeat_gen 8 S.decode_templong_t (S.frodo_key_decode0 (v logq) (v b) (v n) (as_matrix h0 a) (v i)) (u64 0))
val frodo_key_decode2: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b < v logq} -> n:size_t{v n == 8} -> a:matrix_t n n -> i:size_t{v i < v n} -> Stack uint64 (requires fun h -> live h a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == Loops.repeat_gen 8 S.decode_templong_t (S.frodo_key_decode0 (v logq) (v b) (v n) (as_matrix h0 a) (v i)) (u64 0))
let frodo_key_decode2 logq b n a i = push_frame(); let templong = create (size 1) (u64 0) in [@ inline_let] let refl h i : GTot uint64 = bget h templong 0 in [@ inline_let] let footprint i = loc templong in [@ inline_let] let spec h0 = S.frodo_key_decode0 (v logq) (v b) (v n) (as_matrix h0 a) (v i) in let h0 = ST.get () in assert (bget h0 templong 0 == u64 0); loop h0 (size 8) S.decode_templong_t refl footprint spec (fun k -> Loops.unfold_repeat_gen 8 S.decode_templong_t (spec h0) (refl h0 0) (v k); let aik = mget a i k in templong.(size 0) <- templong.(size 0) |. (to_u64 (dc logq b aik) <<. (b *! k)) ); let templong = templong.(size 0) in pop_frame(); templong
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Encode.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 10, "end_line": 191, "start_col": 0, "start_line": 172 }
module Hacl.Impl.Frodo.Encode open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Impl.Matrix module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module S = Spec.Frodo.Encode #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract private val ec: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= v logq} -> k:uint16{v k < pow2 (v b)} -> r:uint16{r == S.ec (v logq) (v b) k} let ec logq b a = a <<. (logq -. b) inline_for_extraction noextract private val dc: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b < v logq} -> c:uint16 -> r:uint16{r == S.dc (v logq) (v b) c} let dc logq b c = let res1 = (c +. (u16 1 <<. (logq -. b -. size 1))) >>. (logq -. b) in res1 &. ((u16 1 <<. b) -. u16 1) inline_for_extraction noextract private val ec1: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b <= v logq} -> x:uint64 -> k:size_t{v k < 8} -> res:uint16{res == S.ec1 (v logq) (v b) x (v k)} let ec1 logq b x k = Spec.Frodo.Lemmas.modulo_pow2_u64 (x >>. (b *! k)) (v b); let rk = (x >>. (b *! k)) &. ((u64 1 <<. b) -. u64 1) in ec logq b (to_u16 rk) inline_for_extraction noextract private val frodo_key_encode1: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b <= v logq} -> n:size_t{v n == 8} -> a:lbytes (n *! n *! b /. size 8) -> i:size_t{v i < v n} -> Stack uint64 (requires fun h -> live h a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.frodo_key_encode1 (v logq) (v b) (v n) (as_seq h0 a) (v i)) let frodo_key_encode1 logq b n a i = let h0 = ST.get() in push_frame(); let v8 = create (size 8) (u8 0) in let chunk = sub a (i *! b) b in let h1 = ST.get() in assert (as_seq h1 chunk == LSeq.sub (as_seq h0 a) (v (i *! b)) (v b)); update_sub v8 (size 0) b chunk; let x = uint_from_bytes_le #U64 v8 in pop_frame(); x inline_for_extraction noextract private val frodo_key_encode2: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b <= v logq} -> n:size_t{v n == 8} -> a:lbytes (n *! n *! b /. size 8) -> i:size_t{v i < v n} -> x:uint64 -> res:matrix_t n n -> Stack unit (requires fun h -> live h a /\ live h res /\ disjoint a res) (ensures fun h0 _ h1 -> modifies1 res h0 h1 /\ as_matrix h1 res == Loops.repeati 8 (S.frodo_key_encode0 (v logq) (v b) (v n) (as_seq h0 a) x (v i)) (as_matrix h0 res)) let frodo_key_encode2 logq b n a i x res = [@ inline_let] let spec h0 = S.frodo_key_encode0 (v logq) (v b) (v n) (as_seq h0 a) x (v i) in let h0 = ST.get () in loop1 h0 (size 8) res spec (fun k -> Loops.unfold_repeati 8 (spec h0) (as_seq h0 res) (v k); mset res i k (ec1 logq b x k) ) val frodo_key_encode: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b <= v logq} -> n:size_t{v n == 8} -> a:lbytes (n *! n *! b /. size 8) -> res:matrix_t n n -> Stack unit (requires fun h -> live h a /\ live h res /\ disjoint a res /\ as_seq h res == Spec.Matrix.create (v n) (v n)) (ensures fun h0 _ h1 -> modifies1 res h0 h1 /\ as_matrix h1 res == S.frodo_key_encode (v logq) (v b) (v n) (as_seq h0 a)) [@"c_inline"] let frodo_key_encode logq b n a res = let h0 = ST.get () in [@ inline_let] let spec h0 = S.frodo_key_encode2 (v logq) (v b) (v n) (as_seq h0 a) in loop1 h0 n res spec (fun i -> Loops.unfold_repeati (v n) (spec h0) (as_seq h0 res) (v i); let x = frodo_key_encode1 logq b n a i in frodo_key_encode2 logq b n a i x res ) inline_for_extraction noextract private val frodo_key_decode1: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b < v logq} -> n:size_t{v n == 8} -> i:size_t{v i < v n} -> templong:uint64 -> res:lbytes (n *! n *! b /. size 8) -> Stack unit (requires fun h -> live h res) (ensures fun h0 _ h1 -> modifies1 res h0 h1 /\ as_seq h1 res == S.frodo_key_decode1 (v logq) (v b) (v n) (v i) templong (as_seq h0 res)) let frodo_key_decode1 logq b n i templong res = push_frame(); let v8 = create (size 8) (u8 0) in uint_to_bytes_le v8 templong; let tmp = sub v8 (size 0) b in update_sub res (i *! b) b tmp; pop_frame() inline_for_extraction noextract private val frodo_key_decode2: logq:size_t{0 < v logq /\ v logq <= 16} -> b:size_t{0 < v b /\ v b <= 8 /\ v b < v logq} -> n:size_t{v n == 8} -> a:matrix_t n n -> i:size_t{v i < v n} -> Stack uint64 (requires fun h -> live h a) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == Loops.repeat_gen 8 S.decode_templong_t (S.frodo_key_decode0 (v logq) (v b) (v n) (as_matrix h0 a) (v i)) (u64 0))
{ "checked_file": "/", "dependencies": [ "Spec.Matrix.fst.checked", "Spec.Frodo.Lemmas.fst.checked", "Spec.Frodo.Encode.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Matrix.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.Frodo.Encode.fst" }
[ { "abbrev": true, "full_module": "Spec.Frodo.Encode", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "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.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
logq: Lib.IntTypes.size_t{0 < Lib.IntTypes.v logq /\ Lib.IntTypes.v logq <= 16} -> b: Lib.IntTypes.size_t {0 < Lib.IntTypes.v b /\ Lib.IntTypes.v b <= 8 /\ Lib.IntTypes.v b < Lib.IntTypes.v logq} -> n: Lib.IntTypes.size_t{Lib.IntTypes.v n == 8} -> a: Hacl.Impl.Matrix.matrix_t n n -> i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v n} -> FStar.HyperStack.ST.Stack Lib.IntTypes.uint64
FStar.HyperStack.ST.Stack
[]
[]
[ "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.eq2", "Prims.int", "Hacl.Impl.Matrix.matrix_t", "Lib.IntTypes.uint64", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT", "Lib.IntTypes.size", "Lib.Buffer.loop", "Spec.Frodo.Encode.decode_templong_t", "Lib.Buffer.op_Array_Assignment", "Lib.IntTypes.op_Bar_Dot", "Lib.IntTypes.op_Less_Less_Dot", "Lib.IntTypes.to_u64", "Lib.IntTypes.U16", "Hacl.Impl.Frodo.Encode.dc", "Lib.IntTypes.op_Star_Bang", "Hacl.Impl.Matrix.mget", "Hacl.Impl.Matrix.elem", "Lib.LoopCombinators.unfold_repeat_gen", "Prims._assert", "Lib.Buffer.bget", "Lib.IntTypes.u64", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Prims.nat", "Prims.op_Subtraction", "Prims.pow2", "Spec.Frodo.Encode.frodo_key_decode0", "Hacl.Impl.Matrix.as_matrix", "Lib.IntTypes.mk_int", "LowStar.Monotonic.Buffer.loc", "Lib.IntTypes.size_nat", "Lib.Buffer.loc", "Lib.Buffer.lbuffer_t", "Lib.Buffer.create", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let frodo_key_decode2 logq b n a i =
push_frame (); let templong = create (size 1) (u64 0) in [@@ inline_let ]let refl h i : GTot uint64 = bget h templong 0 in [@@ inline_let ]let footprint i = loc templong in [@@ inline_let ]let spec h0 = S.frodo_key_decode0 (v logq) (v b) (v n) (as_matrix h0 a) (v i) in let h0 = ST.get () in assert (bget h0 templong 0 == u64 0); loop h0 (size 8) S.decode_templong_t refl footprint spec (fun k -> Loops.unfold_repeat_gen 8 S.decode_templong_t (spec h0) (refl h0 0) (v k); let aik = mget a i k in templong.(size 0) <- templong.(size 0) |. (to_u64 (dc logq b aik) <<. (b *! k))); let templong = templong.(size 0) in pop_frame (); templong
false
Hacl.Bignum.MontArithmetic.fsti
Hacl.Bignum.MontArithmetic.bn_field_sub_st
val bn_field_sub_st : t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0
let bn_field_sub_st (t:limb_t) (len:BN.meta_len t) = k:pbn_mont_ctx t -> aM:lbignum t len -> bM:lbignum t len -> cM:lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ bn_v h aM < bn_v_n h k /\ bn_v h bM < bn_v_n h k /\ live h aM /\ live h bM /\ live h cM /\ eq_or_disjoint aM bM /\ eq_or_disjoint aM cM /\ eq_or_disjoint bM cM /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (bM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (cM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc cM) h0 h1 /\ bn_v h1 cM < bn_v_n h0 k /\ as_seq h1 cM == S.bn_field_sub (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM))
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 80, "end_line": 271, "start_col": 0, "start_line": 252 }
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module Euclid = FStar.Math.Euclid module S = Hacl.Spec.Bignum.MontArithmetic module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val _align_fsti : unit inline_for_extraction noextract let lb (t:limb_t) = match t with | U32 -> buffer uint32 | U64 -> buffer uint64 inline_for_extraction noextract let ll (t:limb_t) = match t with | U32 -> uint32 | U64 -> uint64 inline_for_extraction noeq type bn_mont_ctx' (t:limb_t) (a:Type0{a == lb t}) (b:Type0{b == ll t}) = { len: BN.meta_len t; n: x:a{length #MUT #(limb t) x == v len}; mu: b; r2: x:a{length #MUT #(limb t) x == v len}; } inline_for_extraction noextract let bn_mont_ctx (t:limb_t) = bn_mont_ctx' t (lb t) (ll t) let bn_mont_ctx_u32 = bn_mont_ctx' U32 (lb U32) (ll U32) let bn_mont_ctx_u64 = bn_mont_ctx' U64 (lb U64) (ll U64) inline_for_extraction noextract let pbn_mont_ctx (t:limb_t) = B.pointer (bn_mont_ctx t) inline_for_extraction noextract let pbn_mont_ctx_u32 = B.pointer bn_mont_ctx_u32 inline_for_extraction noextract let pbn_mont_ctx_u64 = B.pointer bn_mont_ctx_u64 inline_for_extraction noextract let as_ctx (#t:limb_t) (h:mem) (k:bn_mont_ctx t) : GTot (S.bn_mont_ctx t) = { S.len = v k.len; S.n = as_seq h (k.n <: lbignum t k.len); S.mu = k.mu; S.r2 = as_seq h (k.r2 <: lbignum t k.len); } inline_for_extraction noextract let bn_mont_ctx_inv (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in live h n /\ live h r2 /\ disjoint n r2 /\ S.bn_mont_ctx_inv (as_ctx h k) inline_for_extraction noextract let bn_v_n (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = let k1 = B.deref h k in let n : lbignum t k1.len = k1.n in bn_v h n inline_for_extraction noextract let freeable_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.freeable n /\ B.freeable r2 inline_for_extraction noextract let freeable (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.freeable k /\ freeable_s h (B.deref h k) inline_for_extraction noextract let footprint_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.(loc_union (loc_addr_of_buffer n) (loc_addr_of_buffer r2)) inline_for_extraction noextract let footprint (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.(loc_union (loc_addr_of_buffer k) (footprint_s h (B.deref h k))) inline_for_extraction noextract let as_pctx (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) : GTot (S.bn_mont_ctx t) = as_ctx h (B.deref h k) inline_for_extraction noextract let pbn_mont_ctx_inv (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.live h k /\ B.(loc_disjoint (loc_addr_of_buffer k) (footprint_s h (B.deref h k))) /\ bn_mont_ctx_inv h (B.deref h k) inline_for_extraction noextract let bn_field_get_len_st (t:limb_t) = k:pbn_mont_ctx t -> Stack (BN.meta_len t) (requires fun h -> pbn_mont_ctx_inv h k) (ensures fun h0 r h1 -> h0 == h1 /\ r == (B.deref h0 k).len /\ v r == S.bn_field_get_len (as_pctx h0 k)) inline_for_extraction noextract val bn_field_get_len: #t:limb_t -> bn_field_get_len_st t inline_for_extraction noextract let bn_field_check_modulus_st (t:limb_t) (len:BN.meta_len t) = n:lbignum t len -> Stack bool (requires fun h -> live h n) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_field_check_modulus (as_seq h0 n)) inline_for_extraction noextract val bn_field_check_modulus: #t:limb_t -> km:BM.mont t -> bn_field_check_modulus_st t km.BM.bn.BN.len inline_for_extraction noextract let bn_field_init_st (t:limb_t) (len:BN.meta_len t) = r:HS.rid -> n:lbignum t len -> ST (pbn_mont_ctx t) (requires fun h -> S.bn_mont_ctx_pre (as_seq h n) /\ live h n /\ ST.is_eternal_region r) (ensures fun h0 res h1 -> B.(modifies loc_none h0 h1) /\ B.(fresh_loc (footprint h1 res) h0 h1) /\ B.(loc_includes (loc_region_only true r) (footprint h1 res)) /\ freeable h1 res /\ (B.deref h1 res).len == len /\ bn_v_n h1 res == bn_v h0 n /\ S.bn_mont_ctx_inv (as_pctx h1 res) /\ as_pctx h1 res == S.bn_field_init (as_seq h0 n)) inline_for_extraction noextract val bn_field_init: #t:limb_t -> len:BN.meta_len t -> precomp_r2:BM.bn_precomp_r2_mod_n_st t len -> bn_field_init_st t len inline_for_extraction noextract let bn_field_free_st (t:limb_t) = k:pbn_mont_ctx t -> ST unit (requires fun h -> freeable h k /\ pbn_mont_ctx_inv h k) (ensures fun h0 _ h1 -> B.(modifies (footprint h0 k) h0 h1)) inline_for_extraction noextract val bn_field_free: #t:limb_t -> bn_field_free_st t inline_for_extraction noextract let bn_to_field_st (t:limb_t) (len:BN.meta_len t) = k:pbn_mont_ctx t -> a:lbignum t len -> aM:lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ live h a /\ live h aM /\ disjoint a aM /\ B.(loc_disjoint (footprint h k) (loc_buffer (a <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc aM) h0 h1 /\ bn_v h1 aM < bn_v_n h0 k /\ as_seq h1 aM == S.bn_to_field (as_pctx h0 k) (as_seq h0 a)) inline_for_extraction noextract val bn_to_field: #t:limb_t -> km:BM.mont t -> bn_to_field_st t km.BM.bn.BN.len inline_for_extraction noextract let bn_from_field_st (t:limb_t) (len:BN.meta_len t) = k:pbn_mont_ctx t -> aM:lbignum t len -> a:lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ bn_v h aM < bn_v_n h k /\ live h a /\ live h aM /\ disjoint a aM /\ B.(loc_disjoint (footprint h k) (loc_buffer (a <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc a) h0 h1 /\ bn_v h1 a < bn_v_n h0 k /\ as_seq h1 a == S.bn_from_field (as_pctx h0 k) (as_seq h0 aM)) inline_for_extraction noextract val bn_from_field: #t:limb_t -> km:BM.mont t -> bn_from_field_st t km.BM.bn.BN.len inline_for_extraction noextract let bn_field_add_st (t:limb_t) (len:BN.meta_len t) = k:pbn_mont_ctx t -> aM:lbignum t len -> bM:lbignum t len -> cM:lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ bn_v h aM < bn_v_n h k /\ bn_v h bM < bn_v_n h k /\ live h aM /\ live h bM /\ live h cM /\ eq_or_disjoint aM bM /\ eq_or_disjoint aM cM /\ eq_or_disjoint bM cM /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (bM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (cM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc cM) h0 h1 /\ bn_v h1 cM < bn_v_n h0 k /\ as_seq h1 cM == S.bn_field_add (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM)) inline_for_extraction noextract val bn_field_add: #t:limb_t -> km:BM.mont t -> bn_field_add_st t km.BM.bn.BN.len
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontArithmetic.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.meta_len", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.Bignum.Definitions.lbignum", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.eq2", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__len", "Hacl.Bignum.MontArithmetic.lb", "Hacl.Bignum.MontArithmetic.ll", "LowStar.Monotonic.Buffer.deref", "Hacl.Bignum.MontArithmetic.bn_mont_ctx", "LowStar.Buffer.trivial_preorder", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx_inv", "Prims.b2t", "Prims.op_LessThan", "Hacl.Bignum.Definitions.bn_v", "Hacl.Bignum.MontArithmetic.bn_v_n", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.eq_or_disjoint", "LowStar.Monotonic.Buffer.loc_disjoint", "Hacl.Bignum.MontArithmetic.footprint", "LowStar.Monotonic.Buffer.loc_buffer", "LowStar.Buffer.buffer", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Lib.Sequence.seq", "Prims.l_or", "Prims.nat", "FStar.Seq.Base.length", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx__item__len", "Hacl.Bignum.MontArithmetic.as_pctx", "Hacl.Spec.Bignum.Definitions.bn_v", "Hacl.Spec.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx__item__n", "Lib.Buffer.as_seq", "Hacl.Spec.Bignum.MontArithmetic.bn_field_sub" ]
[]
false
false
false
false
true
let bn_field_sub_st (t: limb_t) (len: BN.meta_len t) =
k: pbn_mont_ctx t -> aM: lbignum t len -> bM: lbignum t len -> cM: lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ bn_v h aM < bn_v_n h k /\ bn_v h bM < bn_v_n h k /\ live h aM /\ live h bM /\ live h cM /\ eq_or_disjoint aM bM /\ eq_or_disjoint aM cM /\ eq_or_disjoint bM cM /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (bM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (cM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc cM) h0 h1 /\ bn_v h1 cM < bn_v_n h0 k /\ as_seq h1 cM == S.bn_field_sub (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM))
false
Hacl.Spec.Montgomery.Lemmas.fst
Hacl.Spec.Montgomery.Lemmas.eea_pow2_odd_k
val eea_pow2_odd_k: a:pos -> n:pos -> Pure pos (requires n % 2 = 1) (ensures fun k -> n * k % pow2 a == 1 /\ k < pow2 a)
val eea_pow2_odd_k: a:pos -> n:pos -> Pure pos (requires n % 2 = 1) (ensures fun k -> n * k % pow2 a == 1 /\ k < pow2 a)
let rec eea_pow2_odd_k a n = if a = 1 then 1 else begin let k1 = eea_pow2_odd_k (a - 1) n in assert (n * k1 % pow2 (a - 1) == 1); let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in eea_pow2_odd_k_lemma a n k1; eea_pow2_odd_k_lemma_bound a n k1; assert (n * k % pow2 a == 1); k end
{ "file_name": "code/bignum/Hacl.Spec.Montgomery.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 9, "end_line": 125, "start_col": 0, "start_line": 116 }
module Hacl.Spec.Montgomery.Lemmas open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators (** https://members.loria.fr/PZimmermann/mca/mca-cup-0.5.9.pdf https://eprint.iacr.org/2011/239.pdf https://eprint.iacr.org/2017/1057.pdf *) #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val eea_pow2_odd_k_lemma_d: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let d = n * k1 / pow2 (a - 1) in d % 2 == (if n * k1 % pow2 a < pow2 (a - 1) then 0 else 1))) let eea_pow2_odd_k_lemma_d a n k1 = let d = n * k1 / pow2 (a - 1) in Math.Lemmas.pow2_modulo_division_lemma_1 (n * k1) (a - 1) a; assert (d % 2 == n * k1 % pow2 a / pow2 (a - 1)); if d % 2 = 0 then begin Math.Lemmas.small_division_lemma_2 (n * k1 % pow2 a) (pow2 (a - 1)); assert (n * k1 % pow2 a < pow2 (a - 1)); () end #push-options "--z3rlimit 100" val eea_pow2_odd_k_lemma: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in n * k % pow2 a == 1)) let eea_pow2_odd_k_lemma a n k1 = let d = n * k1 / pow2 (a - 1) in let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in calc (==) { n * k1; (==) { Math.Lemmas.euclidean_division_definition (n * k1) (pow2 (a - 1)) } 1 + d * pow2 (a - 1); (==) { Math.Lemmas.euclidean_division_definition d 2 } 1 + (d / 2 * 2 + d % 2) * pow2 (a - 1); (==) { Math.Lemmas.distributivity_add_left (d / 2 * 2) (d % 2) (pow2 (a - 1)) } 1 + d / 2 * 2 * pow2 (a - 1) + d % 2 * pow2 (a - 1); (==) { Math.Lemmas.pow2_plus 1 (a - 1) } 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1); }; assert (n * k1 == 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1)); if n * k1 % pow2 a < pow2 (a - 1) then begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 0); calc (==) { n * k % pow2 a; (==) { } (1 + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) (d / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a = 1); () end else begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 1); assert (n * k1 == 1 + d / 2 * pow2 a + pow2 (a - 1)); //assert (n * k == 1 + d / 2 * pow2 a + pow2 (a - 1) + n * pow2 (a - 1)); calc (==) { n * k % pow2 a; (==) { Math.Lemmas.distributivity_add_right n k1 (pow2 (a - 1)) } (n * k1 + n * pow2 (a - 1)) % pow2 a; (==) { } (1 + pow2 (a - 1) + n * pow2 (a - 1) + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma (1 + pow2 (a - 1) + n * pow2 (a - 1)) (pow2 a) (d / 2) } (1 + pow2 (a - 1) + n * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.distributivity_add_left 1 n (pow2 (a - 1)) } (1 + (1 + n) * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.lemma_div_exact (1 + n) 2 } (1 + (1 + n) / 2 * 2 * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.paren_mul_right ((1 + n) / 2) 2 (pow2 (a - 1)) } (1 + (1 + n) / 2 * (2 * pow2 (a - 1))) % pow2 a; (==) { Math.Lemmas.pow2_plus 1 (a - 1)} (1 + (1 + n) / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) ((1 + n) / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a == 1); () end #pop-options val eea_pow2_odd_k_lemma_bound: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1 /\ k1 < pow2 (a - 1)) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in k < pow2 a)) let eea_pow2_odd_k_lemma_bound a n k1 = if n * k1 % pow2 a < pow2 (a - 1) then Math.Lemmas.pow2_lt_compat a (a - 1) else Math.Lemmas.pow2_double_sum (a - 1) val eea_pow2_odd_k: a:pos -> n:pos -> Pure pos (requires n % 2 = 1) (ensures fun k -> n * k % pow2 a == 1 /\ k < pow2 a)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Montgomery.Lemmas.fst" }
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: Prims.pos -> n: Prims.pos -> Prims.Pure Prims.pos
Prims.Pure
[]
[]
[ "Prims.pos", "Prims.op_Equality", "Prims.int", "Prims.bool", "Prims.unit", "Prims._assert", "Prims.eq2", "Prims.op_Modulus", "FStar.Mul.op_Star", "Prims.pow2", "Hacl.Spec.Montgomery.Lemmas.eea_pow2_odd_k_lemma_bound", "Hacl.Spec.Montgomery.Lemmas.eea_pow2_odd_k_lemma", "Prims.b2t", "Prims.op_GreaterThan", "Prims.op_LessThan", "Prims.op_Subtraction", "Prims.op_Addition", "Hacl.Spec.Montgomery.Lemmas.eea_pow2_odd_k" ]
[ "recursion" ]
false
false
false
false
false
let rec eea_pow2_odd_k a n =
if a = 1 then 1 else let k1 = eea_pow2_odd_k (a - 1) n in assert (n * k1 % pow2 (a - 1) == 1); let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in eea_pow2_odd_k_lemma a n k1; eea_pow2_odd_k_lemma_bound a n k1; assert (n * k % pow2 a == 1); k
false
Hacl.Spec.Montgomery.Lemmas.fst
Hacl.Spec.Montgomery.Lemmas.mont_reduction_lemma_step_modr
val mont_reduction_lemma_step_modr: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> i:pos{i <= rLen} -> res0:nat -> Lemma (requires res0 % pow2 (pbits * (i - 1)) == 0 /\ (1 + n * mu) % pow2 pbits == 0) (ensures mont_reduction_f pbits rLen n mu (i - 1) res0 % pow2 (pbits * i) == 0)
val mont_reduction_lemma_step_modr: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> i:pos{i <= rLen} -> res0:nat -> Lemma (requires res0 % pow2 (pbits * (i - 1)) == 0 /\ (1 + n * mu) % pow2 pbits == 0) (ensures mont_reduction_f pbits rLen n mu (i - 1) res0 % pow2 (pbits * i) == 0)
let mont_reduction_lemma_step_modr pbits rLen n mu i res0 = let b1 = pow2 (pbits * (i - 1)) in let res = mont_reduction_f pbits rLen n mu (i - 1) res0 in let c_i = res0 / b1 % pow2 pbits in let q_i = mu * c_i % pow2 pbits in Math.Lemmas.lemma_div_exact res0 b1; mont_reduction_lemma_step_modr_aux pbits n q_i i res0; mont_reduction_lemma_step_mod_pbits pbits n mu c_i
{ "file_name": "code/bignum/Hacl.Spec.Montgomery.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 52, "end_line": 351, "start_col": 0, "start_line": 343 }
module Hacl.Spec.Montgomery.Lemmas open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators (** https://members.loria.fr/PZimmermann/mca/mca-cup-0.5.9.pdf https://eprint.iacr.org/2011/239.pdf https://eprint.iacr.org/2017/1057.pdf *) #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val eea_pow2_odd_k_lemma_d: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let d = n * k1 / pow2 (a - 1) in d % 2 == (if n * k1 % pow2 a < pow2 (a - 1) then 0 else 1))) let eea_pow2_odd_k_lemma_d a n k1 = let d = n * k1 / pow2 (a - 1) in Math.Lemmas.pow2_modulo_division_lemma_1 (n * k1) (a - 1) a; assert (d % 2 == n * k1 % pow2 a / pow2 (a - 1)); if d % 2 = 0 then begin Math.Lemmas.small_division_lemma_2 (n * k1 % pow2 a) (pow2 (a - 1)); assert (n * k1 % pow2 a < pow2 (a - 1)); () end #push-options "--z3rlimit 100" val eea_pow2_odd_k_lemma: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in n * k % pow2 a == 1)) let eea_pow2_odd_k_lemma a n k1 = let d = n * k1 / pow2 (a - 1) in let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in calc (==) { n * k1; (==) { Math.Lemmas.euclidean_division_definition (n * k1) (pow2 (a - 1)) } 1 + d * pow2 (a - 1); (==) { Math.Lemmas.euclidean_division_definition d 2 } 1 + (d / 2 * 2 + d % 2) * pow2 (a - 1); (==) { Math.Lemmas.distributivity_add_left (d / 2 * 2) (d % 2) (pow2 (a - 1)) } 1 + d / 2 * 2 * pow2 (a - 1) + d % 2 * pow2 (a - 1); (==) { Math.Lemmas.pow2_plus 1 (a - 1) } 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1); }; assert (n * k1 == 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1)); if n * k1 % pow2 a < pow2 (a - 1) then begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 0); calc (==) { n * k % pow2 a; (==) { } (1 + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) (d / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a = 1); () end else begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 1); assert (n * k1 == 1 + d / 2 * pow2 a + pow2 (a - 1)); //assert (n * k == 1 + d / 2 * pow2 a + pow2 (a - 1) + n * pow2 (a - 1)); calc (==) { n * k % pow2 a; (==) { Math.Lemmas.distributivity_add_right n k1 (pow2 (a - 1)) } (n * k1 + n * pow2 (a - 1)) % pow2 a; (==) { } (1 + pow2 (a - 1) + n * pow2 (a - 1) + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma (1 + pow2 (a - 1) + n * pow2 (a - 1)) (pow2 a) (d / 2) } (1 + pow2 (a - 1) + n * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.distributivity_add_left 1 n (pow2 (a - 1)) } (1 + (1 + n) * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.lemma_div_exact (1 + n) 2 } (1 + (1 + n) / 2 * 2 * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.paren_mul_right ((1 + n) / 2) 2 (pow2 (a - 1)) } (1 + (1 + n) / 2 * (2 * pow2 (a - 1))) % pow2 a; (==) { Math.Lemmas.pow2_plus 1 (a - 1)} (1 + (1 + n) / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) ((1 + n) / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a == 1); () end #pop-options val eea_pow2_odd_k_lemma_bound: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1 /\ k1 < pow2 (a - 1)) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in k < pow2 a)) let eea_pow2_odd_k_lemma_bound a n k1 = if n * k1 % pow2 a < pow2 (a - 1) then Math.Lemmas.pow2_lt_compat a (a - 1) else Math.Lemmas.pow2_double_sum (a - 1) val eea_pow2_odd_k: a:pos -> n:pos -> Pure pos (requires n % 2 = 1) (ensures fun k -> n * k % pow2 a == 1 /\ k < pow2 a) let rec eea_pow2_odd_k a n = if a = 1 then 1 else begin let k1 = eea_pow2_odd_k (a - 1) n in assert (n * k1 % pow2 (a - 1) == 1); let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in eea_pow2_odd_k_lemma a n k1; eea_pow2_odd_k_lemma_bound a n k1; assert (n * k % pow2 a == 1); k end val eea_pow2_odd: a:pos -> n:pos -> Pure (tuple2 int int) (requires n % 2 = 1) (ensures fun (d, k) -> pow2 a * d == 1 + k * n /\ - d < n) let eea_pow2_odd a n = let k = eea_pow2_odd_k a n in assert (n * k % pow2 a == 1); assert (n * k == n * k / pow2 a * pow2 a + 1); let d = n * k / pow2 a in Math.Lemmas.lemma_mult_lt_left n k (pow2 a); assert (n * k < n * pow2 a); Math.Lemmas.cancel_mul_div n (pow2 a); assert (d < n); assert (n * k == d * pow2 a + 1); (- d, - k) val mont_preconditions_d: pbits:pos -> rLen:pos -> n:pos{1 < n} -> Lemma (requires n % 2 = 1) (ensures (let d, k = eea_pow2_odd (pbits * rLen) n in pow2 (pbits * rLen) * d % n == 1)) let mont_preconditions_d pbits rLen n = let d, k = eea_pow2_odd (pbits * rLen) n in calc (==) { pow2 (pbits * rLen) * d % n; (==) { } (1 + k * n) % n; (==) { Math.Lemmas.modulo_addition_lemma 1 n k } 1 % n; (==) { Math.Lemmas.small_mod 1 n } 1; }; assert (pow2 (pbits * rLen) * d % n == 1) val mont_preconditions_n0: pbits:pos -> n:pos{n > 1} -> mu:nat -> Lemma (requires (1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) (ensures (1 + n * mu) % pow2 pbits == 0) let mont_preconditions_n0 pbits n mu = calc (==) { (1 + n * mu) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_plus_distr_r 1 (n * mu) (pow2 pbits) } (1 + n * mu % pow2 pbits) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_mul_distr_l n mu (pow2 pbits) } (1 + n % pow2 pbits * mu % pow2 pbits) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_plus_distr_r 1 (n % pow2 pbits * mu) (pow2 pbits) } (1 + n % pow2 pbits * mu) % pow2 pbits; (==) { assert ((1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) } 0; }; assert ((1 + n * mu) % pow2 pbits == 0) val mont_preconditions: pbits:pos -> rLen:pos -> n:pos{1 < n} -> mu:nat -> Lemma (requires n % 2 = 1 /\ (1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) (ensures (let r = pow2 (pbits * rLen) in let d, _ = eea_pow2_odd (pbits * rLen) n in r * d % n == 1 /\ (1 + n * mu) % pow2 pbits == 0)) let mont_preconditions pbits rLen n mu = mont_preconditions_d pbits rLen n; mont_preconditions_n0 pbits n mu /// High-level specification of Montgomery arithmetic val mont_reduction_f: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> i:nat{i < rLen} -> c:nat -> nat let mont_reduction_f pbits rLen n mu i c = let c_i = c / pow2 (pbits * i) % pow2 pbits in let q_i = mu * c_i % pow2 pbits in let res = c + n * q_i * pow2 (pbits * i) in res val mont_reduction_loop_div_r: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> c:nat -> nat let mont_reduction_loop_div_r pbits rLen n mu c = let res = repeati rLen (mont_reduction_f pbits rLen n mu) c in let res = res / pow2 (pbits * rLen) in res val mont_reduction: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> c:nat -> nat let mont_reduction pbits rLen n mu c = let res = mont_reduction_loop_div_r pbits rLen n mu c in if res < n then res else res - n val to_mont: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> a:nat -> nat let to_mont pbits rLen n mu a = let r2 = pow2 (2 * pbits * rLen) % n in let c = a * r2 in mont_reduction pbits rLen n mu c val from_mont: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> aM:nat -> nat let from_mont pbits rLen n mu aM = mont_reduction pbits rLen n mu aM val mont_mul: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> a:nat -> b:nat -> nat let mont_mul pbits rLen n mu a b = let c = a * b in mont_reduction pbits rLen n mu c val mont_sqr: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> a:nat -> nat let mont_sqr pbits rLen n mu a = mont_mul pbits rLen n mu a a val mont_one: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> nat let mont_one pbits rLen n mu = let r2 = pow2 (2 * pbits * rLen) % n in mont_reduction pbits rLen n mu r2 /// Lemma (let res = mont_reduction_loop_div_r pbits rLen n mu c in /// res % n == c * d % n /\ res <= (c - n) / r + n) val mont_reduction_lemma_step_bound_aux: pbits:pos -> n:pos -> q_i:nat{q_i < pow2 pbits} -> i:pos -> c:nat -> res0:nat -> Lemma (requires res0 <= c + (pow2 (pbits * (i - 1)) - 1) * n) (ensures res0 + n * q_i * pow2 (pbits * (i - 1)) <= c + (pow2 (pbits * i) - 1) * n) let mont_reduction_lemma_step_bound_aux pbits n q_i i c res0 = let b = pow2 (pbits * i) in let b1 = pow2 (pbits * (i - 1)) in calc (<=) { res0 + n * q_i * b1; (<=) { Math.Lemmas.lemma_mult_le_right b1 q_i (pow2 pbits - 1) } res0 + n * (pow2 pbits - 1) * b1; (==) { Math.Lemmas.paren_mul_right n (pow2 pbits - 1) b1 } res0 + n * ((pow2 pbits - 1) * b1); (==) { Math.Lemmas.distributivity_sub_left (pow2 pbits) 1 b1 } res0 + n * (pow2 pbits * b1 - b1); (==) { Math.Lemmas.pow2_plus pbits (pbits * (i - 1)) } res0 + n * (b - b1); (==) { Math.Lemmas.distributivity_sub_right n b b1 } res0 + n * b - n * b1; (<=) { } c + (b1 - 1) * n + n * b - n * b1; (==) { Math.Lemmas.distributivity_sub_left b1 1 n } c + b1 * n - n + n * b - n * b1; (==) { } c - n + b * n; (==) { Math.Lemmas.distributivity_sub_left b 1 n } c + (b - 1) * n; } val mont_reduction_lemma_step_bound: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> i:pos{i <= rLen} -> c:nat -> res0:nat -> Lemma (requires res0 <= c + (pow2 (pbits * (i - 1)) - 1) * n) (ensures mont_reduction_f pbits rLen n mu (i - 1) res0 <= c + (pow2 (pbits * i) - 1) * n) let mont_reduction_lemma_step_bound pbits rLen n mu i c res0 = let res = mont_reduction_f pbits rLen n mu (i - 1) res0 in let c_i = res0 / pow2 (pbits * (i - 1)) % pow2 pbits in let q_i = mu * c_i % pow2 pbits in assert (res == res0 + n * q_i * pow2 (pbits * (i - 1))); mont_reduction_lemma_step_bound_aux pbits n q_i i c res0; assert (res <= c + (pow2 (pbits * i) - 1) * n) val mont_reduction_lemma_step_mod_pbits: pbits:pos -> n:pos -> mu:nat -> c_i:nat -> Lemma (requires (1 + n * mu) % pow2 pbits == 0) (ensures (c_i + n * (mu * c_i % pow2 pbits)) % pow2 pbits == 0) let mont_reduction_lemma_step_mod_pbits pbits n mu c_i = let r = pow2 pbits in let q_i = mu * c_i % r in calc (==) { (c_i + n * q_i) % r; (==) { Math.Lemmas.lemma_mod_plus_distr_r c_i (n * q_i) r } (c_i + n * q_i % r) % r; (==) { } (c_i + n * (mu * c_i % r) % r) % r; (==) { Math.Lemmas.lemma_mod_mul_distr_r n (mu * c_i) r } (c_i + n * (mu * c_i) % r) % r; (==) { Math.Lemmas.lemma_mod_plus_distr_r c_i (n * (mu * c_i)) r } (c_i + n * (mu * c_i)) % r; (==) { Math.Lemmas.paren_mul_right n mu c_i } (c_i + n * mu * c_i) % r; (==) { Math.Lemmas.distributivity_add_left 1 (n * mu) c_i } ((1 + n * mu) * c_i) % r; (==) { Math.Lemmas.lemma_mod_mul_distr_l (1 + n * mu) c_i r } ((1 + n * mu) % r * c_i) % r; (==) { assert ((1 + n * mu) % r = 0) } 0; } val mont_reduction_lemma_step_modr_aux: pbits:pos -> n:pos -> q_i:nat -> i:pos -> res0:nat -> Lemma (let b1 = pow2 (pbits * (i - 1)) in (res0 / b1 * b1 + n * q_i * b1) % pow2 (pbits * i) == (res0 / b1 % pow2 pbits + n * q_i) % pow2 pbits * b1) let mont_reduction_lemma_step_modr_aux pbits n q_i i res0 = let b1 = pow2 (pbits * (i - 1)) in Math.Lemmas.distributivity_sub_right pbits i 1; assert (pbits * i - pbits * (i - 1) == pbits); calc (==) { (res0 / b1 * b1 + n * q_i * b1) % pow2 (pbits * i); (==) { Math.Lemmas.distributivity_add_left (res0 / b1) (n * q_i) b1 } (res0 / b1 + n * q_i) * b1 % pow2 (pbits * i); (==) { Math.Lemmas.pow2_multiplication_modulo_lemma_2 (res0 / b1 + n * q_i) (pbits * i) (pbits * (i - 1)) } (res0 / b1 + n * q_i) % pow2 pbits * b1; (==) { Math.Lemmas.lemma_mod_plus_distr_l (res0 / b1) (n * q_i) (pow2 pbits) } (res0 / b1 % pow2 pbits + n * q_i) % pow2 pbits * b1; } val mont_reduction_lemma_step_modr: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> i:pos{i <= rLen} -> res0:nat -> Lemma (requires res0 % pow2 (pbits * (i - 1)) == 0 /\ (1 + n * mu) % pow2 pbits == 0) (ensures mont_reduction_f pbits rLen n mu (i - 1) res0 % pow2 (pbits * i) == 0)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Montgomery.Lemmas.fst" }
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
pbits: Prims.pos -> rLen: Prims.nat -> n: Prims.pos -> mu: Prims.nat -> i: Prims.pos{i <= rLen} -> res0: Prims.nat -> FStar.Pervasives.Lemma (requires res0 % Prims.pow2 (pbits * (i - 1)) == 0 /\ (1 + n * mu) % Prims.pow2 pbits == 0) (ensures Hacl.Spec.Montgomery.Lemmas.mont_reduction_f pbits rLen n mu (i - 1) res0 % Prims.pow2 (pbits * i) == 0)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.pos", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Hacl.Spec.Montgomery.Lemmas.mont_reduction_lemma_step_mod_pbits", "Prims.unit", "Hacl.Spec.Montgomery.Lemmas.mont_reduction_lemma_step_modr_aux", "FStar.Math.Lemmas.lemma_div_exact", "Prims.int", "Prims.op_Modulus", "FStar.Mul.op_Star", "Prims.pow2", "Prims.op_Division", "Hacl.Spec.Montgomery.Lemmas.mont_reduction_f", "Prims.op_Subtraction" ]
[]
true
false
true
false
false
let mont_reduction_lemma_step_modr pbits rLen n mu i res0 =
let b1 = pow2 (pbits * (i - 1)) in let res = mont_reduction_f pbits rLen n mu (i - 1) res0 in let c_i = res0 / b1 % pow2 pbits in let q_i = mu * c_i % pow2 pbits in Math.Lemmas.lemma_div_exact res0 b1; mont_reduction_lemma_step_modr_aux pbits n q_i i res0; mont_reduction_lemma_step_mod_pbits pbits n mu c_i
false
Hacl.Bignum.MontArithmetic.fsti
Hacl.Bignum.MontArithmetic.bn_field_check_modulus_st
val bn_field_check_modulus_st : t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0
let bn_field_check_modulus_st (t:limb_t) (len:BN.meta_len t) = n:lbignum t len -> Stack bool (requires fun h -> live h n) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_field_check_modulus (as_seq h0 n))
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 48, "end_line": 132, "start_col": 0, "start_line": 128 }
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module Euclid = FStar.Math.Euclid module S = Hacl.Spec.Bignum.MontArithmetic module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val _align_fsti : unit inline_for_extraction noextract let lb (t:limb_t) = match t with | U32 -> buffer uint32 | U64 -> buffer uint64 inline_for_extraction noextract let ll (t:limb_t) = match t with | U32 -> uint32 | U64 -> uint64 inline_for_extraction noeq type bn_mont_ctx' (t:limb_t) (a:Type0{a == lb t}) (b:Type0{b == ll t}) = { len: BN.meta_len t; n: x:a{length #MUT #(limb t) x == v len}; mu: b; r2: x:a{length #MUT #(limb t) x == v len}; } inline_for_extraction noextract let bn_mont_ctx (t:limb_t) = bn_mont_ctx' t (lb t) (ll t) let bn_mont_ctx_u32 = bn_mont_ctx' U32 (lb U32) (ll U32) let bn_mont_ctx_u64 = bn_mont_ctx' U64 (lb U64) (ll U64) inline_for_extraction noextract let pbn_mont_ctx (t:limb_t) = B.pointer (bn_mont_ctx t) inline_for_extraction noextract let pbn_mont_ctx_u32 = B.pointer bn_mont_ctx_u32 inline_for_extraction noextract let pbn_mont_ctx_u64 = B.pointer bn_mont_ctx_u64 inline_for_extraction noextract let as_ctx (#t:limb_t) (h:mem) (k:bn_mont_ctx t) : GTot (S.bn_mont_ctx t) = { S.len = v k.len; S.n = as_seq h (k.n <: lbignum t k.len); S.mu = k.mu; S.r2 = as_seq h (k.r2 <: lbignum t k.len); } inline_for_extraction noextract let bn_mont_ctx_inv (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in live h n /\ live h r2 /\ disjoint n r2 /\ S.bn_mont_ctx_inv (as_ctx h k) inline_for_extraction noextract let bn_v_n (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = let k1 = B.deref h k in let n : lbignum t k1.len = k1.n in bn_v h n inline_for_extraction noextract let freeable_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.freeable n /\ B.freeable r2 inline_for_extraction noextract let freeable (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.freeable k /\ freeable_s h (B.deref h k) inline_for_extraction noextract let footprint_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.(loc_union (loc_addr_of_buffer n) (loc_addr_of_buffer r2)) inline_for_extraction noextract let footprint (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.(loc_union (loc_addr_of_buffer k) (footprint_s h (B.deref h k))) inline_for_extraction noextract let as_pctx (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) : GTot (S.bn_mont_ctx t) = as_ctx h (B.deref h k) inline_for_extraction noextract let pbn_mont_ctx_inv (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.live h k /\ B.(loc_disjoint (loc_addr_of_buffer k) (footprint_s h (B.deref h k))) /\ bn_mont_ctx_inv h (B.deref h k) inline_for_extraction noextract let bn_field_get_len_st (t:limb_t) = k:pbn_mont_ctx t -> Stack (BN.meta_len t) (requires fun h -> pbn_mont_ctx_inv h k) (ensures fun h0 r h1 -> h0 == h1 /\ r == (B.deref h0 k).len /\ v r == S.bn_field_get_len (as_pctx h0 k)) inline_for_extraction noextract val bn_field_get_len: #t:limb_t -> bn_field_get_len_st t
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontArithmetic.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.meta_len", "Hacl.Bignum.Definitions.lbignum", "Prims.bool", "FStar.Monotonic.HyperStack.mem", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Prims.l_and", "Lib.Buffer.modifies0", "Prims.eq2", "Hacl.Spec.Bignum.MontArithmetic.bn_field_check_modulus", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.as_seq" ]
[]
false
false
false
false
true
let bn_field_check_modulus_st (t: limb_t) (len: BN.meta_len t) =
n: lbignum t len -> Stack bool (requires fun h -> live h n) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_field_check_modulus (as_seq h0 n))
false
Hacl.Bignum.MontArithmetic.fsti
Hacl.Bignum.MontArithmetic.bn_field_mul_st
val bn_field_mul_st : t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0
let bn_field_mul_st (t:limb_t) (len:BN.meta_len t) = k:pbn_mont_ctx t -> aM:lbignum t len -> bM:lbignum t len -> cM:lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ bn_v h aM < bn_v_n h k /\ bn_v h bM < bn_v_n h k /\ live h aM /\ live h bM /\ live h cM /\ eq_or_disjoint aM bM /\ eq_or_disjoint aM cM /\ eq_or_disjoint bM cM /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (bM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (cM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc cM) h0 h1 /\ bn_v h1 cM < bn_v_n h0 k /\ as_seq h1 cM == S.bn_field_mul (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM))
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 80, "end_line": 298, "start_col": 0, "start_line": 279 }
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module Euclid = FStar.Math.Euclid module S = Hacl.Spec.Bignum.MontArithmetic module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val _align_fsti : unit inline_for_extraction noextract let lb (t:limb_t) = match t with | U32 -> buffer uint32 | U64 -> buffer uint64 inline_for_extraction noextract let ll (t:limb_t) = match t with | U32 -> uint32 | U64 -> uint64 inline_for_extraction noeq type bn_mont_ctx' (t:limb_t) (a:Type0{a == lb t}) (b:Type0{b == ll t}) = { len: BN.meta_len t; n: x:a{length #MUT #(limb t) x == v len}; mu: b; r2: x:a{length #MUT #(limb t) x == v len}; } inline_for_extraction noextract let bn_mont_ctx (t:limb_t) = bn_mont_ctx' t (lb t) (ll t) let bn_mont_ctx_u32 = bn_mont_ctx' U32 (lb U32) (ll U32) let bn_mont_ctx_u64 = bn_mont_ctx' U64 (lb U64) (ll U64) inline_for_extraction noextract let pbn_mont_ctx (t:limb_t) = B.pointer (bn_mont_ctx t) inline_for_extraction noextract let pbn_mont_ctx_u32 = B.pointer bn_mont_ctx_u32 inline_for_extraction noextract let pbn_mont_ctx_u64 = B.pointer bn_mont_ctx_u64 inline_for_extraction noextract let as_ctx (#t:limb_t) (h:mem) (k:bn_mont_ctx t) : GTot (S.bn_mont_ctx t) = { S.len = v k.len; S.n = as_seq h (k.n <: lbignum t k.len); S.mu = k.mu; S.r2 = as_seq h (k.r2 <: lbignum t k.len); } inline_for_extraction noextract let bn_mont_ctx_inv (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in live h n /\ live h r2 /\ disjoint n r2 /\ S.bn_mont_ctx_inv (as_ctx h k) inline_for_extraction noextract let bn_v_n (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = let k1 = B.deref h k in let n : lbignum t k1.len = k1.n in bn_v h n inline_for_extraction noextract let freeable_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.freeable n /\ B.freeable r2 inline_for_extraction noextract let freeable (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.freeable k /\ freeable_s h (B.deref h k) inline_for_extraction noextract let footprint_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.(loc_union (loc_addr_of_buffer n) (loc_addr_of_buffer r2)) inline_for_extraction noextract let footprint (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.(loc_union (loc_addr_of_buffer k) (footprint_s h (B.deref h k))) inline_for_extraction noextract let as_pctx (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) : GTot (S.bn_mont_ctx t) = as_ctx h (B.deref h k) inline_for_extraction noextract let pbn_mont_ctx_inv (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.live h k /\ B.(loc_disjoint (loc_addr_of_buffer k) (footprint_s h (B.deref h k))) /\ bn_mont_ctx_inv h (B.deref h k) inline_for_extraction noextract let bn_field_get_len_st (t:limb_t) = k:pbn_mont_ctx t -> Stack (BN.meta_len t) (requires fun h -> pbn_mont_ctx_inv h k) (ensures fun h0 r h1 -> h0 == h1 /\ r == (B.deref h0 k).len /\ v r == S.bn_field_get_len (as_pctx h0 k)) inline_for_extraction noextract val bn_field_get_len: #t:limb_t -> bn_field_get_len_st t inline_for_extraction noextract let bn_field_check_modulus_st (t:limb_t) (len:BN.meta_len t) = n:lbignum t len -> Stack bool (requires fun h -> live h n) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_field_check_modulus (as_seq h0 n)) inline_for_extraction noextract val bn_field_check_modulus: #t:limb_t -> km:BM.mont t -> bn_field_check_modulus_st t km.BM.bn.BN.len inline_for_extraction noextract let bn_field_init_st (t:limb_t) (len:BN.meta_len t) = r:HS.rid -> n:lbignum t len -> ST (pbn_mont_ctx t) (requires fun h -> S.bn_mont_ctx_pre (as_seq h n) /\ live h n /\ ST.is_eternal_region r) (ensures fun h0 res h1 -> B.(modifies loc_none h0 h1) /\ B.(fresh_loc (footprint h1 res) h0 h1) /\ B.(loc_includes (loc_region_only true r) (footprint h1 res)) /\ freeable h1 res /\ (B.deref h1 res).len == len /\ bn_v_n h1 res == bn_v h0 n /\ S.bn_mont_ctx_inv (as_pctx h1 res) /\ as_pctx h1 res == S.bn_field_init (as_seq h0 n)) inline_for_extraction noextract val bn_field_init: #t:limb_t -> len:BN.meta_len t -> precomp_r2:BM.bn_precomp_r2_mod_n_st t len -> bn_field_init_st t len inline_for_extraction noextract let bn_field_free_st (t:limb_t) = k:pbn_mont_ctx t -> ST unit (requires fun h -> freeable h k /\ pbn_mont_ctx_inv h k) (ensures fun h0 _ h1 -> B.(modifies (footprint h0 k) h0 h1)) inline_for_extraction noextract val bn_field_free: #t:limb_t -> bn_field_free_st t inline_for_extraction noextract let bn_to_field_st (t:limb_t) (len:BN.meta_len t) = k:pbn_mont_ctx t -> a:lbignum t len -> aM:lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ live h a /\ live h aM /\ disjoint a aM /\ B.(loc_disjoint (footprint h k) (loc_buffer (a <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc aM) h0 h1 /\ bn_v h1 aM < bn_v_n h0 k /\ as_seq h1 aM == S.bn_to_field (as_pctx h0 k) (as_seq h0 a)) inline_for_extraction noextract val bn_to_field: #t:limb_t -> km:BM.mont t -> bn_to_field_st t km.BM.bn.BN.len inline_for_extraction noextract let bn_from_field_st (t:limb_t) (len:BN.meta_len t) = k:pbn_mont_ctx t -> aM:lbignum t len -> a:lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ bn_v h aM < bn_v_n h k /\ live h a /\ live h aM /\ disjoint a aM /\ B.(loc_disjoint (footprint h k) (loc_buffer (a <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc a) h0 h1 /\ bn_v h1 a < bn_v_n h0 k /\ as_seq h1 a == S.bn_from_field (as_pctx h0 k) (as_seq h0 aM)) inline_for_extraction noextract val bn_from_field: #t:limb_t -> km:BM.mont t -> bn_from_field_st t km.BM.bn.BN.len inline_for_extraction noextract let bn_field_add_st (t:limb_t) (len:BN.meta_len t) = k:pbn_mont_ctx t -> aM:lbignum t len -> bM:lbignum t len -> cM:lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ bn_v h aM < bn_v_n h k /\ bn_v h bM < bn_v_n h k /\ live h aM /\ live h bM /\ live h cM /\ eq_or_disjoint aM bM /\ eq_or_disjoint aM cM /\ eq_or_disjoint bM cM /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (bM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (cM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc cM) h0 h1 /\ bn_v h1 cM < bn_v_n h0 k /\ as_seq h1 cM == S.bn_field_add (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM)) inline_for_extraction noextract val bn_field_add: #t:limb_t -> km:BM.mont t -> bn_field_add_st t km.BM.bn.BN.len inline_for_extraction noextract let bn_field_sub_st (t:limb_t) (len:BN.meta_len t) = k:pbn_mont_ctx t -> aM:lbignum t len -> bM:lbignum t len -> cM:lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ bn_v h aM < bn_v_n h k /\ bn_v h bM < bn_v_n h k /\ live h aM /\ live h bM /\ live h cM /\ eq_or_disjoint aM bM /\ eq_or_disjoint aM cM /\ eq_or_disjoint bM cM /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (bM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (cM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc cM) h0 h1 /\ bn_v h1 cM < bn_v_n h0 k /\ as_seq h1 cM == S.bn_field_sub (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM)) inline_for_extraction noextract val bn_field_sub: #t:limb_t -> km:BM.mont t -> bn_field_sub_st t km.BM.bn.BN.len
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontArithmetic.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.meta_len", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.Bignum.Definitions.lbignum", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.eq2", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__len", "Hacl.Bignum.MontArithmetic.lb", "Hacl.Bignum.MontArithmetic.ll", "LowStar.Monotonic.Buffer.deref", "Hacl.Bignum.MontArithmetic.bn_mont_ctx", "LowStar.Buffer.trivial_preorder", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx_inv", "Prims.b2t", "Prims.op_LessThan", "Hacl.Bignum.Definitions.bn_v", "Hacl.Bignum.MontArithmetic.bn_v_n", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.eq_or_disjoint", "LowStar.Monotonic.Buffer.loc_disjoint", "Hacl.Bignum.MontArithmetic.footprint", "LowStar.Monotonic.Buffer.loc_buffer", "LowStar.Buffer.buffer", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Lib.Sequence.seq", "Prims.l_or", "Prims.nat", "FStar.Seq.Base.length", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx__item__len", "Hacl.Bignum.MontArithmetic.as_pctx", "Hacl.Spec.Bignum.Definitions.bn_v", "Hacl.Spec.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx__item__n", "Lib.Buffer.as_seq", "Hacl.Spec.Bignum.MontArithmetic.bn_field_mul" ]
[]
false
false
false
false
true
let bn_field_mul_st (t: limb_t) (len: BN.meta_len t) =
k: pbn_mont_ctx t -> aM: lbignum t len -> bM: lbignum t len -> cM: lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ bn_v h aM < bn_v_n h k /\ bn_v h bM < bn_v_n h k /\ live h aM /\ live h bM /\ live h cM /\ eq_or_disjoint aM bM /\ eq_or_disjoint aM cM /\ eq_or_disjoint bM cM /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (bM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (cM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc cM) h0 h1 /\ bn_v h1 cM < bn_v_n h0 k /\ as_seq h1 cM == S.bn_field_mul (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM))
false
Hacl.Spec.Montgomery.Lemmas.fst
Hacl.Spec.Montgomery.Lemmas.mont_reduction_lemma_step_bound
val mont_reduction_lemma_step_bound: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> i:pos{i <= rLen} -> c:nat -> res0:nat -> Lemma (requires res0 <= c + (pow2 (pbits * (i - 1)) - 1) * n) (ensures mont_reduction_f pbits rLen n mu (i - 1) res0 <= c + (pow2 (pbits * i) - 1) * n)
val mont_reduction_lemma_step_bound: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> i:pos{i <= rLen} -> c:nat -> res0:nat -> Lemma (requires res0 <= c + (pow2 (pbits * (i - 1)) - 1) * n) (ensures mont_reduction_f pbits rLen n mu (i - 1) res0 <= c + (pow2 (pbits * i) - 1) * n)
let mont_reduction_lemma_step_bound pbits rLen n mu i c res0 = let res = mont_reduction_f pbits rLen n mu (i - 1) res0 in let c_i = res0 / pow2 (pbits * (i - 1)) % pow2 pbits in let q_i = mu * c_i % pow2 pbits in assert (res == res0 + n * q_i * pow2 (pbits * (i - 1))); mont_reduction_lemma_step_bound_aux pbits n q_i i c res0; assert (res <= c + (pow2 (pbits * i) - 1) * n)
{ "file_name": "code/bignum/Hacl.Spec.Montgomery.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 48, "end_line": 287, "start_col": 0, "start_line": 281 }
module Hacl.Spec.Montgomery.Lemmas open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators (** https://members.loria.fr/PZimmermann/mca/mca-cup-0.5.9.pdf https://eprint.iacr.org/2011/239.pdf https://eprint.iacr.org/2017/1057.pdf *) #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val eea_pow2_odd_k_lemma_d: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let d = n * k1 / pow2 (a - 1) in d % 2 == (if n * k1 % pow2 a < pow2 (a - 1) then 0 else 1))) let eea_pow2_odd_k_lemma_d a n k1 = let d = n * k1 / pow2 (a - 1) in Math.Lemmas.pow2_modulo_division_lemma_1 (n * k1) (a - 1) a; assert (d % 2 == n * k1 % pow2 a / pow2 (a - 1)); if d % 2 = 0 then begin Math.Lemmas.small_division_lemma_2 (n * k1 % pow2 a) (pow2 (a - 1)); assert (n * k1 % pow2 a < pow2 (a - 1)); () end #push-options "--z3rlimit 100" val eea_pow2_odd_k_lemma: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in n * k % pow2 a == 1)) let eea_pow2_odd_k_lemma a n k1 = let d = n * k1 / pow2 (a - 1) in let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in calc (==) { n * k1; (==) { Math.Lemmas.euclidean_division_definition (n * k1) (pow2 (a - 1)) } 1 + d * pow2 (a - 1); (==) { Math.Lemmas.euclidean_division_definition d 2 } 1 + (d / 2 * 2 + d % 2) * pow2 (a - 1); (==) { Math.Lemmas.distributivity_add_left (d / 2 * 2) (d % 2) (pow2 (a - 1)) } 1 + d / 2 * 2 * pow2 (a - 1) + d % 2 * pow2 (a - 1); (==) { Math.Lemmas.pow2_plus 1 (a - 1) } 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1); }; assert (n * k1 == 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1)); if n * k1 % pow2 a < pow2 (a - 1) then begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 0); calc (==) { n * k % pow2 a; (==) { } (1 + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) (d / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a = 1); () end else begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 1); assert (n * k1 == 1 + d / 2 * pow2 a + pow2 (a - 1)); //assert (n * k == 1 + d / 2 * pow2 a + pow2 (a - 1) + n * pow2 (a - 1)); calc (==) { n * k % pow2 a; (==) { Math.Lemmas.distributivity_add_right n k1 (pow2 (a - 1)) } (n * k1 + n * pow2 (a - 1)) % pow2 a; (==) { } (1 + pow2 (a - 1) + n * pow2 (a - 1) + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma (1 + pow2 (a - 1) + n * pow2 (a - 1)) (pow2 a) (d / 2) } (1 + pow2 (a - 1) + n * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.distributivity_add_left 1 n (pow2 (a - 1)) } (1 + (1 + n) * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.lemma_div_exact (1 + n) 2 } (1 + (1 + n) / 2 * 2 * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.paren_mul_right ((1 + n) / 2) 2 (pow2 (a - 1)) } (1 + (1 + n) / 2 * (2 * pow2 (a - 1))) % pow2 a; (==) { Math.Lemmas.pow2_plus 1 (a - 1)} (1 + (1 + n) / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) ((1 + n) / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a == 1); () end #pop-options val eea_pow2_odd_k_lemma_bound: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1 /\ k1 < pow2 (a - 1)) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in k < pow2 a)) let eea_pow2_odd_k_lemma_bound a n k1 = if n * k1 % pow2 a < pow2 (a - 1) then Math.Lemmas.pow2_lt_compat a (a - 1) else Math.Lemmas.pow2_double_sum (a - 1) val eea_pow2_odd_k: a:pos -> n:pos -> Pure pos (requires n % 2 = 1) (ensures fun k -> n * k % pow2 a == 1 /\ k < pow2 a) let rec eea_pow2_odd_k a n = if a = 1 then 1 else begin let k1 = eea_pow2_odd_k (a - 1) n in assert (n * k1 % pow2 (a - 1) == 1); let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in eea_pow2_odd_k_lemma a n k1; eea_pow2_odd_k_lemma_bound a n k1; assert (n * k % pow2 a == 1); k end val eea_pow2_odd: a:pos -> n:pos -> Pure (tuple2 int int) (requires n % 2 = 1) (ensures fun (d, k) -> pow2 a * d == 1 + k * n /\ - d < n) let eea_pow2_odd a n = let k = eea_pow2_odd_k a n in assert (n * k % pow2 a == 1); assert (n * k == n * k / pow2 a * pow2 a + 1); let d = n * k / pow2 a in Math.Lemmas.lemma_mult_lt_left n k (pow2 a); assert (n * k < n * pow2 a); Math.Lemmas.cancel_mul_div n (pow2 a); assert (d < n); assert (n * k == d * pow2 a + 1); (- d, - k) val mont_preconditions_d: pbits:pos -> rLen:pos -> n:pos{1 < n} -> Lemma (requires n % 2 = 1) (ensures (let d, k = eea_pow2_odd (pbits * rLen) n in pow2 (pbits * rLen) * d % n == 1)) let mont_preconditions_d pbits rLen n = let d, k = eea_pow2_odd (pbits * rLen) n in calc (==) { pow2 (pbits * rLen) * d % n; (==) { } (1 + k * n) % n; (==) { Math.Lemmas.modulo_addition_lemma 1 n k } 1 % n; (==) { Math.Lemmas.small_mod 1 n } 1; }; assert (pow2 (pbits * rLen) * d % n == 1) val mont_preconditions_n0: pbits:pos -> n:pos{n > 1} -> mu:nat -> Lemma (requires (1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) (ensures (1 + n * mu) % pow2 pbits == 0) let mont_preconditions_n0 pbits n mu = calc (==) { (1 + n * mu) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_plus_distr_r 1 (n * mu) (pow2 pbits) } (1 + n * mu % pow2 pbits) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_mul_distr_l n mu (pow2 pbits) } (1 + n % pow2 pbits * mu % pow2 pbits) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_plus_distr_r 1 (n % pow2 pbits * mu) (pow2 pbits) } (1 + n % pow2 pbits * mu) % pow2 pbits; (==) { assert ((1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) } 0; }; assert ((1 + n * mu) % pow2 pbits == 0) val mont_preconditions: pbits:pos -> rLen:pos -> n:pos{1 < n} -> mu:nat -> Lemma (requires n % 2 = 1 /\ (1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) (ensures (let r = pow2 (pbits * rLen) in let d, _ = eea_pow2_odd (pbits * rLen) n in r * d % n == 1 /\ (1 + n * mu) % pow2 pbits == 0)) let mont_preconditions pbits rLen n mu = mont_preconditions_d pbits rLen n; mont_preconditions_n0 pbits n mu /// High-level specification of Montgomery arithmetic val mont_reduction_f: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> i:nat{i < rLen} -> c:nat -> nat let mont_reduction_f pbits rLen n mu i c = let c_i = c / pow2 (pbits * i) % pow2 pbits in let q_i = mu * c_i % pow2 pbits in let res = c + n * q_i * pow2 (pbits * i) in res val mont_reduction_loop_div_r: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> c:nat -> nat let mont_reduction_loop_div_r pbits rLen n mu c = let res = repeati rLen (mont_reduction_f pbits rLen n mu) c in let res = res / pow2 (pbits * rLen) in res val mont_reduction: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> c:nat -> nat let mont_reduction pbits rLen n mu c = let res = mont_reduction_loop_div_r pbits rLen n mu c in if res < n then res else res - n val to_mont: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> a:nat -> nat let to_mont pbits rLen n mu a = let r2 = pow2 (2 * pbits * rLen) % n in let c = a * r2 in mont_reduction pbits rLen n mu c val from_mont: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> aM:nat -> nat let from_mont pbits rLen n mu aM = mont_reduction pbits rLen n mu aM val mont_mul: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> a:nat -> b:nat -> nat let mont_mul pbits rLen n mu a b = let c = a * b in mont_reduction pbits rLen n mu c val mont_sqr: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> a:nat -> nat let mont_sqr pbits rLen n mu a = mont_mul pbits rLen n mu a a val mont_one: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> nat let mont_one pbits rLen n mu = let r2 = pow2 (2 * pbits * rLen) % n in mont_reduction pbits rLen n mu r2 /// Lemma (let res = mont_reduction_loop_div_r pbits rLen n mu c in /// res % n == c * d % n /\ res <= (c - n) / r + n) val mont_reduction_lemma_step_bound_aux: pbits:pos -> n:pos -> q_i:nat{q_i < pow2 pbits} -> i:pos -> c:nat -> res0:nat -> Lemma (requires res0 <= c + (pow2 (pbits * (i - 1)) - 1) * n) (ensures res0 + n * q_i * pow2 (pbits * (i - 1)) <= c + (pow2 (pbits * i) - 1) * n) let mont_reduction_lemma_step_bound_aux pbits n q_i i c res0 = let b = pow2 (pbits * i) in let b1 = pow2 (pbits * (i - 1)) in calc (<=) { res0 + n * q_i * b1; (<=) { Math.Lemmas.lemma_mult_le_right b1 q_i (pow2 pbits - 1) } res0 + n * (pow2 pbits - 1) * b1; (==) { Math.Lemmas.paren_mul_right n (pow2 pbits - 1) b1 } res0 + n * ((pow2 pbits - 1) * b1); (==) { Math.Lemmas.distributivity_sub_left (pow2 pbits) 1 b1 } res0 + n * (pow2 pbits * b1 - b1); (==) { Math.Lemmas.pow2_plus pbits (pbits * (i - 1)) } res0 + n * (b - b1); (==) { Math.Lemmas.distributivity_sub_right n b b1 } res0 + n * b - n * b1; (<=) { } c + (b1 - 1) * n + n * b - n * b1; (==) { Math.Lemmas.distributivity_sub_left b1 1 n } c + b1 * n - n + n * b - n * b1; (==) { } c - n + b * n; (==) { Math.Lemmas.distributivity_sub_left b 1 n } c + (b - 1) * n; } val mont_reduction_lemma_step_bound: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> i:pos{i <= rLen} -> c:nat -> res0:nat -> Lemma (requires res0 <= c + (pow2 (pbits * (i - 1)) - 1) * n) (ensures mont_reduction_f pbits rLen n mu (i - 1) res0 <= c + (pow2 (pbits * i) - 1) * n)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Montgomery.Lemmas.fst" }
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
pbits: Prims.pos -> rLen: Prims.nat -> n: Prims.pos -> mu: Prims.nat -> i: Prims.pos{i <= rLen} -> c: Prims.nat -> res0: Prims.nat -> FStar.Pervasives.Lemma (requires res0 <= c + (Prims.pow2 (pbits * (i - 1)) - 1) * n) (ensures Hacl.Spec.Montgomery.Lemmas.mont_reduction_f pbits rLen n mu (i - 1) res0 <= c + (Prims.pow2 (pbits * i) - 1) * n)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.pos", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims._assert", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.op_Subtraction", "Prims.pow2", "Prims.unit", "Hacl.Spec.Montgomery.Lemmas.mont_reduction_lemma_step_bound_aux", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "Prims.op_Division", "Hacl.Spec.Montgomery.Lemmas.mont_reduction_f" ]
[]
true
false
true
false
false
let mont_reduction_lemma_step_bound pbits rLen n mu i c res0 =
let res = mont_reduction_f pbits rLen n mu (i - 1) res0 in let c_i = res0 / pow2 (pbits * (i - 1)) % pow2 pbits in let q_i = mu * c_i % pow2 pbits in assert (res == res0 + (n * q_i) * pow2 (pbits * (i - 1))); mont_reduction_lemma_step_bound_aux pbits n q_i i c res0; assert (res <= c + (pow2 (pbits * i) - 1) * n)
false
Hacl.Spec.Montgomery.Lemmas.fst
Hacl.Spec.Montgomery.Lemmas.mont_pre
val mont_pre : pbits: Prims.pos -> rLen: Prims.pos -> n: Prims.pos -> mu: Prims.nat -> Prims.logical
let mont_pre (pbits:pos) (rLen:pos) (n:pos) (mu:nat) = (1 + n * mu) % pow2 pbits == 0 /\ 1 < n /\ n < pow2 (pbits * rLen) /\ n % 2 = 1
{ "file_name": "code/bignum/Hacl.Spec.Montgomery.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 47, "end_line": 456, "start_col": 0, "start_line": 454 }
module Hacl.Spec.Montgomery.Lemmas open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators (** https://members.loria.fr/PZimmermann/mca/mca-cup-0.5.9.pdf https://eprint.iacr.org/2011/239.pdf https://eprint.iacr.org/2017/1057.pdf *) #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val eea_pow2_odd_k_lemma_d: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let d = n * k1 / pow2 (a - 1) in d % 2 == (if n * k1 % pow2 a < pow2 (a - 1) then 0 else 1))) let eea_pow2_odd_k_lemma_d a n k1 = let d = n * k1 / pow2 (a - 1) in Math.Lemmas.pow2_modulo_division_lemma_1 (n * k1) (a - 1) a; assert (d % 2 == n * k1 % pow2 a / pow2 (a - 1)); if d % 2 = 0 then begin Math.Lemmas.small_division_lemma_2 (n * k1 % pow2 a) (pow2 (a - 1)); assert (n * k1 % pow2 a < pow2 (a - 1)); () end #push-options "--z3rlimit 100" val eea_pow2_odd_k_lemma: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in n * k % pow2 a == 1)) let eea_pow2_odd_k_lemma a n k1 = let d = n * k1 / pow2 (a - 1) in let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in calc (==) { n * k1; (==) { Math.Lemmas.euclidean_division_definition (n * k1) (pow2 (a - 1)) } 1 + d * pow2 (a - 1); (==) { Math.Lemmas.euclidean_division_definition d 2 } 1 + (d / 2 * 2 + d % 2) * pow2 (a - 1); (==) { Math.Lemmas.distributivity_add_left (d / 2 * 2) (d % 2) (pow2 (a - 1)) } 1 + d / 2 * 2 * pow2 (a - 1) + d % 2 * pow2 (a - 1); (==) { Math.Lemmas.pow2_plus 1 (a - 1) } 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1); }; assert (n * k1 == 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1)); if n * k1 % pow2 a < pow2 (a - 1) then begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 0); calc (==) { n * k % pow2 a; (==) { } (1 + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) (d / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a = 1); () end else begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 1); assert (n * k1 == 1 + d / 2 * pow2 a + pow2 (a - 1)); //assert (n * k == 1 + d / 2 * pow2 a + pow2 (a - 1) + n * pow2 (a - 1)); calc (==) { n * k % pow2 a; (==) { Math.Lemmas.distributivity_add_right n k1 (pow2 (a - 1)) } (n * k1 + n * pow2 (a - 1)) % pow2 a; (==) { } (1 + pow2 (a - 1) + n * pow2 (a - 1) + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma (1 + pow2 (a - 1) + n * pow2 (a - 1)) (pow2 a) (d / 2) } (1 + pow2 (a - 1) + n * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.distributivity_add_left 1 n (pow2 (a - 1)) } (1 + (1 + n) * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.lemma_div_exact (1 + n) 2 } (1 + (1 + n) / 2 * 2 * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.paren_mul_right ((1 + n) / 2) 2 (pow2 (a - 1)) } (1 + (1 + n) / 2 * (2 * pow2 (a - 1))) % pow2 a; (==) { Math.Lemmas.pow2_plus 1 (a - 1)} (1 + (1 + n) / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) ((1 + n) / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a == 1); () end #pop-options val eea_pow2_odd_k_lemma_bound: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1 /\ k1 < pow2 (a - 1)) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in k < pow2 a)) let eea_pow2_odd_k_lemma_bound a n k1 = if n * k1 % pow2 a < pow2 (a - 1) then Math.Lemmas.pow2_lt_compat a (a - 1) else Math.Lemmas.pow2_double_sum (a - 1) val eea_pow2_odd_k: a:pos -> n:pos -> Pure pos (requires n % 2 = 1) (ensures fun k -> n * k % pow2 a == 1 /\ k < pow2 a) let rec eea_pow2_odd_k a n = if a = 1 then 1 else begin let k1 = eea_pow2_odd_k (a - 1) n in assert (n * k1 % pow2 (a - 1) == 1); let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in eea_pow2_odd_k_lemma a n k1; eea_pow2_odd_k_lemma_bound a n k1; assert (n * k % pow2 a == 1); k end val eea_pow2_odd: a:pos -> n:pos -> Pure (tuple2 int int) (requires n % 2 = 1) (ensures fun (d, k) -> pow2 a * d == 1 + k * n /\ - d < n) let eea_pow2_odd a n = let k = eea_pow2_odd_k a n in assert (n * k % pow2 a == 1); assert (n * k == n * k / pow2 a * pow2 a + 1); let d = n * k / pow2 a in Math.Lemmas.lemma_mult_lt_left n k (pow2 a); assert (n * k < n * pow2 a); Math.Lemmas.cancel_mul_div n (pow2 a); assert (d < n); assert (n * k == d * pow2 a + 1); (- d, - k) val mont_preconditions_d: pbits:pos -> rLen:pos -> n:pos{1 < n} -> Lemma (requires n % 2 = 1) (ensures (let d, k = eea_pow2_odd (pbits * rLen) n in pow2 (pbits * rLen) * d % n == 1)) let mont_preconditions_d pbits rLen n = let d, k = eea_pow2_odd (pbits * rLen) n in calc (==) { pow2 (pbits * rLen) * d % n; (==) { } (1 + k * n) % n; (==) { Math.Lemmas.modulo_addition_lemma 1 n k } 1 % n; (==) { Math.Lemmas.small_mod 1 n } 1; }; assert (pow2 (pbits * rLen) * d % n == 1) val mont_preconditions_n0: pbits:pos -> n:pos{n > 1} -> mu:nat -> Lemma (requires (1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) (ensures (1 + n * mu) % pow2 pbits == 0) let mont_preconditions_n0 pbits n mu = calc (==) { (1 + n * mu) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_plus_distr_r 1 (n * mu) (pow2 pbits) } (1 + n * mu % pow2 pbits) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_mul_distr_l n mu (pow2 pbits) } (1 + n % pow2 pbits * mu % pow2 pbits) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_plus_distr_r 1 (n % pow2 pbits * mu) (pow2 pbits) } (1 + n % pow2 pbits * mu) % pow2 pbits; (==) { assert ((1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) } 0; }; assert ((1 + n * mu) % pow2 pbits == 0) val mont_preconditions: pbits:pos -> rLen:pos -> n:pos{1 < n} -> mu:nat -> Lemma (requires n % 2 = 1 /\ (1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) (ensures (let r = pow2 (pbits * rLen) in let d, _ = eea_pow2_odd (pbits * rLen) n in r * d % n == 1 /\ (1 + n * mu) % pow2 pbits == 0)) let mont_preconditions pbits rLen n mu = mont_preconditions_d pbits rLen n; mont_preconditions_n0 pbits n mu /// High-level specification of Montgomery arithmetic val mont_reduction_f: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> i:nat{i < rLen} -> c:nat -> nat let mont_reduction_f pbits rLen n mu i c = let c_i = c / pow2 (pbits * i) % pow2 pbits in let q_i = mu * c_i % pow2 pbits in let res = c + n * q_i * pow2 (pbits * i) in res val mont_reduction_loop_div_r: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> c:nat -> nat let mont_reduction_loop_div_r pbits rLen n mu c = let res = repeati rLen (mont_reduction_f pbits rLen n mu) c in let res = res / pow2 (pbits * rLen) in res val mont_reduction: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> c:nat -> nat let mont_reduction pbits rLen n mu c = let res = mont_reduction_loop_div_r pbits rLen n mu c in if res < n then res else res - n val to_mont: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> a:nat -> nat let to_mont pbits rLen n mu a = let r2 = pow2 (2 * pbits * rLen) % n in let c = a * r2 in mont_reduction pbits rLen n mu c val from_mont: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> aM:nat -> nat let from_mont pbits rLen n mu aM = mont_reduction pbits rLen n mu aM val mont_mul: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> a:nat -> b:nat -> nat let mont_mul pbits rLen n mu a b = let c = a * b in mont_reduction pbits rLen n mu c val mont_sqr: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> a:nat -> nat let mont_sqr pbits rLen n mu a = mont_mul pbits rLen n mu a a val mont_one: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> nat let mont_one pbits rLen n mu = let r2 = pow2 (2 * pbits * rLen) % n in mont_reduction pbits rLen n mu r2 /// Lemma (let res = mont_reduction_loop_div_r pbits rLen n mu c in /// res % n == c * d % n /\ res <= (c - n) / r + n) val mont_reduction_lemma_step_bound_aux: pbits:pos -> n:pos -> q_i:nat{q_i < pow2 pbits} -> i:pos -> c:nat -> res0:nat -> Lemma (requires res0 <= c + (pow2 (pbits * (i - 1)) - 1) * n) (ensures res0 + n * q_i * pow2 (pbits * (i - 1)) <= c + (pow2 (pbits * i) - 1) * n) let mont_reduction_lemma_step_bound_aux pbits n q_i i c res0 = let b = pow2 (pbits * i) in let b1 = pow2 (pbits * (i - 1)) in calc (<=) { res0 + n * q_i * b1; (<=) { Math.Lemmas.lemma_mult_le_right b1 q_i (pow2 pbits - 1) } res0 + n * (pow2 pbits - 1) * b1; (==) { Math.Lemmas.paren_mul_right n (pow2 pbits - 1) b1 } res0 + n * ((pow2 pbits - 1) * b1); (==) { Math.Lemmas.distributivity_sub_left (pow2 pbits) 1 b1 } res0 + n * (pow2 pbits * b1 - b1); (==) { Math.Lemmas.pow2_plus pbits (pbits * (i - 1)) } res0 + n * (b - b1); (==) { Math.Lemmas.distributivity_sub_right n b b1 } res0 + n * b - n * b1; (<=) { } c + (b1 - 1) * n + n * b - n * b1; (==) { Math.Lemmas.distributivity_sub_left b1 1 n } c + b1 * n - n + n * b - n * b1; (==) { } c - n + b * n; (==) { Math.Lemmas.distributivity_sub_left b 1 n } c + (b - 1) * n; } val mont_reduction_lemma_step_bound: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> i:pos{i <= rLen} -> c:nat -> res0:nat -> Lemma (requires res0 <= c + (pow2 (pbits * (i - 1)) - 1) * n) (ensures mont_reduction_f pbits rLen n mu (i - 1) res0 <= c + (pow2 (pbits * i) - 1) * n) let mont_reduction_lemma_step_bound pbits rLen n mu i c res0 = let res = mont_reduction_f pbits rLen n mu (i - 1) res0 in let c_i = res0 / pow2 (pbits * (i - 1)) % pow2 pbits in let q_i = mu * c_i % pow2 pbits in assert (res == res0 + n * q_i * pow2 (pbits * (i - 1))); mont_reduction_lemma_step_bound_aux pbits n q_i i c res0; assert (res <= c + (pow2 (pbits * i) - 1) * n) val mont_reduction_lemma_step_mod_pbits: pbits:pos -> n:pos -> mu:nat -> c_i:nat -> Lemma (requires (1 + n * mu) % pow2 pbits == 0) (ensures (c_i + n * (mu * c_i % pow2 pbits)) % pow2 pbits == 0) let mont_reduction_lemma_step_mod_pbits pbits n mu c_i = let r = pow2 pbits in let q_i = mu * c_i % r in calc (==) { (c_i + n * q_i) % r; (==) { Math.Lemmas.lemma_mod_plus_distr_r c_i (n * q_i) r } (c_i + n * q_i % r) % r; (==) { } (c_i + n * (mu * c_i % r) % r) % r; (==) { Math.Lemmas.lemma_mod_mul_distr_r n (mu * c_i) r } (c_i + n * (mu * c_i) % r) % r; (==) { Math.Lemmas.lemma_mod_plus_distr_r c_i (n * (mu * c_i)) r } (c_i + n * (mu * c_i)) % r; (==) { Math.Lemmas.paren_mul_right n mu c_i } (c_i + n * mu * c_i) % r; (==) { Math.Lemmas.distributivity_add_left 1 (n * mu) c_i } ((1 + n * mu) * c_i) % r; (==) { Math.Lemmas.lemma_mod_mul_distr_l (1 + n * mu) c_i r } ((1 + n * mu) % r * c_i) % r; (==) { assert ((1 + n * mu) % r = 0) } 0; } val mont_reduction_lemma_step_modr_aux: pbits:pos -> n:pos -> q_i:nat -> i:pos -> res0:nat -> Lemma (let b1 = pow2 (pbits * (i - 1)) in (res0 / b1 * b1 + n * q_i * b1) % pow2 (pbits * i) == (res0 / b1 % pow2 pbits + n * q_i) % pow2 pbits * b1) let mont_reduction_lemma_step_modr_aux pbits n q_i i res0 = let b1 = pow2 (pbits * (i - 1)) in Math.Lemmas.distributivity_sub_right pbits i 1; assert (pbits * i - pbits * (i - 1) == pbits); calc (==) { (res0 / b1 * b1 + n * q_i * b1) % pow2 (pbits * i); (==) { Math.Lemmas.distributivity_add_left (res0 / b1) (n * q_i) b1 } (res0 / b1 + n * q_i) * b1 % pow2 (pbits * i); (==) { Math.Lemmas.pow2_multiplication_modulo_lemma_2 (res0 / b1 + n * q_i) (pbits * i) (pbits * (i - 1)) } (res0 / b1 + n * q_i) % pow2 pbits * b1; (==) { Math.Lemmas.lemma_mod_plus_distr_l (res0 / b1) (n * q_i) (pow2 pbits) } (res0 / b1 % pow2 pbits + n * q_i) % pow2 pbits * b1; } val mont_reduction_lemma_step_modr: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> i:pos{i <= rLen} -> res0:nat -> Lemma (requires res0 % pow2 (pbits * (i - 1)) == 0 /\ (1 + n * mu) % pow2 pbits == 0) (ensures mont_reduction_f pbits rLen n mu (i - 1) res0 % pow2 (pbits * i) == 0) let mont_reduction_lemma_step_modr pbits rLen n mu i res0 = let b1 = pow2 (pbits * (i - 1)) in let res = mont_reduction_f pbits rLen n mu (i - 1) res0 in let c_i = res0 / b1 % pow2 pbits in let q_i = mu * c_i % pow2 pbits in Math.Lemmas.lemma_div_exact res0 b1; mont_reduction_lemma_step_modr_aux pbits n q_i i res0; mont_reduction_lemma_step_mod_pbits pbits n mu c_i val mont_reduction_lemma_step_modn: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> i:pos{i <= rLen} -> c:nat -> res0:nat -> Lemma (requires res0 % n == c % n) (ensures mont_reduction_f pbits rLen n mu (i - 1) res0 % n == c % n) let mont_reduction_lemma_step_modn pbits rLen n mu i c res0 = let res = mont_reduction_f pbits rLen n mu (i - 1) res0 in let c_i = res0 / pow2 (pbits * (i - 1)) % pow2 pbits in let q_i = mu * c_i % pow2 pbits in assert (res == res0 + n * q_i * pow2 (pbits * (i - 1))); Math.Lemmas.paren_mul_right n q_i (pow2 (pbits * (i - 1))); Math.Lemmas.modulo_addition_lemma res0 n (q_i * pow2 (pbits * (i - 1))) val mont_reduction_lemma_step: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> i:pos{i <= rLen} -> c:nat -> res0:nat -> Lemma (requires res0 % n == c % n /\ res0 % pow2 (pbits * (i - 1)) == 0 /\ res0 <= c + (pow2 (pbits * (i - 1)) - 1) * n /\ (1 + n * mu) % pow2 pbits == 0) (ensures (let res = mont_reduction_f pbits rLen n mu (i - 1) res0 in res % n == c % n /\ res % pow2 (pbits * i) == 0 /\ res <= c + (pow2 (pbits * i) - 1) * n)) let mont_reduction_lemma_step pbits rLen n mu i c res0 = mont_reduction_lemma_step_bound pbits rLen n mu i c res0; mont_reduction_lemma_step_modr pbits rLen n mu i res0; mont_reduction_lemma_step_modn pbits rLen n mu i c res0 val mont_reduction_loop_lemma: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> i:nat{i <= rLen} -> c:nat -> Lemma (requires (1 + n * mu) % pow2 pbits == 0) (ensures (let res = repeati i (mont_reduction_f pbits rLen n mu) c in res % n == c % n /\ res % pow2 (pbits * i) == 0 /\ res <= c + (pow2 (pbits * i) - 1) * n)) let rec mont_reduction_loop_lemma pbits rLen n mu i c = let res : nat = repeati i (mont_reduction_f pbits rLen n mu) c in if i = 0 then eq_repeati0 i (mont_reduction_f pbits rLen n mu) c else begin unfold_repeati i (mont_reduction_f pbits rLen n mu) c (i - 1); let res0 : nat = repeati (i - 1) (mont_reduction_f pbits rLen n mu) c in mont_reduction_loop_lemma pbits rLen n mu (i - 1) c; mont_reduction_lemma_step pbits rLen n mu i c res0 end val mont_reduction_loop_div_r_fits_lemma: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> c:nat -> Lemma (requires (let r = pow2 (pbits * rLen) in (1 + n * mu) % pow2 pbits == 0)) (ensures (let res = mont_reduction_loop_div_r pbits rLen n mu c in let r = pow2 (pbits * rLen) in res <= (c - n) / r + n)) let mont_reduction_loop_div_r_fits_lemma pbits rLen n mu c = let r = pow2 (pbits * rLen) in let res : nat = repeati rLen (mont_reduction_f pbits rLen n mu) c in mont_reduction_loop_lemma pbits rLen n mu rLen c; assert (res % n == c % n /\ res % r == 0 /\ res <= c + (r - 1) * n); Math.Lemmas.lemma_div_le res (c + (r - 1) * n) r; assert (res / r <= (c + (r - 1) * n) / r); calc (==) { (c + (r - 1) * n) / r; (==) { Math.Lemmas.distributivity_sub_left r 1 n } (c - n + r * n) / r; (==) { Math.Lemmas.division_addition_lemma (c - n) r n } (c - n) / r + n; }; assert (res / r <= (c - n) / r + n) val mont_reduction_loop_div_r_eval_lemma: pbits:pos -> rLen:nat -> n:pos -> d:int -> mu:nat -> c:nat -> Lemma (requires (let r = pow2 (pbits * rLen) in (1 + n * mu) % pow2 pbits == 0 /\ r * d % n == 1)) (ensures (let res = mont_reduction_loop_div_r pbits rLen n mu c in res % n == c * d % n)) let mont_reduction_loop_div_r_eval_lemma pbits rLen n d mu c = let r = pow2 (pbits * rLen) in let res : nat = repeati rLen (mont_reduction_f pbits rLen n mu) c in mont_reduction_loop_lemma pbits rLen n mu rLen c; assert (res % n == c % n /\ res % r == 0 /\ res <= c + (r - 1) * n); calc (==) { res / r % n; (==) { assert (r * d % n == 1) } res / r * (r * d % n) % n; (==) { Math.Lemmas.lemma_mod_mul_distr_r (res / r) (r * d) n } res / r * (r * d) % n; (==) { Math.Lemmas.paren_mul_right (res / r) r d } res / r * r * d % n; (==) { Math.Lemmas.div_exact_r res r } res * d % n; (==) { Math.Lemmas.lemma_mod_mul_distr_l res d n } res % n * d % n; (==) { assert (res % n == c % n) } c % n * d % n; (==) { Math.Lemmas.lemma_mod_mul_distr_l c d n } c * d % n; }; assert (res / r % n == c * d % n)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Montgomery.Lemmas.fst" }
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
pbits: Prims.pos -> rLen: Prims.pos -> n: Prims.pos -> mu: Prims.nat -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "Prims.nat", "Prims.l_and", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.pow2", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Equality", "Prims.logical" ]
[]
false
false
false
true
true
let mont_pre (pbits rLen n: pos) (mu: nat) =
(1 + n * mu) % pow2 pbits == 0 /\ 1 < n /\ n < pow2 (pbits * rLen) /\ n % 2 = 1
false
Hacl.Spec.Montgomery.Lemmas.fst
Hacl.Spec.Montgomery.Lemmas.mont_reduction_lemma_step_modn
val mont_reduction_lemma_step_modn: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> i:pos{i <= rLen} -> c:nat -> res0:nat -> Lemma (requires res0 % n == c % n) (ensures mont_reduction_f pbits rLen n mu (i - 1) res0 % n == c % n)
val mont_reduction_lemma_step_modn: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> i:pos{i <= rLen} -> c:nat -> res0:nat -> Lemma (requires res0 % n == c % n) (ensures mont_reduction_f pbits rLen n mu (i - 1) res0 % n == c % n)
let mont_reduction_lemma_step_modn pbits rLen n mu i c res0 = let res = mont_reduction_f pbits rLen n mu (i - 1) res0 in let c_i = res0 / pow2 (pbits * (i - 1)) % pow2 pbits in let q_i = mu * c_i % pow2 pbits in assert (res == res0 + n * q_i * pow2 (pbits * (i - 1))); Math.Lemmas.paren_mul_right n q_i (pow2 (pbits * (i - 1))); Math.Lemmas.modulo_addition_lemma res0 n (q_i * pow2 (pbits * (i - 1)))
{ "file_name": "code/bignum/Hacl.Spec.Montgomery.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 73, "end_line": 365, "start_col": 0, "start_line": 359 }
module Hacl.Spec.Montgomery.Lemmas open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators (** https://members.loria.fr/PZimmermann/mca/mca-cup-0.5.9.pdf https://eprint.iacr.org/2011/239.pdf https://eprint.iacr.org/2017/1057.pdf *) #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val eea_pow2_odd_k_lemma_d: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let d = n * k1 / pow2 (a - 1) in d % 2 == (if n * k1 % pow2 a < pow2 (a - 1) then 0 else 1))) let eea_pow2_odd_k_lemma_d a n k1 = let d = n * k1 / pow2 (a - 1) in Math.Lemmas.pow2_modulo_division_lemma_1 (n * k1) (a - 1) a; assert (d % 2 == n * k1 % pow2 a / pow2 (a - 1)); if d % 2 = 0 then begin Math.Lemmas.small_division_lemma_2 (n * k1 % pow2 a) (pow2 (a - 1)); assert (n * k1 % pow2 a < pow2 (a - 1)); () end #push-options "--z3rlimit 100" val eea_pow2_odd_k_lemma: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in n * k % pow2 a == 1)) let eea_pow2_odd_k_lemma a n k1 = let d = n * k1 / pow2 (a - 1) in let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in calc (==) { n * k1; (==) { Math.Lemmas.euclidean_division_definition (n * k1) (pow2 (a - 1)) } 1 + d * pow2 (a - 1); (==) { Math.Lemmas.euclidean_division_definition d 2 } 1 + (d / 2 * 2 + d % 2) * pow2 (a - 1); (==) { Math.Lemmas.distributivity_add_left (d / 2 * 2) (d % 2) (pow2 (a - 1)) } 1 + d / 2 * 2 * pow2 (a - 1) + d % 2 * pow2 (a - 1); (==) { Math.Lemmas.pow2_plus 1 (a - 1) } 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1); }; assert (n * k1 == 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1)); if n * k1 % pow2 a < pow2 (a - 1) then begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 0); calc (==) { n * k % pow2 a; (==) { } (1 + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) (d / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a = 1); () end else begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 1); assert (n * k1 == 1 + d / 2 * pow2 a + pow2 (a - 1)); //assert (n * k == 1 + d / 2 * pow2 a + pow2 (a - 1) + n * pow2 (a - 1)); calc (==) { n * k % pow2 a; (==) { Math.Lemmas.distributivity_add_right n k1 (pow2 (a - 1)) } (n * k1 + n * pow2 (a - 1)) % pow2 a; (==) { } (1 + pow2 (a - 1) + n * pow2 (a - 1) + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma (1 + pow2 (a - 1) + n * pow2 (a - 1)) (pow2 a) (d / 2) } (1 + pow2 (a - 1) + n * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.distributivity_add_left 1 n (pow2 (a - 1)) } (1 + (1 + n) * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.lemma_div_exact (1 + n) 2 } (1 + (1 + n) / 2 * 2 * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.paren_mul_right ((1 + n) / 2) 2 (pow2 (a - 1)) } (1 + (1 + n) / 2 * (2 * pow2 (a - 1))) % pow2 a; (==) { Math.Lemmas.pow2_plus 1 (a - 1)} (1 + (1 + n) / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) ((1 + n) / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a == 1); () end #pop-options val eea_pow2_odd_k_lemma_bound: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1 /\ k1 < pow2 (a - 1)) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in k < pow2 a)) let eea_pow2_odd_k_lemma_bound a n k1 = if n * k1 % pow2 a < pow2 (a - 1) then Math.Lemmas.pow2_lt_compat a (a - 1) else Math.Lemmas.pow2_double_sum (a - 1) val eea_pow2_odd_k: a:pos -> n:pos -> Pure pos (requires n % 2 = 1) (ensures fun k -> n * k % pow2 a == 1 /\ k < pow2 a) let rec eea_pow2_odd_k a n = if a = 1 then 1 else begin let k1 = eea_pow2_odd_k (a - 1) n in assert (n * k1 % pow2 (a - 1) == 1); let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in eea_pow2_odd_k_lemma a n k1; eea_pow2_odd_k_lemma_bound a n k1; assert (n * k % pow2 a == 1); k end val eea_pow2_odd: a:pos -> n:pos -> Pure (tuple2 int int) (requires n % 2 = 1) (ensures fun (d, k) -> pow2 a * d == 1 + k * n /\ - d < n) let eea_pow2_odd a n = let k = eea_pow2_odd_k a n in assert (n * k % pow2 a == 1); assert (n * k == n * k / pow2 a * pow2 a + 1); let d = n * k / pow2 a in Math.Lemmas.lemma_mult_lt_left n k (pow2 a); assert (n * k < n * pow2 a); Math.Lemmas.cancel_mul_div n (pow2 a); assert (d < n); assert (n * k == d * pow2 a + 1); (- d, - k) val mont_preconditions_d: pbits:pos -> rLen:pos -> n:pos{1 < n} -> Lemma (requires n % 2 = 1) (ensures (let d, k = eea_pow2_odd (pbits * rLen) n in pow2 (pbits * rLen) * d % n == 1)) let mont_preconditions_d pbits rLen n = let d, k = eea_pow2_odd (pbits * rLen) n in calc (==) { pow2 (pbits * rLen) * d % n; (==) { } (1 + k * n) % n; (==) { Math.Lemmas.modulo_addition_lemma 1 n k } 1 % n; (==) { Math.Lemmas.small_mod 1 n } 1; }; assert (pow2 (pbits * rLen) * d % n == 1) val mont_preconditions_n0: pbits:pos -> n:pos{n > 1} -> mu:nat -> Lemma (requires (1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) (ensures (1 + n * mu) % pow2 pbits == 0) let mont_preconditions_n0 pbits n mu = calc (==) { (1 + n * mu) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_plus_distr_r 1 (n * mu) (pow2 pbits) } (1 + n * mu % pow2 pbits) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_mul_distr_l n mu (pow2 pbits) } (1 + n % pow2 pbits * mu % pow2 pbits) % pow2 pbits; (==) { Math.Lemmas.lemma_mod_plus_distr_r 1 (n % pow2 pbits * mu) (pow2 pbits) } (1 + n % pow2 pbits * mu) % pow2 pbits; (==) { assert ((1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) } 0; }; assert ((1 + n * mu) % pow2 pbits == 0) val mont_preconditions: pbits:pos -> rLen:pos -> n:pos{1 < n} -> mu:nat -> Lemma (requires n % 2 = 1 /\ (1 + (n % pow2 pbits) * mu) % pow2 pbits == 0) (ensures (let r = pow2 (pbits * rLen) in let d, _ = eea_pow2_odd (pbits * rLen) n in r * d % n == 1 /\ (1 + n * mu) % pow2 pbits == 0)) let mont_preconditions pbits rLen n mu = mont_preconditions_d pbits rLen n; mont_preconditions_n0 pbits n mu /// High-level specification of Montgomery arithmetic val mont_reduction_f: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> i:nat{i < rLen} -> c:nat -> nat let mont_reduction_f pbits rLen n mu i c = let c_i = c / pow2 (pbits * i) % pow2 pbits in let q_i = mu * c_i % pow2 pbits in let res = c + n * q_i * pow2 (pbits * i) in res val mont_reduction_loop_div_r: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> c:nat -> nat let mont_reduction_loop_div_r pbits rLen n mu c = let res = repeati rLen (mont_reduction_f pbits rLen n mu) c in let res = res / pow2 (pbits * rLen) in res val mont_reduction: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> c:nat -> nat let mont_reduction pbits rLen n mu c = let res = mont_reduction_loop_div_r pbits rLen n mu c in if res < n then res else res - n val to_mont: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> a:nat -> nat let to_mont pbits rLen n mu a = let r2 = pow2 (2 * pbits * rLen) % n in let c = a * r2 in mont_reduction pbits rLen n mu c val from_mont: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> aM:nat -> nat let from_mont pbits rLen n mu aM = mont_reduction pbits rLen n mu aM val mont_mul: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> a:nat -> b:nat -> nat let mont_mul pbits rLen n mu a b = let c = a * b in mont_reduction pbits rLen n mu c val mont_sqr: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> a:nat -> nat let mont_sqr pbits rLen n mu a = mont_mul pbits rLen n mu a a val mont_one: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> nat let mont_one pbits rLen n mu = let r2 = pow2 (2 * pbits * rLen) % n in mont_reduction pbits rLen n mu r2 /// Lemma (let res = mont_reduction_loop_div_r pbits rLen n mu c in /// res % n == c * d % n /\ res <= (c - n) / r + n) val mont_reduction_lemma_step_bound_aux: pbits:pos -> n:pos -> q_i:nat{q_i < pow2 pbits} -> i:pos -> c:nat -> res0:nat -> Lemma (requires res0 <= c + (pow2 (pbits * (i - 1)) - 1) * n) (ensures res0 + n * q_i * pow2 (pbits * (i - 1)) <= c + (pow2 (pbits * i) - 1) * n) let mont_reduction_lemma_step_bound_aux pbits n q_i i c res0 = let b = pow2 (pbits * i) in let b1 = pow2 (pbits * (i - 1)) in calc (<=) { res0 + n * q_i * b1; (<=) { Math.Lemmas.lemma_mult_le_right b1 q_i (pow2 pbits - 1) } res0 + n * (pow2 pbits - 1) * b1; (==) { Math.Lemmas.paren_mul_right n (pow2 pbits - 1) b1 } res0 + n * ((pow2 pbits - 1) * b1); (==) { Math.Lemmas.distributivity_sub_left (pow2 pbits) 1 b1 } res0 + n * (pow2 pbits * b1 - b1); (==) { Math.Lemmas.pow2_plus pbits (pbits * (i - 1)) } res0 + n * (b - b1); (==) { Math.Lemmas.distributivity_sub_right n b b1 } res0 + n * b - n * b1; (<=) { } c + (b1 - 1) * n + n * b - n * b1; (==) { Math.Lemmas.distributivity_sub_left b1 1 n } c + b1 * n - n + n * b - n * b1; (==) { } c - n + b * n; (==) { Math.Lemmas.distributivity_sub_left b 1 n } c + (b - 1) * n; } val mont_reduction_lemma_step_bound: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> i:pos{i <= rLen} -> c:nat -> res0:nat -> Lemma (requires res0 <= c + (pow2 (pbits * (i - 1)) - 1) * n) (ensures mont_reduction_f pbits rLen n mu (i - 1) res0 <= c + (pow2 (pbits * i) - 1) * n) let mont_reduction_lemma_step_bound pbits rLen n mu i c res0 = let res = mont_reduction_f pbits rLen n mu (i - 1) res0 in let c_i = res0 / pow2 (pbits * (i - 1)) % pow2 pbits in let q_i = mu * c_i % pow2 pbits in assert (res == res0 + n * q_i * pow2 (pbits * (i - 1))); mont_reduction_lemma_step_bound_aux pbits n q_i i c res0; assert (res <= c + (pow2 (pbits * i) - 1) * n) val mont_reduction_lemma_step_mod_pbits: pbits:pos -> n:pos -> mu:nat -> c_i:nat -> Lemma (requires (1 + n * mu) % pow2 pbits == 0) (ensures (c_i + n * (mu * c_i % pow2 pbits)) % pow2 pbits == 0) let mont_reduction_lemma_step_mod_pbits pbits n mu c_i = let r = pow2 pbits in let q_i = mu * c_i % r in calc (==) { (c_i + n * q_i) % r; (==) { Math.Lemmas.lemma_mod_plus_distr_r c_i (n * q_i) r } (c_i + n * q_i % r) % r; (==) { } (c_i + n * (mu * c_i % r) % r) % r; (==) { Math.Lemmas.lemma_mod_mul_distr_r n (mu * c_i) r } (c_i + n * (mu * c_i) % r) % r; (==) { Math.Lemmas.lemma_mod_plus_distr_r c_i (n * (mu * c_i)) r } (c_i + n * (mu * c_i)) % r; (==) { Math.Lemmas.paren_mul_right n mu c_i } (c_i + n * mu * c_i) % r; (==) { Math.Lemmas.distributivity_add_left 1 (n * mu) c_i } ((1 + n * mu) * c_i) % r; (==) { Math.Lemmas.lemma_mod_mul_distr_l (1 + n * mu) c_i r } ((1 + n * mu) % r * c_i) % r; (==) { assert ((1 + n * mu) % r = 0) } 0; } val mont_reduction_lemma_step_modr_aux: pbits:pos -> n:pos -> q_i:nat -> i:pos -> res0:nat -> Lemma (let b1 = pow2 (pbits * (i - 1)) in (res0 / b1 * b1 + n * q_i * b1) % pow2 (pbits * i) == (res0 / b1 % pow2 pbits + n * q_i) % pow2 pbits * b1) let mont_reduction_lemma_step_modr_aux pbits n q_i i res0 = let b1 = pow2 (pbits * (i - 1)) in Math.Lemmas.distributivity_sub_right pbits i 1; assert (pbits * i - pbits * (i - 1) == pbits); calc (==) { (res0 / b1 * b1 + n * q_i * b1) % pow2 (pbits * i); (==) { Math.Lemmas.distributivity_add_left (res0 / b1) (n * q_i) b1 } (res0 / b1 + n * q_i) * b1 % pow2 (pbits * i); (==) { Math.Lemmas.pow2_multiplication_modulo_lemma_2 (res0 / b1 + n * q_i) (pbits * i) (pbits * (i - 1)) } (res0 / b1 + n * q_i) % pow2 pbits * b1; (==) { Math.Lemmas.lemma_mod_plus_distr_l (res0 / b1) (n * q_i) (pow2 pbits) } (res0 / b1 % pow2 pbits + n * q_i) % pow2 pbits * b1; } val mont_reduction_lemma_step_modr: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> i:pos{i <= rLen} -> res0:nat -> Lemma (requires res0 % pow2 (pbits * (i - 1)) == 0 /\ (1 + n * mu) % pow2 pbits == 0) (ensures mont_reduction_f pbits rLen n mu (i - 1) res0 % pow2 (pbits * i) == 0) let mont_reduction_lemma_step_modr pbits rLen n mu i res0 = let b1 = pow2 (pbits * (i - 1)) in let res = mont_reduction_f pbits rLen n mu (i - 1) res0 in let c_i = res0 / b1 % pow2 pbits in let q_i = mu * c_i % pow2 pbits in Math.Lemmas.lemma_div_exact res0 b1; mont_reduction_lemma_step_modr_aux pbits n q_i i res0; mont_reduction_lemma_step_mod_pbits pbits n mu c_i val mont_reduction_lemma_step_modn: pbits:pos -> rLen:nat -> n:pos -> mu:nat -> i:pos{i <= rLen} -> c:nat -> res0:nat -> Lemma (requires res0 % n == c % n) (ensures mont_reduction_f pbits rLen n mu (i - 1) res0 % n == c % n)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Montgomery.Lemmas.fst" }
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
pbits: Prims.pos -> rLen: Prims.nat -> n: Prims.pos -> mu: Prims.nat -> i: Prims.pos{i <= rLen} -> c: Prims.nat -> res0: Prims.nat -> FStar.Pervasives.Lemma (requires res0 % n == c % n) (ensures Hacl.Spec.Montgomery.Lemmas.mont_reduction_f pbits rLen n mu (i - 1) res0 % n == c % n)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.pos", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Math.Lemmas.modulo_addition_lemma", "FStar.Mul.op_Star", "Prims.pow2", "Prims.op_Subtraction", "Prims.unit", "FStar.Math.Lemmas.paren_mul_right", "Prims._assert", "Prims.eq2", "Prims.int", "Prims.op_Addition", "Prims.op_Modulus", "Prims.op_Division", "Hacl.Spec.Montgomery.Lemmas.mont_reduction_f" ]
[]
true
false
true
false
false
let mont_reduction_lemma_step_modn pbits rLen n mu i c res0 =
let res = mont_reduction_f pbits rLen n mu (i - 1) res0 in let c_i = res0 / pow2 (pbits * (i - 1)) % pow2 pbits in let q_i = mu * c_i % pow2 pbits in assert (res == res0 + (n * q_i) * pow2 (pbits * (i - 1))); Math.Lemmas.paren_mul_right n q_i (pow2 (pbits * (i - 1))); Math.Lemmas.modulo_addition_lemma res0 n (q_i * pow2 (pbits * (i - 1)))
false
Hacl.Spec.Montgomery.Lemmas.fst
Hacl.Spec.Montgomery.Lemmas.eea_pow2_odd
val eea_pow2_odd: a:pos -> n:pos -> Pure (tuple2 int int) (requires n % 2 = 1) (ensures fun (d, k) -> pow2 a * d == 1 + k * n /\ - d < n)
val eea_pow2_odd: a:pos -> n:pos -> Pure (tuple2 int int) (requires n % 2 = 1) (ensures fun (d, k) -> pow2 a * d == 1 + k * n /\ - d < n)
let eea_pow2_odd a n = let k = eea_pow2_odd_k a n in assert (n * k % pow2 a == 1); assert (n * k == n * k / pow2 a * pow2 a + 1); let d = n * k / pow2 a in Math.Lemmas.lemma_mult_lt_left n k (pow2 a); assert (n * k < n * pow2 a); Math.Lemmas.cancel_mul_div n (pow2 a); assert (d < n); assert (n * k == d * pow2 a + 1); (- d, - k)
{ "file_name": "code/bignum/Hacl.Spec.Montgomery.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 12, "end_line": 144, "start_col": 0, "start_line": 134 }
module Hacl.Spec.Montgomery.Lemmas open FStar.Mul open Lib.IntTypes open Lib.LoopCombinators (** https://members.loria.fr/PZimmermann/mca/mca-cup-0.5.9.pdf https://eprint.iacr.org/2011/239.pdf https://eprint.iacr.org/2017/1057.pdf *) #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" val eea_pow2_odd_k_lemma_d: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let d = n * k1 / pow2 (a - 1) in d % 2 == (if n * k1 % pow2 a < pow2 (a - 1) then 0 else 1))) let eea_pow2_odd_k_lemma_d a n k1 = let d = n * k1 / pow2 (a - 1) in Math.Lemmas.pow2_modulo_division_lemma_1 (n * k1) (a - 1) a; assert (d % 2 == n * k1 % pow2 a / pow2 (a - 1)); if d % 2 = 0 then begin Math.Lemmas.small_division_lemma_2 (n * k1 % pow2 a) (pow2 (a - 1)); assert (n * k1 % pow2 a < pow2 (a - 1)); () end #push-options "--z3rlimit 100" val eea_pow2_odd_k_lemma: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in n * k % pow2 a == 1)) let eea_pow2_odd_k_lemma a n k1 = let d = n * k1 / pow2 (a - 1) in let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in calc (==) { n * k1; (==) { Math.Lemmas.euclidean_division_definition (n * k1) (pow2 (a - 1)) } 1 + d * pow2 (a - 1); (==) { Math.Lemmas.euclidean_division_definition d 2 } 1 + (d / 2 * 2 + d % 2) * pow2 (a - 1); (==) { Math.Lemmas.distributivity_add_left (d / 2 * 2) (d % 2) (pow2 (a - 1)) } 1 + d / 2 * 2 * pow2 (a - 1) + d % 2 * pow2 (a - 1); (==) { Math.Lemmas.pow2_plus 1 (a - 1) } 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1); }; assert (n * k1 == 1 + d / 2 * pow2 a + d % 2 * pow2 (a - 1)); if n * k1 % pow2 a < pow2 (a - 1) then begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 0); calc (==) { n * k % pow2 a; (==) { } (1 + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) (d / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a = 1); () end else begin eea_pow2_odd_k_lemma_d a n k1; assert (d % 2 = 1); assert (n * k1 == 1 + d / 2 * pow2 a + pow2 (a - 1)); //assert (n * k == 1 + d / 2 * pow2 a + pow2 (a - 1) + n * pow2 (a - 1)); calc (==) { n * k % pow2 a; (==) { Math.Lemmas.distributivity_add_right n k1 (pow2 (a - 1)) } (n * k1 + n * pow2 (a - 1)) % pow2 a; (==) { } (1 + pow2 (a - 1) + n * pow2 (a - 1) + d / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma (1 + pow2 (a - 1) + n * pow2 (a - 1)) (pow2 a) (d / 2) } (1 + pow2 (a - 1) + n * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.distributivity_add_left 1 n (pow2 (a - 1)) } (1 + (1 + n) * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.lemma_div_exact (1 + n) 2 } (1 + (1 + n) / 2 * 2 * pow2 (a - 1)) % pow2 a; (==) { Math.Lemmas.paren_mul_right ((1 + n) / 2) 2 (pow2 (a - 1)) } (1 + (1 + n) / 2 * (2 * pow2 (a - 1))) % pow2 a; (==) { Math.Lemmas.pow2_plus 1 (a - 1)} (1 + (1 + n) / 2 * pow2 a) % pow2 a; (==) { Math.Lemmas.modulo_addition_lemma 1 (pow2 a) ((1 + n) / 2) } 1 % pow2 a; (==) { Math.Lemmas.pow2_le_compat a 1; Math.Lemmas.small_mod 1 (pow2 a) } 1; }; assert (n * k % pow2 a == 1); () end #pop-options val eea_pow2_odd_k_lemma_bound: a:pos -> n:pos -> k1:pos -> Lemma (requires n * k1 % pow2 (a - 1) == 1 /\ n % 2 = 1 /\ k1 < pow2 (a - 1)) (ensures (let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in k < pow2 a)) let eea_pow2_odd_k_lemma_bound a n k1 = if n * k1 % pow2 a < pow2 (a - 1) then Math.Lemmas.pow2_lt_compat a (a - 1) else Math.Lemmas.pow2_double_sum (a - 1) val eea_pow2_odd_k: a:pos -> n:pos -> Pure pos (requires n % 2 = 1) (ensures fun k -> n * k % pow2 a == 1 /\ k < pow2 a) let rec eea_pow2_odd_k a n = if a = 1 then 1 else begin let k1 = eea_pow2_odd_k (a - 1) n in assert (n * k1 % pow2 (a - 1) == 1); let k = if n * k1 % pow2 a < pow2 (a - 1) then k1 else k1 + pow2 (a - 1) in eea_pow2_odd_k_lemma a n k1; eea_pow2_odd_k_lemma_bound a n k1; assert (n * k % pow2 a == 1); k end val eea_pow2_odd: a:pos -> n:pos -> Pure (tuple2 int int) (requires n % 2 = 1) (ensures fun (d, k) -> pow2 a * d == 1 + k * n /\ - d < n)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Montgomery.Lemmas.fst" }
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Montgomery", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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: Prims.pos -> n: Prims.pos -> Prims.Pure (Prims.int * Prims.int)
Prims.Pure
[]
[]
[ "Prims.pos", "FStar.Pervasives.Native.Mktuple2", "Prims.int", "Prims.op_Minus", "Prims.unit", "Prims._assert", "Prims.eq2", "FStar.Mul.op_Star", "Prims.op_Addition", "Prims.pow2", "Prims.b2t", "Prims.op_LessThan", "FStar.Math.Lemmas.cancel_mul_div", "FStar.Math.Lemmas.lemma_mult_lt_left", "Prims.op_Division", "Prims.op_Modulus", "Hacl.Spec.Montgomery.Lemmas.eea_pow2_odd_k", "FStar.Pervasives.Native.tuple2" ]
[]
false
false
false
false
false
let eea_pow2_odd a n =
let k = eea_pow2_odd_k a n in assert (n * k % pow2 a == 1); assert (n * k == (n * k / pow2 a) * pow2 a + 1); let d = n * k / pow2 a in Math.Lemmas.lemma_mult_lt_left n k (pow2 a); assert (n * k < n * pow2 a); Math.Lemmas.cancel_mul_div n (pow2 a); assert (d < n); assert (n * k == d * pow2 a + 1); (- d, - k)
false
Vale.Transformers.Transform.fsti
Vale.Transformers.Transform.equiv_states
val equiv_states : s1: Vale.X64.Decls.va_state -> s2: Vale.X64.Decls.va_state -> Prims.logical
let equiv_states (s1 s2:va_state) = equiv_states s1 s2
{ "file_name": "vale/code/lib/transformers/Vale.Transformers.Transform.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 61, "end_line": 29, "start_col": 7, "start_line": 29 }
(** This module exposes user-friendly transformers and lemmas for them. Each transformation takes 1 or more [va_code] object(s) and produces a [va_code] object, along with additional data. The lemma guarantees that the produced [va_code] object is semantically identical to the (first, if more than one) provided [va_code] object. The additional data that is generated is always a [pbool] which is [ttrue] if the transformation succeeded, and otherwise is a [ffalse reason]. Under both circumstances, the lemma mentioned above is held, and in particular, a failed transformation is still safe to use (since in that case, the code returned is exactly the same as the first [va_code] object). The additional data is provided only for debugging, since we expect that after debugging and fixing things, all transformations will succeed. *) module Vale.Transformers.Transform open Vale.X64.Machine_s open Vale.Def.PossiblyMonad open Vale.X64.Decls open Vale.Transformers.Common
{ "checked_file": "/", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Transformers.Common.fsti.checked", "Vale.Def.PossiblyMonad.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.Transformers.Transform.fsti" }
[ { "abbrev": false, "full_module": "Vale.Transformers.Common", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.PossiblyMonad", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Transformers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Transformers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "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
s1: Vale.X64.Decls.va_state -> s2: Vale.X64.Decls.va_state -> Prims.logical
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_state", "Vale.Transformers.Common.equiv_states", "Prims.logical" ]
[]
false
false
false
true
true
let equiv_states (s1 s2: va_state) =
equiv_states s1 s2
false
Hacl.Bignum.MontArithmetic.fsti
Hacl.Bignum.MontArithmetic.bn_field_inv_st
val bn_field_inv_st : t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0
let bn_field_inv_st (t:limb_t) (len:BN.meta_len t) = k:pbn_mont_ctx t -> aM:lbignum t len -> aInvM:lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ Euclid.is_prime (bn_v_n h k) /\ 0 < bn_v h aM /\ bn_v h aM < bn_v_n h k /\ live h aM /\ live h aInvM /\ disjoint aM aInvM /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (aInvM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc aInvM) h0 h1 /\ bn_v h1 aInvM < bn_v_n h0 k /\ as_seq h1 aInvM == S.bn_field_inv (as_pctx h0 k) (as_seq h0 aM))
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 68, "end_line": 419, "start_col": 0, "start_line": 403 }
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module Euclid = FStar.Math.Euclid module S = Hacl.Spec.Bignum.MontArithmetic module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val _align_fsti : unit inline_for_extraction noextract let lb (t:limb_t) = match t with | U32 -> buffer uint32 | U64 -> buffer uint64 inline_for_extraction noextract let ll (t:limb_t) = match t with | U32 -> uint32 | U64 -> uint64 inline_for_extraction noeq type bn_mont_ctx' (t:limb_t) (a:Type0{a == lb t}) (b:Type0{b == ll t}) = { len: BN.meta_len t; n: x:a{length #MUT #(limb t) x == v len}; mu: b; r2: x:a{length #MUT #(limb t) x == v len}; } inline_for_extraction noextract let bn_mont_ctx (t:limb_t) = bn_mont_ctx' t (lb t) (ll t) let bn_mont_ctx_u32 = bn_mont_ctx' U32 (lb U32) (ll U32) let bn_mont_ctx_u64 = bn_mont_ctx' U64 (lb U64) (ll U64) inline_for_extraction noextract let pbn_mont_ctx (t:limb_t) = B.pointer (bn_mont_ctx t) inline_for_extraction noextract let pbn_mont_ctx_u32 = B.pointer bn_mont_ctx_u32 inline_for_extraction noextract let pbn_mont_ctx_u64 = B.pointer bn_mont_ctx_u64 inline_for_extraction noextract let as_ctx (#t:limb_t) (h:mem) (k:bn_mont_ctx t) : GTot (S.bn_mont_ctx t) = { S.len = v k.len; S.n = as_seq h (k.n <: lbignum t k.len); S.mu = k.mu; S.r2 = as_seq h (k.r2 <: lbignum t k.len); } inline_for_extraction noextract let bn_mont_ctx_inv (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in live h n /\ live h r2 /\ disjoint n r2 /\ S.bn_mont_ctx_inv (as_ctx h k) inline_for_extraction noextract let bn_v_n (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = let k1 = B.deref h k in let n : lbignum t k1.len = k1.n in bn_v h n inline_for_extraction noextract let freeable_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.freeable n /\ B.freeable r2 inline_for_extraction noextract let freeable (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.freeable k /\ freeable_s h (B.deref h k) inline_for_extraction noextract let footprint_s (#t:limb_t) (h:mem) (k:bn_mont_ctx t) = let n : buffer (limb t) = k.n in let r2 : buffer (limb t) = k.r2 in B.(loc_union (loc_addr_of_buffer n) (loc_addr_of_buffer r2)) inline_for_extraction noextract let footprint (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.(loc_union (loc_addr_of_buffer k) (footprint_s h (B.deref h k))) inline_for_extraction noextract let as_pctx (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) : GTot (S.bn_mont_ctx t) = as_ctx h (B.deref h k) inline_for_extraction noextract let pbn_mont_ctx_inv (#t:limb_t) (h:mem) (k:pbn_mont_ctx t) = B.live h k /\ B.(loc_disjoint (loc_addr_of_buffer k) (footprint_s h (B.deref h k))) /\ bn_mont_ctx_inv h (B.deref h k) inline_for_extraction noextract let bn_field_get_len_st (t:limb_t) = k:pbn_mont_ctx t -> Stack (BN.meta_len t) (requires fun h -> pbn_mont_ctx_inv h k) (ensures fun h0 r h1 -> h0 == h1 /\ r == (B.deref h0 k).len /\ v r == S.bn_field_get_len (as_pctx h0 k)) inline_for_extraction noextract val bn_field_get_len: #t:limb_t -> bn_field_get_len_st t inline_for_extraction noextract let bn_field_check_modulus_st (t:limb_t) (len:BN.meta_len t) = n:lbignum t len -> Stack bool (requires fun h -> live h n) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_field_check_modulus (as_seq h0 n)) inline_for_extraction noextract val bn_field_check_modulus: #t:limb_t -> km:BM.mont t -> bn_field_check_modulus_st t km.BM.bn.BN.len inline_for_extraction noextract let bn_field_init_st (t:limb_t) (len:BN.meta_len t) = r:HS.rid -> n:lbignum t len -> ST (pbn_mont_ctx t) (requires fun h -> S.bn_mont_ctx_pre (as_seq h n) /\ live h n /\ ST.is_eternal_region r) (ensures fun h0 res h1 -> B.(modifies loc_none h0 h1) /\ B.(fresh_loc (footprint h1 res) h0 h1) /\ B.(loc_includes (loc_region_only true r) (footprint h1 res)) /\ freeable h1 res /\ (B.deref h1 res).len == len /\ bn_v_n h1 res == bn_v h0 n /\ S.bn_mont_ctx_inv (as_pctx h1 res) /\ as_pctx h1 res == S.bn_field_init (as_seq h0 n)) inline_for_extraction noextract val bn_field_init: #t:limb_t -> len:BN.meta_len t -> precomp_r2:BM.bn_precomp_r2_mod_n_st t len -> bn_field_init_st t len inline_for_extraction noextract let bn_field_free_st (t:limb_t) = k:pbn_mont_ctx t -> ST unit (requires fun h -> freeable h k /\ pbn_mont_ctx_inv h k) (ensures fun h0 _ h1 -> B.(modifies (footprint h0 k) h0 h1)) inline_for_extraction noextract val bn_field_free: #t:limb_t -> bn_field_free_st t inline_for_extraction noextract let bn_to_field_st (t:limb_t) (len:BN.meta_len t) = k:pbn_mont_ctx t -> a:lbignum t len -> aM:lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ live h a /\ live h aM /\ disjoint a aM /\ B.(loc_disjoint (footprint h k) (loc_buffer (a <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc aM) h0 h1 /\ bn_v h1 aM < bn_v_n h0 k /\ as_seq h1 aM == S.bn_to_field (as_pctx h0 k) (as_seq h0 a)) inline_for_extraction noextract val bn_to_field: #t:limb_t -> km:BM.mont t -> bn_to_field_st t km.BM.bn.BN.len inline_for_extraction noextract let bn_from_field_st (t:limb_t) (len:BN.meta_len t) = k:pbn_mont_ctx t -> aM:lbignum t len -> a:lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ bn_v h aM < bn_v_n h k /\ live h a /\ live h aM /\ disjoint a aM /\ B.(loc_disjoint (footprint h k) (loc_buffer (a <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc a) h0 h1 /\ bn_v h1 a < bn_v_n h0 k /\ as_seq h1 a == S.bn_from_field (as_pctx h0 k) (as_seq h0 aM)) inline_for_extraction noextract val bn_from_field: #t:limb_t -> km:BM.mont t -> bn_from_field_st t km.BM.bn.BN.len inline_for_extraction noextract let bn_field_add_st (t:limb_t) (len:BN.meta_len t) = k:pbn_mont_ctx t -> aM:lbignum t len -> bM:lbignum t len -> cM:lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ bn_v h aM < bn_v_n h k /\ bn_v h bM < bn_v_n h k /\ live h aM /\ live h bM /\ live h cM /\ eq_or_disjoint aM bM /\ eq_or_disjoint aM cM /\ eq_or_disjoint bM cM /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (bM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (cM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc cM) h0 h1 /\ bn_v h1 cM < bn_v_n h0 k /\ as_seq h1 cM == S.bn_field_add (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM)) inline_for_extraction noextract val bn_field_add: #t:limb_t -> km:BM.mont t -> bn_field_add_st t km.BM.bn.BN.len inline_for_extraction noextract let bn_field_sub_st (t:limb_t) (len:BN.meta_len t) = k:pbn_mont_ctx t -> aM:lbignum t len -> bM:lbignum t len -> cM:lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ bn_v h aM < bn_v_n h k /\ bn_v h bM < bn_v_n h k /\ live h aM /\ live h bM /\ live h cM /\ eq_or_disjoint aM bM /\ eq_or_disjoint aM cM /\ eq_or_disjoint bM cM /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (bM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (cM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc cM) h0 h1 /\ bn_v h1 cM < bn_v_n h0 k /\ as_seq h1 cM == S.bn_field_sub (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM)) inline_for_extraction noextract val bn_field_sub: #t:limb_t -> km:BM.mont t -> bn_field_sub_st t km.BM.bn.BN.len inline_for_extraction noextract let bn_field_mul_st (t:limb_t) (len:BN.meta_len t) = k:pbn_mont_ctx t -> aM:lbignum t len -> bM:lbignum t len -> cM:lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ bn_v h aM < bn_v_n h k /\ bn_v h bM < bn_v_n h k /\ live h aM /\ live h bM /\ live h cM /\ eq_or_disjoint aM bM /\ eq_or_disjoint aM cM /\ eq_or_disjoint bM cM /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (bM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (cM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc cM) h0 h1 /\ bn_v h1 cM < bn_v_n h0 k /\ as_seq h1 cM == S.bn_field_mul (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM)) inline_for_extraction noextract val bn_field_mul: #t:limb_t -> km:BM.mont t -> bn_field_mul_st t km.BM.bn.BN.len inline_for_extraction noextract let bn_field_sqr_st (t:limb_t) (len:BN.meta_len t) = k:pbn_mont_ctx t -> aM:lbignum t len -> cM:lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ bn_v h aM < bn_v_n h k /\ live h aM /\ live h cM /\ eq_or_disjoint aM cM /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (cM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc cM) h0 h1 /\ bn_v h1 cM < bn_v_n h0 k /\ as_seq h1 cM == S.bn_field_sqr (as_pctx h0 k) (as_seq h0 aM)) inline_for_extraction noextract val bn_field_sqr: #t:limb_t -> km:BM.mont t -> bn_field_sqr_st t km.BM.bn.BN.len inline_for_extraction noextract let bn_field_one_st (t:limb_t) (len:BN.meta_len t) = k:pbn_mont_ctx t -> oneM:lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ live h oneM /\ B.(loc_disjoint (footprint h k) (loc_buffer (oneM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc oneM) h0 h1 /\ bn_v h1 oneM < bn_v_n h0 k /\ as_seq h1 oneM == S.bn_field_one (as_pctx h0 k)) inline_for_extraction noextract val bn_field_one: #t:limb_t -> km:BM.mont t -> bn_field_one_st t km.BM.bn.BN.len inline_for_extraction noextract let bn_field_exp_consttime_st (t:limb_t) (len:BN.meta_len t) = k:pbn_mont_ctx t -> aM:lbignum t len -> bBits:size_t -> b:lbignum t (blocks0 bBits (size (bits t))) -> resM:lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ bn_v h aM < bn_v_n h k /\ bn_v h b < pow2 (v bBits) /\ live h aM /\ live h b /\ live h resM /\ disjoint resM aM /\ disjoint resM b /\ disjoint aM b /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (resM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc resM) h0 h1 /\ bn_v h1 resM < bn_v_n h0 k /\ as_seq h1 resM == S.bn_field_exp_consttime (as_pctx h0 k) (as_seq h0 aM) (v bBits) (as_seq h0 b)) inline_for_extraction noextract val bn_field_exp_consttime: #t:limb_t -> km:BM.mont t -> bn_field_exp_consttime_st t km.BM.bn.BN.len inline_for_extraction noextract let bn_field_exp_vartime_st (t:limb_t) (len:BN.meta_len t) = k:pbn_mont_ctx t -> aM:lbignum t len -> bBits:size_t -> b:lbignum t (blocks0 bBits (size (bits t))) -> resM:lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ bn_v h aM < bn_v_n h k /\ bn_v h b < pow2 (v bBits) /\ live h aM /\ live h b /\ live h resM /\ disjoint resM aM /\ disjoint resM b /\ disjoint aM b /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (resM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc resM) h0 h1 /\ bn_v h1 resM < bn_v_n h0 k /\ as_seq h1 resM == S.bn_field_exp_vartime (as_pctx h0 k) (as_seq h0 aM) (v bBits) (as_seq h0 b)) inline_for_extraction noextract val bn_field_exp_vartime: #t:limb_t -> km:BM.mont t -> bn_field_exp_vartime_st t km.BM.bn.BN.len
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fsti.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Euclid.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Bignum.MontArithmetic.fsti" }
[ { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.meta_len", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.Bignum.Definitions.lbignum", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.eq2", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__len", "Hacl.Bignum.MontArithmetic.lb", "Hacl.Bignum.MontArithmetic.ll", "LowStar.Monotonic.Buffer.deref", "Hacl.Bignum.MontArithmetic.bn_mont_ctx", "LowStar.Buffer.trivial_preorder", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx_inv", "FStar.Math.Euclid.is_prime", "Hacl.Bignum.MontArithmetic.bn_v_n", "Prims.b2t", "Prims.op_LessThan", "Hacl.Bignum.Definitions.bn_v", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.disjoint", "LowStar.Monotonic.Buffer.loc_disjoint", "Hacl.Bignum.MontArithmetic.footprint", "LowStar.Monotonic.Buffer.loc_buffer", "LowStar.Buffer.buffer", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Lib.Sequence.seq", "Prims.l_or", "Prims.nat", "FStar.Seq.Base.length", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx__item__len", "Hacl.Bignum.MontArithmetic.as_pctx", "Hacl.Spec.Bignum.Definitions.bn_v", "Hacl.Spec.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx__item__n", "Lib.Buffer.as_seq", "Hacl.Spec.Bignum.MontArithmetic.bn_field_inv" ]
[]
false
false
false
false
true
let bn_field_inv_st (t: limb_t) (len: BN.meta_len t) =
k: pbn_mont_ctx t -> aM: lbignum t len -> aInvM: lbignum t len -> Stack unit (requires fun h -> (B.deref h k).len == len /\ pbn_mont_ctx_inv h k /\ Euclid.is_prime (bn_v_n h k) /\ 0 < bn_v h aM /\ bn_v h aM < bn_v_n h k /\ live h aM /\ live h aInvM /\ disjoint aM aInvM /\ B.(loc_disjoint (footprint h k) (loc_buffer (aM <: buffer (limb t)))) /\ B.(loc_disjoint (footprint h k) (loc_buffer (aInvM <: buffer (limb t))))) (ensures fun h0 _ h1 -> modifies (loc aInvM) h0 h1 /\ bn_v h1 aInvM < bn_v_n h0 k /\ as_seq h1 aInvM == S.bn_field_inv (as_pctx h0 k) (as_seq h0 aM))
false