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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Spec.P256.PointOps.fst
|
Spec.P256.PointOps.is_on_curve
|
val is_on_curve (p: aff_point) : bool
|
val is_on_curve (p: aff_point) : bool
|
let is_on_curve (p:aff_point) : bool =
let (x, y) = p in y *% y = x *% x *% x +% a_coeff *% x +% b_coeff
|
{
"file_name": "specs/Spec.P256.PointOps.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 67,
"end_line": 78,
"start_col": 0,
"start_line": 77
}
|
module Spec.P256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Base field
// 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff
let prime: (a:pos{a = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff /\ a < pow2 256}) =
let p = pow2 256 - pow2 224 + pow2 192 + pow2 96 - 1 in
assert_norm (0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff = p);
assert_norm (p < pow2 256); p
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (a:felem) : felem = M.pow_mod #prime a (prime - 2)
let fsqrt (a:felem) : felem = M.pow_mod #prime a ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let order: (a:pos{a < pow2 256}) =
let o = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551 in
assert_norm (o < pow2 256); o
let qelem = x:nat{x < order}
let qadd (x y:qelem) : qelem = (x + y) % order
let qmul (x y:qelem) : qelem = (x * y) % order
let qinv (x:qelem) : qelem = M.pow_mod #order x (order - 2)
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve `y^2 = x^3 + a * x + b`
let aff_point = p:tuple2 nat nat{let (px, py) = p in px < prime /\ py < prime}
let proj_point = p:tuple3 nat nat nat{let (px, py, pz) = p in px < prime /\ py < prime /\ pz < prime}
// let aff_point = felem & felem // Affine point
// let proj_point = felem & felem & felem // Projective coordinates
let a_coeff : felem = (-3) % prime
let b_coeff : felem =
let b = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b in
assert_norm (b < prime); b
// Base point
let g_x : felem =
let x = 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296 in
assert_norm (x < prime); x
let g_y : felem =
let y = 0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5 in
assert_norm (y < prime); y
let base_point : proj_point = (g_x, g_y, one)
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.P256.PointOps.fst"
}
|
[
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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": "Spec.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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 |
p: Spec.P256.PointOps.aff_point -> Prims.bool
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Spec.P256.PointOps.aff_point",
"Prims.nat",
"Prims.op_Equality",
"Spec.P256.PointOps.felem",
"Spec.P256.PointOps.op_Star_Percent",
"Spec.P256.PointOps.op_Plus_Percent",
"Spec.P256.PointOps.a_coeff",
"Spec.P256.PointOps.b_coeff",
"Prims.bool"
] |
[] | false | false | false | true | false |
let is_on_curve (p: aff_point) : bool =
|
let x, y = p in
y *% y = x *% x *% x +% a_coeff *% x +% b_coeff
| false |
Spec.P256.PointOps.fst
|
Spec.P256.PointOps.point_at_inf
|
val point_at_inf:proj_point
|
val point_at_inf:proj_point
|
let point_at_inf : proj_point = (zero, one, zero)
|
{
"file_name": "specs/Spec.P256.PointOps.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 49,
"end_line": 82,
"start_col": 0,
"start_line": 82
}
|
module Spec.P256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Base field
// 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff
let prime: (a:pos{a = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff /\ a < pow2 256}) =
let p = pow2 256 - pow2 224 + pow2 192 + pow2 96 - 1 in
assert_norm (0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff = p);
assert_norm (p < pow2 256); p
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (a:felem) : felem = M.pow_mod #prime a (prime - 2)
let fsqrt (a:felem) : felem = M.pow_mod #prime a ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let order: (a:pos{a < pow2 256}) =
let o = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551 in
assert_norm (o < pow2 256); o
let qelem = x:nat{x < order}
let qadd (x y:qelem) : qelem = (x + y) % order
let qmul (x y:qelem) : qelem = (x * y) % order
let qinv (x:qelem) : qelem = M.pow_mod #order x (order - 2)
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve `y^2 = x^3 + a * x + b`
let aff_point = p:tuple2 nat nat{let (px, py) = p in px < prime /\ py < prime}
let proj_point = p:tuple3 nat nat nat{let (px, py, pz) = p in px < prime /\ py < prime /\ pz < prime}
// let aff_point = felem & felem // Affine point
// let proj_point = felem & felem & felem // Projective coordinates
let a_coeff : felem = (-3) % prime
let b_coeff : felem =
let b = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b in
assert_norm (b < prime); b
// Base point
let g_x : felem =
let x = 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296 in
assert_norm (x < prime); x
let g_y : felem =
let y = 0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5 in
assert_norm (y < prime); y
let base_point : proj_point = (g_x, g_y, one)
let is_on_curve (p:aff_point) : bool =
let (x, y) = p in y *% y = x *% x *% x +% a_coeff *% x +% b_coeff
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.P256.PointOps.fst"
}
|
[
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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": "Spec.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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 |
Spec.P256.PointOps.proj_point
|
Prims.Tot
|
[
"total"
] |
[] |
[
"FStar.Pervasives.Native.Mktuple3",
"Prims.nat",
"Spec.P256.PointOps.zero",
"Spec.P256.PointOps.one"
] |
[] | false | false | false | true | false |
let point_at_inf:proj_point =
|
(zero, one, zero)
| false |
Spec.P256.PointOps.fst
|
Spec.P256.PointOps.is_aff_point_at_inf
|
val is_aff_point_at_inf (p: aff_point) : bool
|
val is_aff_point_at_inf (p: aff_point) : bool
|
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
|
{
"file_name": "specs/Spec.P256.PointOps.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 40,
"end_line": 85,
"start_col": 0,
"start_line": 84
}
|
module Spec.P256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Base field
// 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff
let prime: (a:pos{a = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff /\ a < pow2 256}) =
let p = pow2 256 - pow2 224 + pow2 192 + pow2 96 - 1 in
assert_norm (0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff = p);
assert_norm (p < pow2 256); p
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (a:felem) : felem = M.pow_mod #prime a (prime - 2)
let fsqrt (a:felem) : felem = M.pow_mod #prime a ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let order: (a:pos{a < pow2 256}) =
let o = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551 in
assert_norm (o < pow2 256); o
let qelem = x:nat{x < order}
let qadd (x y:qelem) : qelem = (x + y) % order
let qmul (x y:qelem) : qelem = (x * y) % order
let qinv (x:qelem) : qelem = M.pow_mod #order x (order - 2)
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve `y^2 = x^3 + a * x + b`
let aff_point = p:tuple2 nat nat{let (px, py) = p in px < prime /\ py < prime}
let proj_point = p:tuple3 nat nat nat{let (px, py, pz) = p in px < prime /\ py < prime /\ pz < prime}
// let aff_point = felem & felem // Affine point
// let proj_point = felem & felem & felem // Projective coordinates
let a_coeff : felem = (-3) % prime
let b_coeff : felem =
let b = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b in
assert_norm (b < prime); b
// Base point
let g_x : felem =
let x = 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296 in
assert_norm (x < prime); x
let g_y : felem =
let y = 0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5 in
assert_norm (y < prime); y
let base_point : proj_point = (g_x, g_y, one)
let is_on_curve (p:aff_point) : bool =
let (x, y) = p in y *% y = x *% x *% x +% a_coeff *% x +% b_coeff
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.P256.PointOps.fst"
}
|
[
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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": "Spec.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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 |
p: Spec.P256.PointOps.aff_point -> Prims.bool
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Spec.P256.PointOps.aff_point",
"Prims.nat",
"Prims.op_AmpAmp",
"Prims.op_Equality",
"Spec.P256.PointOps.zero",
"Prims.bool"
] |
[] | false | false | false | true | false |
let is_aff_point_at_inf (p: aff_point) : bool =
|
let x, y = p in
x = zero && y = zero
| false |
Spec.P256.PointOps.fst
|
Spec.P256.PointOps.base_point
|
val base_point:proj_point
|
val base_point:proj_point
|
let base_point : proj_point = (g_x, g_y, one)
|
{
"file_name": "specs/Spec.P256.PointOps.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 45,
"end_line": 74,
"start_col": 0,
"start_line": 74
}
|
module Spec.P256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Base field
// 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff
let prime: (a:pos{a = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff /\ a < pow2 256}) =
let p = pow2 256 - pow2 224 + pow2 192 + pow2 96 - 1 in
assert_norm (0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff = p);
assert_norm (p < pow2 256); p
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (a:felem) : felem = M.pow_mod #prime a (prime - 2)
let fsqrt (a:felem) : felem = M.pow_mod #prime a ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let order: (a:pos{a < pow2 256}) =
let o = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551 in
assert_norm (o < pow2 256); o
let qelem = x:nat{x < order}
let qadd (x y:qelem) : qelem = (x + y) % order
let qmul (x y:qelem) : qelem = (x * y) % order
let qinv (x:qelem) : qelem = M.pow_mod #order x (order - 2)
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve `y^2 = x^3 + a * x + b`
let aff_point = p:tuple2 nat nat{let (px, py) = p in px < prime /\ py < prime}
let proj_point = p:tuple3 nat nat nat{let (px, py, pz) = p in px < prime /\ py < prime /\ pz < prime}
// let aff_point = felem & felem // Affine point
// let proj_point = felem & felem & felem // Projective coordinates
let a_coeff : felem = (-3) % prime
let b_coeff : felem =
let b = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b in
assert_norm (b < prime); b
// Base point
let g_x : felem =
let x = 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296 in
assert_norm (x < prime); x
let g_y : felem =
let y = 0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5 in
assert_norm (y < prime); y
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.P256.PointOps.fst"
}
|
[
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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": "Spec.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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 |
Spec.P256.PointOps.proj_point
|
Prims.Tot
|
[
"total"
] |
[] |
[
"FStar.Pervasives.Native.Mktuple3",
"Prims.nat",
"Spec.P256.PointOps.g_x",
"Spec.P256.PointOps.g_y",
"Spec.P256.PointOps.one"
] |
[] | false | false | false | true | false |
let base_point:proj_point =
|
(g_x, g_y, one)
| false |
MerkleTree.Low.Hashfunctions.fst
|
MerkleTree.Low.Hashfunctions.init_hash
|
val init_hash (hsz: hash_size_t) (r: HST.erid) : HST.St (hash #hsz)
|
val init_hash (hsz: hash_size_t) (r: HST.erid) : HST.St (hash #hsz)
|
let init_hash (hsz:hash_size_t) (r:HST.erid): HST.St (hash #hsz)
= rg_alloc (hreg hsz) r
|
{
"file_name": "src/MerkleTree.Low.Hashfunctions.fst",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
}
|
{
"end_col": 23,
"end_line": 40,
"start_col": 0,
"start_line": 39
}
|
module MerkleTree.Low.Hashfunctions
open EverCrypt.Helpers
open FStar.All
open FStar.Integers
open FStar.Mul
open LowStar.Buffer
open LowStar.BufferOps
open LowStar.Vector
open LowStar.Regional
open LowStar.RVector
open LowStar.Regional.Instances
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MHS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module V = LowStar.Vector
module RV = LowStar.RVector
module RVI = LowStar.Regional.Instances
module S = FStar.Seq
module U32 = FStar.UInt32
module MTH = MerkleTree.New.High
module MTS = MerkleTree.Spec
open Lib.IntTypes
open MerkleTree.Low.Datastructures
#set-options "--z3rlimit 10 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0"
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.Instances.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.All.fst.checked",
"EverCrypt.Helpers.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.Hashfunctions.fst"
}
|
[
{
"abbrev": false,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "MerkleTree.New.High",
"short_module": "MTH"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Regional.Instances",
"short_module": "RVI"
},
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "MHS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar.Regional.Instances",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 10,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
hsz: MerkleTree.Low.Datastructures.hash_size_t -> r: FStar.HyperStack.ST.erid
-> FStar.HyperStack.ST.St MerkleTree.Low.Datastructures.hash
|
FStar.HyperStack.ST.St
|
[] |
[] |
[
"MerkleTree.Low.Datastructures.hash_size_t",
"FStar.HyperStack.ST.erid",
"LowStar.Regional.rg_alloc",
"MerkleTree.Low.Datastructures.hash",
"MerkleTree.Low.Datastructures.hreg"
] |
[] | false | true | false | false | false |
let init_hash (hsz: hash_size_t) (r: HST.erid) : HST.St (hash #hsz) =
|
rg_alloc (hreg hsz) r
| false |
Pulse.Checker.STApp.fst
|
Pulse.Checker.STApp.check
|
val check
(g:env)
(pre:term)
(pre_typing:tot_typing g pre tm_vprop)
(post_hint:post_hint_opt g)
(res_ppname:ppname)
(t:st_term{Tm_STApp? t.term})
: T.Tac (checker_result_t g pre post_hint)
|
val check
(g:env)
(pre:term)
(pre_typing:tot_typing g pre tm_vprop)
(post_hint:post_hint_opt g)
(res_ppname:ppname)
(t:st_term{Tm_STApp? t.term})
: T.Tac (checker_result_t g pre post_hint)
|
let check
(g0:env)
(ctxt:vprop)
(ctxt_typing:tot_typing g0 ctxt tm_vprop)
(post_hint:post_hint_opt g0)
(res_ppname:ppname)
(t:st_term { Tm_STApp? t.term })
: T.Tac (checker_result_t g0 ctxt post_hint) =
let g0 = push_context "st_app" t.range g0 in
let range = t.range in
let (| uvs, g, t |) = instantiate_implicits g0 t in
assert (g `env_extends` g0);
let post_hint : post_hint_opt g = post_hint in
let Tm_STApp { head; arg_qual=qual; arg } = t.term in
let (| head, eff_head, ty_head, dhead |) = compute_term_type g head in
debug_log g (fun _ ->
T.print (Printf.sprintf "st_app: head = %s, eff_head: %s, ty_head = %s\n"
(P.term_to_string head)
(P.tot_or_ghost_to_string eff_head)
(P.term_to_string ty_head)));
match is_arrow ty_head with
| Some b ->
apply_impure_function t.range g0 uvs g ctxt ctxt_typing post_hint res_ppname head qual arg ty_head eff_head dhead b
| _ ->
let (| ty', typing |) = norm_typing g head eff_head ty_head dhead [weak;hnf;delta] in
match is_arrow ty' with
| None ->
fail g (Some t.range)
(Printf.sprintf "Expected an arrow type; but head %s has type %s"
(P.term_to_string head)
(P.term_to_string ty_head))
| Some b ->
apply_impure_function t.range g0 uvs g ctxt ctxt_typing post_hint res_ppname head qual arg ty' eff_head typing b
|
{
"file_name": "lib/steel/pulse/Pulse.Checker.STApp.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
}
|
{
"end_col": 117,
"end_line": 251,
"start_col": 0,
"start_line": 211
}
|
(*
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.Checker.STApp
open Pulse.Syntax
open Pulse.Typing
open Pulse.Checker.Pure
open Pulse.Checker.Base
module T = FStar.Tactics.V2
module RT = FStar.Reflection.Typing
module FV = Pulse.Typing.FV
module RU = Pulse.RuntimeUtils
module P = Pulse.Syntax.Printer
module Prover = Pulse.Checker.Prover
open Pulse.Show
let debug_log (g:env) (f:unit -> T.Tac unit) : T.Tac unit = if RU.debug_at_level (fstar_env g) "st_app" then f () else ()
let canon_comp (c:comp_st) : comp_st =
match readback_comp (elab_comp c) with
| None -> c
| Some (C_Tot _) -> c //should be impossible
| Some c' -> c'
#push-options "--admit_smt_queries true"
let canon_comp_eq_res (g:env) (c:comp_st)
: RT.equiv (elab_env g) (elab_term (comp_res c)) (elab_term (comp_res (canon_comp c)))
= RT.Rel_refl _ _ _
#pop-options
let canonicalize_st_typing (#g:env) (#t:st_term) (#c:comp_st) (d:st_typing g t c)
: st_typing g t (canon_comp c)
= let c' = canon_comp c in
let x = fresh g in
assume ( ~(x `Set.mem` freevars (comp_post c)) /\
~(x `Set.mem` freevars (comp_post c')) );
assume (st_equiv_pre c c');
let st_eq
: st_equiv g c c'
= ST_VPropEquiv g c c' x (RU.magic ()) (RU.magic()) (RU.magic()) (canon_comp_eq_res g c) (RU.magic()) (RU.magic())
in
T_Equiv _ _ _ _ d st_eq
let coerce_eq (#a #b:Type) (x:a) (_:squash (a === b)) : y:b { y == x } = x
let rec intro_uvars_for_logical_implicits (g:env) (uvs:env { disjoint g uvs }) (t:term) (ty:term)
: T.Tac (uvs':env &
g':env { extends_with g' g uvs' } &
t':st_term { Tm_STApp? t'.term }) =
let ropt = is_arrow ty in
match ropt with
| Some (b, Some Implicit, c_rest) ->
let x = fresh (push_env g uvs) in
let uvs' = push_binding uvs x b.binder_ppname b.binder_ty in
let c_rest = open_comp_with c_rest (tm_var {nm_index = x; nm_ppname = b.binder_ppname}) in
begin
match c_rest with
| C_ST _
| C_STAtomic _ _ _
| C_STGhost _ ->
(| uvs', push_env g uvs', {term=Tm_STApp {head=t;arg_qual=Some Implicit;arg=null_var x};
range=t.range;
effect_tag=as_effect_hint (ctag_of_comp_st c_rest) } |)
| C_Tot ty ->
intro_uvars_for_logical_implicits g uvs' (tm_pureapp t (Some Implicit) (null_var x)) ty
end
| _ ->
fail g None
(Printf.sprintf "check_stapp.intro_uvars_for_logical_implicits: expected an arrow type,\
with an implicit parameter, found: %s"
(P.term_to_string ty))
let instantiate_implicits (g:env) (t:st_term { Tm_STApp? t.term })
: T.Tac (uvs : env &
g' : env { extends_with g' g uvs } &
t' : st_term { Tm_STApp? t'.term }) =
let range = t.range in
let Tm_STApp { head; arg_qual=qual; arg } = t.term in
let pure_app = tm_pureapp head qual arg in
let (| uvs, t, ty |) = instantiate_term_implicits_uvs g pure_app in
match is_arrow ty with
| Some (_, Some Implicit, _) ->
//Some implicits to follow
intro_uvars_for_logical_implicits g uvs t ty
| _ ->
match is_pure_app t with
| Some (head, q, arg) ->
(| uvs, push_env g uvs, {term=Tm_STApp {head;arg_qual=q;arg}; range=t.range; effect_tag=default_effect_hint } |)
| _ ->
fail g (Some t.range)
(Printf.sprintf "check_stapp.instantiate_implicits: expected an application term, found: %s"
(show t))
#push-options "--z3rlimit_factor 4 --fuel 1 --ifuel 1"
let apply_impure_function
(range:range)
(g0:env)
(uvs:_)
(g:env { extends_with g g0 uvs })
(ctxt:vprop)
(ctxt_typing:tot_typing g0 ctxt tm_vprop)
(post_hint:post_hint_opt g0)
(res_ppname:ppname)
(head:term)
(qual:option qualifier)
(arg:term)
(ty_head:term)
(eff_head:_)
(dhead:typing g head eff_head ty_head)
(b:binder & option qualifier & comp { Some b == is_arrow ty_head })
: T.Tac (checker_result_t g0 ctxt post_hint)
= let {binder_ty=formal;binder_ppname=ppname}, bqual, comp_typ = b in
assert (g `env_extends` g0);
let post_hint : post_hint_opt g = post_hint in
is_arrow_tm_arrow ty_head;
debug_log g (fun _ ->
T.print (Printf.sprintf "st_app, head=%s, arg=%s, readback comp as %s\n"
(P.term_to_string head)
(P.term_to_string arg)
(P.comp_to_string comp_typ)));
let allow_ghost = C_STGhost? comp_typ in
if (not allow_ghost) &&
eff_head = T.E_Ghost
then fail g (Some range)
(Printf.sprintf "head term %s is ghost, but the arrow comp is not STGhost"
(P.term_to_string head));
if qual <> bqual
then (
fail g (Some range) (Printf.sprintf "Unexpected qualifier in head type %s of stateful application: head = %s, arg = %s"
(P.term_to_string ty_head)
(P.term_to_string head)
(P.term_to_string arg))
)
else (
let eff_arg = if allow_ghost then T.E_Ghost else T.E_Total in
let (| arg, darg |) = check_term g arg eff_arg formal in
let (| t, c, d |) : (t:st_term & c:comp_st & st_typing g t c) =
match comp_typ with
| C_ST res
| C_STAtomic _ _ res ->
// ST application
let d : st_typing _ _ (open_comp_with comp_typ arg) =
T_STApp g head formal qual comp_typ arg dhead darg in
let d = canonicalize_st_typing d in
let t = { term = Tm_STApp {head; arg_qual=qual; arg}; range; effect_tag=as_effect_hint (ctag_of_comp_st comp_typ) } in
let c = (canon_comp (open_comp_with comp_typ arg)) in
(| t, c, d |)
| C_STGhost res ->
// get the non-informative witness
let x = fresh g in
if x `Set.mem` freevars_comp (comp_typ)
then fail g (Some range)
("Unexpected clash of variable names, please file a bug-report");
//
// This will always succeed, is there a way to avoid this?
//
let d_non_info =
let token =
is_non_informative (push_binding g x ppname_default formal)
(open_comp_with comp_typ (null_var x)) in
match token with
| None ->
fail g (Some range)
(Printf.sprintf "Unexpected non-informative result for %s" (P.comp_to_string comp_typ))
| Some token ->
RT.Non_informative_token _ _
(FStar.Squash.return_squash token) in
let d : st_typing _ _ (open_comp_with comp_typ arg) =
T_STGhostApp g head formal qual comp_typ arg x
(lift_typing_to_ghost_typing dhead)
(E d_non_info)
(lift_typing_to_ghost_typing darg) in
let d = canonicalize_st_typing d in
let t = { term = Tm_STApp {head; arg_qual=qual; arg}; range; effect_tag=as_effect_hint STT_Ghost } in
let c = (canon_comp (open_comp_with comp_typ arg)) in
(| t, c, d |)
| _ ->
fail g (Some range)
"Expected an effectful application; got a pure term (could it be partially applied by mistake?)"
in
let (| st', c', st_typing' |) = match_comp_res_with_post_hint d post_hint in
debug_log g (fun _ -> T.print (Printf.sprintf "st_app: c' = %s\n"
(show #comp c')));
let framed = Prover.try_frame_pre_uvs ctxt_typing uvs (| st', c', st_typing' |) res_ppname in
Prover.prove_post_hint framed post_hint range
)
|
{
"checked_file": "/",
"dependencies": [
"Pulse.Typing.FV.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.Show.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Checker.Pure.fsti.checked",
"Pulse.Checker.Prover.fsti.checked",
"Pulse.Checker.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.STApp.fst"
}
|
[
{
"abbrev": false,
"full_module": "Pulse.Show",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover",
"short_module": "Prover"
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.FV",
"short_module": "FV"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 4,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
g: Pulse.Typing.Env.env ->
pre: Pulse.Syntax.Base.term ->
pre_typing: Pulse.Typing.tot_typing g pre Pulse.Syntax.Base.tm_vprop ->
post_hint: Pulse.Typing.post_hint_opt g ->
res_ppname: Pulse.Syntax.Base.ppname ->
t: Pulse.Syntax.Base.st_term{Tm_STApp? (Mkst_term?.term t)}
-> FStar.Tactics.Effect.Tac (Pulse.Checker.Base.checker_result_t g pre post_hint)
|
FStar.Tactics.Effect.Tac
|
[] |
[] |
[
"Pulse.Typing.Env.env",
"Pulse.Syntax.Base.vprop",
"Pulse.Typing.tot_typing",
"Pulse.Syntax.Base.tm_vprop",
"Pulse.Typing.post_hint_opt",
"Pulse.Syntax.Base.ppname",
"Pulse.Syntax.Base.st_term",
"Prims.b2t",
"Pulse.Syntax.Base.uu___is_Tm_STApp",
"Pulse.Syntax.Base.__proj__Mkst_term__item__term",
"Pulse.Typing.Env.extends_with",
"Pulse.Syntax.Base.term",
"FStar.Pervasives.Native.option",
"Pulse.Syntax.Base.qualifier",
"FStar.Stubs.TypeChecker.Core.tot_or_ghost",
"Pulse.Typing.typing",
"Pulse.Syntax.Pure.is_arrow",
"FStar.Pervasives.Native.tuple3",
"Pulse.Syntax.Base.binder",
"Pulse.Syntax.Base.comp",
"Pulse.Checker.STApp.apply_impure_function",
"Pulse.Syntax.Base.__proj__Mkst_term__item__range",
"Pulse.Checker.Base.checker_result_t",
"Pulse.Typing.Env.fail",
"FStar.Pervasives.Native.Some",
"Pulse.Syntax.Base.range",
"Prims.string",
"FStar.Printf.sprintf",
"Pulse.Syntax.Printer.term_to_string",
"Prims.dtuple2",
"Pulse.Checker.Base.norm_typing",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.weak",
"FStar.Pervasives.hnf",
"FStar.Pervasives.delta",
"Prims.Nil",
"Prims.unit",
"Pulse.Checker.STApp.debug_log",
"FStar.Stubs.Tactics.V2.Builtins.print",
"Pulse.Syntax.Printer.tot_or_ghost_to_string",
"FStar.Pervasives.dtuple4",
"Pulse.Checker.Pure.compute_term_type",
"Pulse.Syntax.Base.st_term'",
"Prims._assert",
"Pulse.Typing.Env.env_extends",
"FStar.Pervasives.dtuple3",
"Pulse.Checker.STApp.instantiate_implicits",
"Prims.eq2",
"Pulse.Checker.Pure.push_context"
] |
[] | false | true | false | false | false |
let check
(g0: env)
(ctxt: vprop)
(ctxt_typing: tot_typing g0 ctxt tm_vprop)
(post_hint: post_hint_opt g0)
(res_ppname: ppname)
(t: st_term{Tm_STApp? t.term})
: T.Tac (checker_result_t g0 ctxt post_hint) =
|
let g0 = push_context "st_app" t.range g0 in
let range = t.range in
let (| uvs , g , t |) = instantiate_implicits g0 t in
assert (g `env_extends` g0);
let post_hint:post_hint_opt g = post_hint in
let Tm_STApp { head = head ; arg_qual = qual ; arg = arg } = t.term in
let (| head , eff_head , ty_head , dhead |) = compute_term_type g head in
debug_log g
(fun _ ->
T.print (Printf.sprintf "st_app: head = %s, eff_head: %s, ty_head = %s\n"
(P.term_to_string head)
(P.tot_or_ghost_to_string eff_head)
(P.term_to_string ty_head)));
match is_arrow ty_head with
| Some b ->
apply_impure_function t.range g0 uvs g ctxt ctxt_typing post_hint res_ppname head qual arg ty_head
eff_head dhead b
| _ ->
let (| ty' , typing |) = norm_typing g head eff_head ty_head dhead [weak; hnf; delta] in
match is_arrow ty' with
| None ->
fail g
(Some t.range)
(Printf.sprintf "Expected an arrow type; but head %s has type %s"
(P.term_to_string head)
(P.term_to_string ty_head))
| Some b ->
apply_impure_function t.range g0 uvs g ctxt ctxt_typing post_hint res_ppname head qual arg ty'
eff_head typing b
| false |
Spec.P256.PointOps.fst
|
Spec.P256.PointOps.a_coeff
|
val a_coeff:felem
|
val a_coeff:felem
|
let a_coeff : felem = (-3) % prime
|
{
"file_name": "specs/Spec.P256.PointOps.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 34,
"end_line": 60,
"start_col": 0,
"start_line": 60
}
|
module Spec.P256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Base field
// 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff
let prime: (a:pos{a = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff /\ a < pow2 256}) =
let p = pow2 256 - pow2 224 + pow2 192 + pow2 96 - 1 in
assert_norm (0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff = p);
assert_norm (p < pow2 256); p
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (a:felem) : felem = M.pow_mod #prime a (prime - 2)
let fsqrt (a:felem) : felem = M.pow_mod #prime a ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let order: (a:pos{a < pow2 256}) =
let o = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551 in
assert_norm (o < pow2 256); o
let qelem = x:nat{x < order}
let qadd (x y:qelem) : qelem = (x + y) % order
let qmul (x y:qelem) : qelem = (x * y) % order
let qinv (x:qelem) : qelem = M.pow_mod #order x (order - 2)
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve `y^2 = x^3 + a * x + b`
let aff_point = p:tuple2 nat nat{let (px, py) = p in px < prime /\ py < prime}
let proj_point = p:tuple3 nat nat nat{let (px, py, pz) = p in px < prime /\ py < prime /\ pz < prime}
// let aff_point = felem & felem // Affine point
// let proj_point = felem & felem & felem // Projective coordinates
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.P256.PointOps.fst"
}
|
[
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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": "Spec.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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 |
Spec.P256.PointOps.felem
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Prims.op_Modulus",
"Prims.op_Minus",
"Spec.P256.PointOps.prime"
] |
[] | false | false | false | true | false |
let a_coeff:felem =
|
(- 3) % prime
| false |
Spec.P256.PointOps.fst
|
Spec.P256.PointOps.to_proj_point
|
val to_proj_point (p: aff_point) : proj_point
|
val to_proj_point (p: aff_point) : proj_point
|
let to_proj_point (p:aff_point) : proj_point =
let (x, y) = p in (x, y, one)
|
{
"file_name": "specs/Spec.P256.PointOps.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 31,
"end_line": 92,
"start_col": 0,
"start_line": 91
}
|
module Spec.P256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Base field
// 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff
let prime: (a:pos{a = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff /\ a < pow2 256}) =
let p = pow2 256 - pow2 224 + pow2 192 + pow2 96 - 1 in
assert_norm (0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff = p);
assert_norm (p < pow2 256); p
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (a:felem) : felem = M.pow_mod #prime a (prime - 2)
let fsqrt (a:felem) : felem = M.pow_mod #prime a ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let order: (a:pos{a < pow2 256}) =
let o = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551 in
assert_norm (o < pow2 256); o
let qelem = x:nat{x < order}
let qadd (x y:qelem) : qelem = (x + y) % order
let qmul (x y:qelem) : qelem = (x * y) % order
let qinv (x:qelem) : qelem = M.pow_mod #order x (order - 2)
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve `y^2 = x^3 + a * x + b`
let aff_point = p:tuple2 nat nat{let (px, py) = p in px < prime /\ py < prime}
let proj_point = p:tuple3 nat nat nat{let (px, py, pz) = p in px < prime /\ py < prime /\ pz < prime}
// let aff_point = felem & felem // Affine point
// let proj_point = felem & felem & felem // Projective coordinates
let a_coeff : felem = (-3) % prime
let b_coeff : felem =
let b = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b in
assert_norm (b < prime); b
// Base point
let g_x : felem =
let x = 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296 in
assert_norm (x < prime); x
let g_y : felem =
let y = 0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5 in
assert_norm (y < prime); y
let base_point : proj_point = (g_x, g_y, one)
let is_on_curve (p:aff_point) : bool =
let (x, y) = p in y *% y = x *% x *% x +% a_coeff *% x +% b_coeff
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
let is_point_at_inf (p:proj_point) =
let (_, _, z) = p in z = 0
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.P256.PointOps.fst"
}
|
[
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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": "Spec.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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 |
p: Spec.P256.PointOps.aff_point -> Spec.P256.PointOps.proj_point
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Spec.P256.PointOps.aff_point",
"Prims.nat",
"FStar.Pervasives.Native.Mktuple3",
"Spec.P256.PointOps.one",
"Spec.P256.PointOps.proj_point"
] |
[] | false | false | false | true | false |
let to_proj_point (p: aff_point) : proj_point =
|
let x, y = p in
(x, y, one)
| false |
Spec.P256.PointOps.fst
|
Spec.P256.PointOps.aff_point_add
|
val aff_point_add (p q: aff_point) : aff_point
|
val aff_point_add (p q: aff_point) : aff_point
|
let aff_point_add (p:aff_point) (q:aff_point) : aff_point =
let (px, py) = p in let (qx, qy) = q in
if is_aff_point_at_inf p then q
else begin
if is_aff_point_at_inf q then p
else begin
if p = q then aff_point_double p
else begin
if qx = px then aff_point_at_inf
else begin
let lambda = (qy -% py) /% (qx -% px) in
let rx = lambda *% lambda -% px -% qx in
let ry = lambda *% (px -% rx) -% py in
(rx, ry)
end
end
end
end
|
{
"file_name": "specs/Spec.P256.PointOps.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 5,
"end_line": 134,
"start_col": 0,
"start_line": 117
}
|
module Spec.P256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Base field
// 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff
let prime: (a:pos{a = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff /\ a < pow2 256}) =
let p = pow2 256 - pow2 224 + pow2 192 + pow2 96 - 1 in
assert_norm (0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff = p);
assert_norm (p < pow2 256); p
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (a:felem) : felem = M.pow_mod #prime a (prime - 2)
let fsqrt (a:felem) : felem = M.pow_mod #prime a ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let order: (a:pos{a < pow2 256}) =
let o = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551 in
assert_norm (o < pow2 256); o
let qelem = x:nat{x < order}
let qadd (x y:qelem) : qelem = (x + y) % order
let qmul (x y:qelem) : qelem = (x * y) % order
let qinv (x:qelem) : qelem = M.pow_mod #order x (order - 2)
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve `y^2 = x^3 + a * x + b`
let aff_point = p:tuple2 nat nat{let (px, py) = p in px < prime /\ py < prime}
let proj_point = p:tuple3 nat nat nat{let (px, py, pz) = p in px < prime /\ py < prime /\ pz < prime}
// let aff_point = felem & felem // Affine point
// let proj_point = felem & felem & felem // Projective coordinates
let a_coeff : felem = (-3) % prime
let b_coeff : felem =
let b = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b in
assert_norm (b < prime); b
// Base point
let g_x : felem =
let x = 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296 in
assert_norm (x < prime); x
let g_y : felem =
let y = 0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5 in
assert_norm (y < prime); y
let base_point : proj_point = (g_x, g_y, one)
let is_on_curve (p:aff_point) : bool =
let (x, y) = p in y *% y = x *% x *% x +% a_coeff *% x +% b_coeff
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
let is_point_at_inf (p:proj_point) =
let (_, _, z) = p in z = 0
let to_proj_point (p:aff_point) : proj_point =
let (x, y) = p in (x, y, one)
let to_aff_point (p:proj_point) : aff_point =
// if is_proj_point_at_inf p then aff_point_at_inf
let (px, py, pz) = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y)
/// Point addition in affine coordinates
let aff_point_double (p:aff_point) : aff_point =
let (px, py) = p in
if is_aff_point_at_inf p then p
else begin
if py = 0 then aff_point_at_inf
else begin
let lambda = (3 *% px *% px +% a_coeff) /% (2 *% py) in
let rx = lambda *% lambda -% px -% px in
let ry = lambda *% (px -% rx) -% py in
(rx, ry) end
end
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.P256.PointOps.fst"
}
|
[
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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": "Spec.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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 |
p: Spec.P256.PointOps.aff_point -> q: Spec.P256.PointOps.aff_point -> Spec.P256.PointOps.aff_point
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Spec.P256.PointOps.aff_point",
"Prims.nat",
"Spec.P256.PointOps.is_aff_point_at_inf",
"Prims.bool",
"Prims.op_Equality",
"Spec.P256.PointOps.aff_point_double",
"Spec.P256.PointOps.aff_point_at_inf",
"FStar.Pervasives.Native.Mktuple2",
"Spec.P256.PointOps.felem",
"Spec.P256.PointOps.op_Subtraction_Percent",
"Spec.P256.PointOps.op_Star_Percent",
"Spec.P256.PointOps.op_Slash_Percent"
] |
[] | false | false | false | true | false |
let aff_point_add (p q: aff_point) : aff_point =
|
let px, py = p in
let qx, qy = q in
if is_aff_point_at_inf p
then q
else
if is_aff_point_at_inf q
then p
else
if p = q
then aff_point_double p
else
if qx = px
then aff_point_at_inf
else
let lambda = (qy -% py) /% (qx -% px) in
let rx = lambda *% lambda -% px -% qx in
let ry = lambda *% (px -% rx) -% py in
(rx, ry)
| false |
Spec.P256.PointOps.fst
|
Spec.P256.PointOps.recover_y
|
val recover_y (x: felem) (is_odd: bool) : option felem
|
val recover_y (x: felem) (is_odd: bool) : option felem
|
let recover_y (x:felem) (is_odd:bool) : option felem =
let y2 = x *% x *% x +% a_coeff *% x +% b_coeff in
let y = fsqrt y2 in
if y *% y <> y2 then None
else begin
let y = if is_fodd y <> is_odd then (prime - y) % prime else y in
Some y end
|
{
"file_name": "specs/Spec.P256.PointOps.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 14,
"end_line": 264,
"start_col": 0,
"start_line": 258
}
|
module Spec.P256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Base field
// 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff
let prime: (a:pos{a = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff /\ a < pow2 256}) =
let p = pow2 256 - pow2 224 + pow2 192 + pow2 96 - 1 in
assert_norm (0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff = p);
assert_norm (p < pow2 256); p
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (a:felem) : felem = M.pow_mod #prime a (prime - 2)
let fsqrt (a:felem) : felem = M.pow_mod #prime a ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let order: (a:pos{a < pow2 256}) =
let o = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551 in
assert_norm (o < pow2 256); o
let qelem = x:nat{x < order}
let qadd (x y:qelem) : qelem = (x + y) % order
let qmul (x y:qelem) : qelem = (x * y) % order
let qinv (x:qelem) : qelem = M.pow_mod #order x (order - 2)
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve `y^2 = x^3 + a * x + b`
let aff_point = p:tuple2 nat nat{let (px, py) = p in px < prime /\ py < prime}
let proj_point = p:tuple3 nat nat nat{let (px, py, pz) = p in px < prime /\ py < prime /\ pz < prime}
// let aff_point = felem & felem // Affine point
// let proj_point = felem & felem & felem // Projective coordinates
let a_coeff : felem = (-3) % prime
let b_coeff : felem =
let b = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b in
assert_norm (b < prime); b
// Base point
let g_x : felem =
let x = 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296 in
assert_norm (x < prime); x
let g_y : felem =
let y = 0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5 in
assert_norm (y < prime); y
let base_point : proj_point = (g_x, g_y, one)
let is_on_curve (p:aff_point) : bool =
let (x, y) = p in y *% y = x *% x *% x +% a_coeff *% x +% b_coeff
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
let is_point_at_inf (p:proj_point) =
let (_, _, z) = p in z = 0
let to_proj_point (p:aff_point) : proj_point =
let (x, y) = p in (x, y, one)
let to_aff_point (p:proj_point) : aff_point =
// if is_proj_point_at_inf p then aff_point_at_inf
let (px, py, pz) = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y)
/// Point addition in affine coordinates
let aff_point_double (p:aff_point) : aff_point =
let (px, py) = p in
if is_aff_point_at_inf p then p
else begin
if py = 0 then aff_point_at_inf
else begin
let lambda = (3 *% px *% px +% a_coeff) /% (2 *% py) in
let rx = lambda *% lambda -% px -% px in
let ry = lambda *% (px -% rx) -% py in
(rx, ry) end
end
let aff_point_add (p:aff_point) (q:aff_point) : aff_point =
let (px, py) = p in let (qx, qy) = q in
if is_aff_point_at_inf p then q
else begin
if is_aff_point_at_inf q then p
else begin
if p = q then aff_point_double p
else begin
if qx = px then aff_point_at_inf
else begin
let lambda = (qy -% py) /% (qx -% px) in
let rx = lambda *% lambda -% px -% qx in
let ry = lambda *% (px -% rx) -% py in
(rx, ry)
end
end
end
end
/// Point addition and doubling in projective coordinates
// Alg 4 from https://eprint.iacr.org/2015/1060.pdf
let point_add (p q:proj_point) : proj_point =
let x1, y1, z1 = p in
let x2, y2, z2 = q in
let t0 = x1 *% x2 in
let t1 = y1 *% y2 in
let t2 = z1 *% z2 in
let t3 = x1 +% y1 in
let t4 = x2 +% y2 in
let t3 = t3 *% t4 in
let t4 = t0 +% t1 in
let t3 = t3 -% t4 in
let t4 = y1 +% z1 in
let t5 = y2 +% z2 in
let t4 = t4 *% t5 in
let t5 = t1 +% t2 in
let t4 = t4 -% t5 in
let x3 = x1 +% z1 in
let y3 = x2 +% z2 in
let x3 = x3 *% y3 in
let y3 = t0 +% t2 in
let y3 = x3 -% y3 in
let z3 = b_coeff *% t2 in
let x3 = y3 -% z3 in
let z3 = x3 +% x3 in
let x3 = x3 +% z3 in
let z3 = t1 -% x3 in
let x3 = t1 +% x3 in
let y3 = b_coeff *% y3 in
let t1 = t2 +% t2 in
let t2 = t1 +% t2 in
let y3 = y3 -% t2 in
let y3 = y3 -% t0 in
let t1 = y3 +% y3 in
let y3 = t1 +% y3 in
let t1 = t0 +% t0 in
let t0 = t1 +% t0 in
let t0 = t0 -% t2 in
let t1 = t4 *% y3 in
let t2 = t0 *% y3 in
let y3 = x3 *% z3 in
let y3 = y3 +% t2 in
let x3 = t3 *% x3 in
let x3 = x3 -% t1 in
let z3 = t4 *% z3 in
let t1 = t3 *% t0 in
let z3 = z3 +% t1 in
(x3, y3, z3)
// Alg 6 from https://eprint.iacr.org/2015/1060.pdf
let point_double (p:proj_point) : proj_point =
let (x, y, z) = p in
let t0 = x *% x in
let t1 = y *% y in
let t2 = z *% z in
let t3 = x *% y in
let t3 = t3 +% t3 in
let t4 = y *% z in
let z3 = x *% z in
let z3 = z3 +% z3 in
let y3 = b_coeff *% t2 in
let y3 = y3 -% z3 in
let x3 = y3 +% y3 in
let y3 = x3 +% y3 in
let x3 = t1 -% y3 in
let y3 = t1 +% y3 in
let y3 = x3 *% y3 in
let x3 = x3 *% t3 in
let t3 = t2 +% t2 in
let t2 = t2 +% t3 in
let z3 = b_coeff *% z3 in
let z3 = z3 -% t2 in
let z3 = z3 -% t0 in
let t3 = z3 +% z3 in
let z3 = z3 +% t3 in
let t3 = t0 +% t0 in
let t0 = t3 +% t0 in
let t0 = t0 -% t2 in
let t0 = t0 *% z3 in
let y3 = y3 +% t0 in
let t0 = t4 +% t4 in
let z3 = t0 *% z3 in
let x3 = x3 -% z3 in
let z3 = t0 *% t1 in
let z3 = z3 +% z3 in
let z3 = z3 +% z3 in
(x3, y3, z3)
/// Point conversion between affine, projective and bytes representation
let aff_point_load (b:BSeq.lbytes 64) : option aff_point =
let pk_x = BSeq.nat_from_bytes_be (sub b 0 32) in
let pk_y = BSeq.nat_from_bytes_be (sub b 32 32) in
let is_x_valid = pk_x < prime in
let is_y_valid = pk_y < prime in
let is_xy_on_curve =
if is_x_valid && is_y_valid then is_on_curve (pk_x, pk_y) else false in
if is_xy_on_curve then Some (pk_x, pk_y) else None
let load_point (b:BSeq.lbytes 64) : option proj_point =
match (aff_point_load b) with
| Some p -> Some (to_proj_point p)
| None -> None
let aff_point_store (p:aff_point) : BSeq.lbytes 64 =
let (px, py) = p in
let pxb = BSeq.nat_to_bytes_be 32 px in
let pxy = BSeq.nat_to_bytes_be 32 py in
concat #uint8 #32 #32 pxb pxy
let point_store (p:proj_point) : BSeq.lbytes 64 =
aff_point_store (to_aff_point p)
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.P256.PointOps.fst"
}
|
[
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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": "Spec.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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 |
x: Spec.P256.PointOps.felem -> is_odd: Prims.bool
-> FStar.Pervasives.Native.option Spec.P256.PointOps.felem
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Spec.P256.PointOps.felem",
"Prims.bool",
"Prims.op_disEquality",
"Spec.P256.PointOps.op_Star_Percent",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.Some",
"Spec.P256.PointOps.is_fodd",
"Prims.op_Modulus",
"Prims.op_Subtraction",
"Spec.P256.PointOps.prime",
"FStar.Pervasives.Native.option",
"Spec.P256.PointOps.fsqrt",
"Spec.P256.PointOps.op_Plus_Percent",
"Spec.P256.PointOps.a_coeff",
"Spec.P256.PointOps.b_coeff"
] |
[] | false | false | false | true | false |
let recover_y (x: felem) (is_odd: bool) : option felem =
|
let y2 = x *% x *% x +% a_coeff *% x +% b_coeff in
let y = fsqrt y2 in
if y *% y <> y2
then None
else
let y = if is_fodd y <> is_odd then (prime - y) % prime else y in
Some y
| false |
Spec.P256.PointOps.fst
|
Spec.P256.PointOps.to_aff_point
|
val to_aff_point (p: proj_point) : aff_point
|
val to_aff_point (p: proj_point) : aff_point
|
let to_aff_point (p:proj_point) : aff_point =
// if is_proj_point_at_inf p then aff_point_at_inf
let (px, py, pz) = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y)
|
{
"file_name": "specs/Spec.P256.PointOps.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 8,
"end_line": 100,
"start_col": 0,
"start_line": 94
}
|
module Spec.P256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Base field
// 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff
let prime: (a:pos{a = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff /\ a < pow2 256}) =
let p = pow2 256 - pow2 224 + pow2 192 + pow2 96 - 1 in
assert_norm (0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff = p);
assert_norm (p < pow2 256); p
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (a:felem) : felem = M.pow_mod #prime a (prime - 2)
let fsqrt (a:felem) : felem = M.pow_mod #prime a ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let order: (a:pos{a < pow2 256}) =
let o = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551 in
assert_norm (o < pow2 256); o
let qelem = x:nat{x < order}
let qadd (x y:qelem) : qelem = (x + y) % order
let qmul (x y:qelem) : qelem = (x * y) % order
let qinv (x:qelem) : qelem = M.pow_mod #order x (order - 2)
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve `y^2 = x^3 + a * x + b`
let aff_point = p:tuple2 nat nat{let (px, py) = p in px < prime /\ py < prime}
let proj_point = p:tuple3 nat nat nat{let (px, py, pz) = p in px < prime /\ py < prime /\ pz < prime}
// let aff_point = felem & felem // Affine point
// let proj_point = felem & felem & felem // Projective coordinates
let a_coeff : felem = (-3) % prime
let b_coeff : felem =
let b = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b in
assert_norm (b < prime); b
// Base point
let g_x : felem =
let x = 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296 in
assert_norm (x < prime); x
let g_y : felem =
let y = 0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5 in
assert_norm (y < prime); y
let base_point : proj_point = (g_x, g_y, one)
let is_on_curve (p:aff_point) : bool =
let (x, y) = p in y *% y = x *% x *% x +% a_coeff *% x +% b_coeff
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
let is_point_at_inf (p:proj_point) =
let (_, _, z) = p in z = 0
let to_proj_point (p:aff_point) : proj_point =
let (x, y) = p in (x, y, one)
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.P256.PointOps.fst"
}
|
[
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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": "Spec.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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 |
p: Spec.P256.PointOps.proj_point -> Spec.P256.PointOps.aff_point
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Spec.P256.PointOps.proj_point",
"Prims.nat",
"FStar.Pervasives.Native.Mktuple2",
"Spec.P256.PointOps.felem",
"Spec.P256.PointOps.op_Star_Percent",
"Spec.P256.PointOps.finv",
"Spec.P256.PointOps.aff_point"
] |
[] | false | false | false | true | false |
let to_aff_point (p: proj_point) : aff_point =
|
let px, py, pz = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y)
| false |
Spec.P256.PointOps.fst
|
Spec.P256.PointOps.point_double
|
val point_double (p: proj_point) : proj_point
|
val point_double (p: proj_point) : proj_point
|
let point_double (p:proj_point) : proj_point =
let (x, y, z) = p in
let t0 = x *% x in
let t1 = y *% y in
let t2 = z *% z in
let t3 = x *% y in
let t3 = t3 +% t3 in
let t4 = y *% z in
let z3 = x *% z in
let z3 = z3 +% z3 in
let y3 = b_coeff *% t2 in
let y3 = y3 -% z3 in
let x3 = y3 +% y3 in
let y3 = x3 +% y3 in
let x3 = t1 -% y3 in
let y3 = t1 +% y3 in
let y3 = x3 *% y3 in
let x3 = x3 *% t3 in
let t3 = t2 +% t2 in
let t2 = t2 +% t3 in
let z3 = b_coeff *% z3 in
let z3 = z3 -% t2 in
let z3 = z3 -% t0 in
let t3 = z3 +% z3 in
let z3 = z3 +% t3 in
let t3 = t0 +% t0 in
let t0 = t3 +% t0 in
let t0 = t0 -% t2 in
let t0 = t0 *% z3 in
let y3 = y3 +% t0 in
let t0 = t4 +% t4 in
let z3 = t0 *% z3 in
let x3 = x3 -% z3 in
let z3 = t0 *% t1 in
let z3 = z3 +% z3 in
let z3 = z3 +% z3 in
(x3, y3, z3)
|
{
"file_name": "specs/Spec.P256.PointOps.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 14,
"end_line": 226,
"start_col": 0,
"start_line": 190
}
|
module Spec.P256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Base field
// 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff
let prime: (a:pos{a = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff /\ a < pow2 256}) =
let p = pow2 256 - pow2 224 + pow2 192 + pow2 96 - 1 in
assert_norm (0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff = p);
assert_norm (p < pow2 256); p
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (a:felem) : felem = M.pow_mod #prime a (prime - 2)
let fsqrt (a:felem) : felem = M.pow_mod #prime a ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let order: (a:pos{a < pow2 256}) =
let o = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551 in
assert_norm (o < pow2 256); o
let qelem = x:nat{x < order}
let qadd (x y:qelem) : qelem = (x + y) % order
let qmul (x y:qelem) : qelem = (x * y) % order
let qinv (x:qelem) : qelem = M.pow_mod #order x (order - 2)
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve `y^2 = x^3 + a * x + b`
let aff_point = p:tuple2 nat nat{let (px, py) = p in px < prime /\ py < prime}
let proj_point = p:tuple3 nat nat nat{let (px, py, pz) = p in px < prime /\ py < prime /\ pz < prime}
// let aff_point = felem & felem // Affine point
// let proj_point = felem & felem & felem // Projective coordinates
let a_coeff : felem = (-3) % prime
let b_coeff : felem =
let b = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b in
assert_norm (b < prime); b
// Base point
let g_x : felem =
let x = 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296 in
assert_norm (x < prime); x
let g_y : felem =
let y = 0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5 in
assert_norm (y < prime); y
let base_point : proj_point = (g_x, g_y, one)
let is_on_curve (p:aff_point) : bool =
let (x, y) = p in y *% y = x *% x *% x +% a_coeff *% x +% b_coeff
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
let is_point_at_inf (p:proj_point) =
let (_, _, z) = p in z = 0
let to_proj_point (p:aff_point) : proj_point =
let (x, y) = p in (x, y, one)
let to_aff_point (p:proj_point) : aff_point =
// if is_proj_point_at_inf p then aff_point_at_inf
let (px, py, pz) = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y)
/// Point addition in affine coordinates
let aff_point_double (p:aff_point) : aff_point =
let (px, py) = p in
if is_aff_point_at_inf p then p
else begin
if py = 0 then aff_point_at_inf
else begin
let lambda = (3 *% px *% px +% a_coeff) /% (2 *% py) in
let rx = lambda *% lambda -% px -% px in
let ry = lambda *% (px -% rx) -% py in
(rx, ry) end
end
let aff_point_add (p:aff_point) (q:aff_point) : aff_point =
let (px, py) = p in let (qx, qy) = q in
if is_aff_point_at_inf p then q
else begin
if is_aff_point_at_inf q then p
else begin
if p = q then aff_point_double p
else begin
if qx = px then aff_point_at_inf
else begin
let lambda = (qy -% py) /% (qx -% px) in
let rx = lambda *% lambda -% px -% qx in
let ry = lambda *% (px -% rx) -% py in
(rx, ry)
end
end
end
end
/// Point addition and doubling in projective coordinates
// Alg 4 from https://eprint.iacr.org/2015/1060.pdf
let point_add (p q:proj_point) : proj_point =
let x1, y1, z1 = p in
let x2, y2, z2 = q in
let t0 = x1 *% x2 in
let t1 = y1 *% y2 in
let t2 = z1 *% z2 in
let t3 = x1 +% y1 in
let t4 = x2 +% y2 in
let t3 = t3 *% t4 in
let t4 = t0 +% t1 in
let t3 = t3 -% t4 in
let t4 = y1 +% z1 in
let t5 = y2 +% z2 in
let t4 = t4 *% t5 in
let t5 = t1 +% t2 in
let t4 = t4 -% t5 in
let x3 = x1 +% z1 in
let y3 = x2 +% z2 in
let x3 = x3 *% y3 in
let y3 = t0 +% t2 in
let y3 = x3 -% y3 in
let z3 = b_coeff *% t2 in
let x3 = y3 -% z3 in
let z3 = x3 +% x3 in
let x3 = x3 +% z3 in
let z3 = t1 -% x3 in
let x3 = t1 +% x3 in
let y3 = b_coeff *% y3 in
let t1 = t2 +% t2 in
let t2 = t1 +% t2 in
let y3 = y3 -% t2 in
let y3 = y3 -% t0 in
let t1 = y3 +% y3 in
let y3 = t1 +% y3 in
let t1 = t0 +% t0 in
let t0 = t1 +% t0 in
let t0 = t0 -% t2 in
let t1 = t4 *% y3 in
let t2 = t0 *% y3 in
let y3 = x3 *% z3 in
let y3 = y3 +% t2 in
let x3 = t3 *% x3 in
let x3 = x3 -% t1 in
let z3 = t4 *% z3 in
let t1 = t3 *% t0 in
let z3 = z3 +% t1 in
(x3, y3, z3)
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.P256.PointOps.fst"
}
|
[
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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": "Spec.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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 |
p: Spec.P256.PointOps.proj_point -> Spec.P256.PointOps.proj_point
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Spec.P256.PointOps.proj_point",
"Prims.nat",
"FStar.Pervasives.Native.Mktuple3",
"Spec.P256.PointOps.felem",
"Spec.P256.PointOps.op_Plus_Percent",
"Spec.P256.PointOps.op_Star_Percent",
"Spec.P256.PointOps.op_Subtraction_Percent",
"Spec.P256.PointOps.b_coeff"
] |
[] | false | false | false | true | false |
let point_double (p: proj_point) : proj_point =
|
let x, y, z = p in
let t0 = x *% x in
let t1 = y *% y in
let t2 = z *% z in
let t3 = x *% y in
let t3 = t3 +% t3 in
let t4 = y *% z in
let z3 = x *% z in
let z3 = z3 +% z3 in
let y3 = b_coeff *% t2 in
let y3 = y3 -% z3 in
let x3 = y3 +% y3 in
let y3 = x3 +% y3 in
let x3 = t1 -% y3 in
let y3 = t1 +% y3 in
let y3 = x3 *% y3 in
let x3 = x3 *% t3 in
let t3 = t2 +% t2 in
let t2 = t2 +% t3 in
let z3 = b_coeff *% z3 in
let z3 = z3 -% t2 in
let z3 = z3 -% t0 in
let t3 = z3 +% z3 in
let z3 = z3 +% t3 in
let t3 = t0 +% t0 in
let t0 = t3 +% t0 in
let t0 = t0 -% t2 in
let t0 = t0 *% z3 in
let y3 = y3 +% t0 in
let t0 = t4 +% t4 in
let z3 = t0 *% z3 in
let x3 = x3 -% z3 in
let z3 = t0 *% t1 in
let z3 = z3 +% z3 in
let z3 = z3 +% z3 in
(x3, y3, z3)
| false |
LList2.fst
|
LList2.llist_nil
|
val llist_nil (p: ptr cell) : Tot vprop
|
val llist_nil (p: ptr cell) : Tot vprop
|
let llist_nil (p: ptr cell) : Tot vprop =
pure (p == null _)
|
{
"file_name": "share/steel/examples/steelc/LList2.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
}
|
{
"end_col": 20,
"end_line": 41,
"start_col": 0,
"start_line": 40
}
|
module LList2
open Steel.ST.GenElim
open Steel.ST.C.Types
open Steel.ST.C.Types.Struct.Aux
open Steel.ST.C.Types.UserStruct // hides Struct
module U32 = FStar.UInt32
noeq
type cell_t = {
hd: scalar_t U32.t;
tl: scalar_t (ptr_gen cell_t);
}
noextract
inline_for_extraction
[@@ norm_field_attr]
let cell_struct_def : struct_def cell_t =
let fields = FStar.Set.add "hd" (FStar.Set.singleton "tl") in
let field_desc : field_description_gen_t (field_t fields) = {
fd_nonempty = nonempty_set_nonempty_type "hd" fields;
fd_type = (fun (n: field_t fields) -> match n with "hd" -> scalar_t U32.t | "tl" -> scalar_t (ptr_gen cell_t));
fd_typedef = (fun (n: field_t fields) -> match n with "hd" -> scalar U32.t | "tl" -> scalar (ptr_gen cell_t));
}
in {
fields = fields;
field_desc = field_desc;
mk = (fun f -> Mkcell_t (f "hd") (f "tl"));
get = (fun x (f: field_t fields) -> match f with "hd" -> x.hd | "tl" -> x.tl);
get_mk = (fun _ _ -> ());
extensionality = (fun s1 s2 phi -> phi "hd"; phi "tl");
}
noextract
inline_for_extraction
[@@ norm_field_attr]
let cell = struct_typedef cell_struct_def
|
{
"checked_file": "/",
"dependencies": [
"Steel.ST.GenElim.fsti.checked",
"Steel.ST.C.Types.UserStruct.fsti.checked",
"Steel.ST.C.Types.Struct.Aux.fsti.checked",
"Steel.ST.C.Types.fst.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LList2.fst"
}
|
[
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.UserStruct // hides Struct",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.UserStruct",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.Struct.Aux",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
p: Steel.ST.C.Types.Base.ptr LList2.cell -> Steel.Effect.Common.vprop
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Steel.ST.C.Types.Base.ptr",
"LList2.cell_t",
"LList2.cell",
"Steel.ST.Util.pure",
"Prims.eq2",
"Steel.ST.C.Types.Base.null",
"Steel.Effect.Common.vprop"
] |
[] | false | false | false | true | false |
let llist_nil (p: ptr cell) : Tot vprop =
|
pure (p == null _)
| false |
Spec.P256.PointOps.fst
|
Spec.P256.PointOps.aff_point_double
|
val aff_point_double (p: aff_point) : aff_point
|
val aff_point_double (p: aff_point) : aff_point
|
let aff_point_double (p:aff_point) : aff_point =
let (px, py) = p in
if is_aff_point_at_inf p then p
else begin
if py = 0 then aff_point_at_inf
else begin
let lambda = (3 *% px *% px +% a_coeff) /% (2 *% py) in
let rx = lambda *% lambda -% px -% px in
let ry = lambda *% (px -% rx) -% py in
(rx, ry) end
end
|
{
"file_name": "specs/Spec.P256.PointOps.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 5,
"end_line": 115,
"start_col": 0,
"start_line": 105
}
|
module Spec.P256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Base field
// 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff
let prime: (a:pos{a = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff /\ a < pow2 256}) =
let p = pow2 256 - pow2 224 + pow2 192 + pow2 96 - 1 in
assert_norm (0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff = p);
assert_norm (p < pow2 256); p
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (a:felem) : felem = M.pow_mod #prime a (prime - 2)
let fsqrt (a:felem) : felem = M.pow_mod #prime a ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let order: (a:pos{a < pow2 256}) =
let o = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551 in
assert_norm (o < pow2 256); o
let qelem = x:nat{x < order}
let qadd (x y:qelem) : qelem = (x + y) % order
let qmul (x y:qelem) : qelem = (x * y) % order
let qinv (x:qelem) : qelem = M.pow_mod #order x (order - 2)
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve `y^2 = x^3 + a * x + b`
let aff_point = p:tuple2 nat nat{let (px, py) = p in px < prime /\ py < prime}
let proj_point = p:tuple3 nat nat nat{let (px, py, pz) = p in px < prime /\ py < prime /\ pz < prime}
// let aff_point = felem & felem // Affine point
// let proj_point = felem & felem & felem // Projective coordinates
let a_coeff : felem = (-3) % prime
let b_coeff : felem =
let b = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b in
assert_norm (b < prime); b
// Base point
let g_x : felem =
let x = 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296 in
assert_norm (x < prime); x
let g_y : felem =
let y = 0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5 in
assert_norm (y < prime); y
let base_point : proj_point = (g_x, g_y, one)
let is_on_curve (p:aff_point) : bool =
let (x, y) = p in y *% y = x *% x *% x +% a_coeff *% x +% b_coeff
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
let is_point_at_inf (p:proj_point) =
let (_, _, z) = p in z = 0
let to_proj_point (p:aff_point) : proj_point =
let (x, y) = p in (x, y, one)
let to_aff_point (p:proj_point) : aff_point =
// if is_proj_point_at_inf p then aff_point_at_inf
let (px, py, pz) = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y)
/// Point addition in affine coordinates
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.P256.PointOps.fst"
}
|
[
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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": "Spec.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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 |
p: Spec.P256.PointOps.aff_point -> Spec.P256.PointOps.aff_point
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Spec.P256.PointOps.aff_point",
"Prims.nat",
"Spec.P256.PointOps.is_aff_point_at_inf",
"Prims.bool",
"Prims.op_Equality",
"Prims.int",
"Spec.P256.PointOps.aff_point_at_inf",
"FStar.Pervasives.Native.Mktuple2",
"Spec.P256.PointOps.felem",
"Spec.P256.PointOps.op_Subtraction_Percent",
"Spec.P256.PointOps.op_Star_Percent",
"Spec.P256.PointOps.op_Slash_Percent",
"Spec.P256.PointOps.op_Plus_Percent",
"Spec.P256.PointOps.a_coeff"
] |
[] | false | false | false | true | false |
let aff_point_double (p: aff_point) : aff_point =
|
let px, py = p in
if is_aff_point_at_inf p
then p
else
if py = 0
then aff_point_at_inf
else
let lambda = (3 *% px *% px +% a_coeff) /% (2 *% py) in
let rx = lambda *% lambda -% px -% px in
let ry = lambda *% (px -% rx) -% py in
(rx, ry)
| false |
LList2.fst
|
LList2.cell
|
val cell : Steel.ST.C.Types.Base.typedef LList2.cell_t
|
let cell = struct_typedef cell_struct_def
|
{
"file_name": "share/steel/examples/steelc/LList2.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
}
|
{
"end_col": 41,
"end_line": 37,
"start_col": 0,
"start_line": 37
}
|
module LList2
open Steel.ST.GenElim
open Steel.ST.C.Types
open Steel.ST.C.Types.Struct.Aux
open Steel.ST.C.Types.UserStruct // hides Struct
module U32 = FStar.UInt32
noeq
type cell_t = {
hd: scalar_t U32.t;
tl: scalar_t (ptr_gen cell_t);
}
noextract
inline_for_extraction
[@@ norm_field_attr]
let cell_struct_def : struct_def cell_t =
let fields = FStar.Set.add "hd" (FStar.Set.singleton "tl") in
let field_desc : field_description_gen_t (field_t fields) = {
fd_nonempty = nonempty_set_nonempty_type "hd" fields;
fd_type = (fun (n: field_t fields) -> match n with "hd" -> scalar_t U32.t | "tl" -> scalar_t (ptr_gen cell_t));
fd_typedef = (fun (n: field_t fields) -> match n with "hd" -> scalar U32.t | "tl" -> scalar (ptr_gen cell_t));
}
in {
fields = fields;
field_desc = field_desc;
mk = (fun f -> Mkcell_t (f "hd") (f "tl"));
get = (fun x (f: field_t fields) -> match f with "hd" -> x.hd | "tl" -> x.tl);
get_mk = (fun _ _ -> ());
extensionality = (fun s1 s2 phi -> phi "hd"; phi "tl");
}
noextract
inline_for_extraction
|
{
"checked_file": "/",
"dependencies": [
"Steel.ST.GenElim.fsti.checked",
"Steel.ST.C.Types.UserStruct.fsti.checked",
"Steel.ST.C.Types.Struct.Aux.fsti.checked",
"Steel.ST.C.Types.fst.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LList2.fst"
}
|
[
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.UserStruct // hides Struct",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.UserStruct",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.Struct.Aux",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 |
Steel.ST.C.Types.Base.typedef LList2.cell_t
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Steel.ST.C.Types.UserStruct.struct_typedef",
"LList2.cell_t",
"LList2.cell_struct_def"
] |
[] | false | false | false | true | false |
let cell =
|
struct_typedef cell_struct_def
| false |
|
MerkleTree.Low.Hashfunctions.fst
|
MerkleTree.Low.Hashfunctions.free_hash
|
val free_hash (#hsz: Ghost.erased hash_size_t) (h: hash #hsz)
: HST.ST unit (requires (fun h0 -> (Rgl?.r_inv (hreg hsz)) h0 h)) (ensures (fun _ _ _ -> True))
|
val free_hash (#hsz: Ghost.erased hash_size_t) (h: hash #hsz)
: HST.ST unit (requires (fun h0 -> (Rgl?.r_inv (hreg hsz)) h0 h)) (ensures (fun _ _ _ -> True))
|
let free_hash
(#hsz:Ghost.erased hash_size_t)
(h:hash #hsz): HST.ST unit
(requires (fun h0 -> (Rgl?.r_inv (hreg hsz)) h0 h))
(ensures (fun _ _ _ -> True))
= B.free h
|
{
"file_name": "src/MerkleTree.Low.Hashfunctions.fst",
"git_rev": "7d7bdc20f2033171e279c176b26e84f9069d23c6",
"git_url": "https://github.com/hacl-star/merkle-tree.git",
"project_name": "merkle-tree"
}
|
{
"end_col": 10,
"end_line": 49,
"start_col": 0,
"start_line": 44
}
|
module MerkleTree.Low.Hashfunctions
open EverCrypt.Helpers
open FStar.All
open FStar.Integers
open FStar.Mul
open LowStar.Buffer
open LowStar.BufferOps
open LowStar.Vector
open LowStar.Regional
open LowStar.RVector
open LowStar.Regional.Instances
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MHS = FStar.Monotonic.HyperStack
module HH = FStar.Monotonic.HyperHeap
module B = LowStar.Buffer
module CB = LowStar.ConstBuffer
module V = LowStar.Vector
module RV = LowStar.RVector
module RVI = LowStar.Regional.Instances
module S = FStar.Seq
module U32 = FStar.UInt32
module MTH = MerkleTree.New.High
module MTS = MerkleTree.Spec
open Lib.IntTypes
open MerkleTree.Low.Datastructures
#set-options "--z3rlimit 10 --initial_fuel 0 --max_fuel 0 --initial_ifuel 0 --max_ifuel 0"
let init_hash (hsz:hash_size_t) (r:HST.erid): HST.St (hash #hsz)
= rg_alloc (hreg hsz) r
#set-options "--z3rlimit 200 --initial_fuel 2 --max_fuel 2 --initial_ifuel 2 --max_ifuel 2"
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"MerkleTree.Spec.fst.checked",
"MerkleTree.New.High.fst.checked",
"MerkleTree.Low.Datastructures.fst.checked",
"LowStar.Vector.fst.checked",
"LowStar.RVector.fst.checked",
"LowStar.Regional.Instances.fst.checked",
"LowStar.Regional.fst.checked",
"LowStar.ConstBuffer.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Monotonic.HyperStack.fsti.checked",
"FStar.Monotonic.HyperHeap.fsti.checked",
"FStar.Integers.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.All.fst.checked",
"EverCrypt.Helpers.fsti.checked"
],
"interface_file": false,
"source_file": "MerkleTree.Low.Hashfunctions.fst"
}
|
[
{
"abbrev": false,
"full_module": "MerkleTree.Low.Datastructures",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "MerkleTree.Spec",
"short_module": "MTS"
},
{
"abbrev": true,
"full_module": "MerkleTree.New.High",
"short_module": "MTH"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Regional.Instances",
"short_module": "RVI"
},
{
"abbrev": true,
"full_module": "LowStar.RVector",
"short_module": "RV"
},
{
"abbrev": true,
"full_module": "LowStar.Vector",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "LowStar.ConstBuffer",
"short_module": "CB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperHeap",
"short_module": "HH"
},
{
"abbrev": true,
"full_module": "FStar.Monotonic.HyperStack",
"short_module": "MHS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "LowStar.Regional.Instances",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.RVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Regional",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Vector",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Integers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "MerkleTree.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 2,
"max_fuel": 2,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
h: MerkleTree.Low.Datastructures.hash -> FStar.HyperStack.ST.ST Prims.unit
|
FStar.HyperStack.ST.ST
|
[] |
[] |
[
"FStar.Ghost.erased",
"MerkleTree.Low.Datastructures.hash_size_t",
"MerkleTree.Low.Datastructures.hash",
"FStar.Ghost.reveal",
"LowStar.Monotonic.Buffer.free",
"Lib.IntTypes.uint8",
"LowStar.Buffer.trivial_preorder",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"LowStar.Regional.__proj__Rgl__item__r_inv",
"MerkleTree.Low.Datastructures.hreg",
"Prims.l_True"
] |
[] | false | true | false | false | false |
let free_hash (#hsz: Ghost.erased hash_size_t) (h: hash #hsz)
: HST.ST unit (requires (fun h0 -> (Rgl?.r_inv (hreg hsz)) h0 h)) (ensures (fun _ _ _ -> True)) =
|
B.free h
| false |
LList2.fst
|
LList2.pllist0
|
val pllist0 (p: ref (scalar (ptr cell))) (l: Ghost.erased (list U32.t)) : Tot vprop
|
val pllist0 (p: ref (scalar (ptr cell))) (l: Ghost.erased (list U32.t)) : Tot vprop
|
let pllist0
(p: ref (scalar (ptr cell)))
(l: Ghost.erased (list U32.t))
: Tot vprop
= exists_ (fun (pc: ptr cell) ->
pts_to p (mk_scalar pc) `star`
llist pc l
)
|
{
"file_name": "share/steel/examples/steelc/LList2.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
}
|
{
"end_col": 3,
"end_line": 98,
"start_col": 0,
"start_line": 91
}
|
module LList2
open Steel.ST.GenElim
open Steel.ST.C.Types
open Steel.ST.C.Types.Struct.Aux
open Steel.ST.C.Types.UserStruct // hides Struct
module U32 = FStar.UInt32
noeq
type cell_t = {
hd: scalar_t U32.t;
tl: scalar_t (ptr_gen cell_t);
}
noextract
inline_for_extraction
[@@ norm_field_attr]
let cell_struct_def : struct_def cell_t =
let fields = FStar.Set.add "hd" (FStar.Set.singleton "tl") in
let field_desc : field_description_gen_t (field_t fields) = {
fd_nonempty = nonempty_set_nonempty_type "hd" fields;
fd_type = (fun (n: field_t fields) -> match n with "hd" -> scalar_t U32.t | "tl" -> scalar_t (ptr_gen cell_t));
fd_typedef = (fun (n: field_t fields) -> match n with "hd" -> scalar U32.t | "tl" -> scalar (ptr_gen cell_t));
}
in {
fields = fields;
field_desc = field_desc;
mk = (fun f -> Mkcell_t (f "hd") (f "tl"));
get = (fun x (f: field_t fields) -> match f with "hd" -> x.hd | "tl" -> x.tl);
get_mk = (fun _ _ -> ());
extensionality = (fun s1 s2 phi -> phi "hd"; phi "tl");
}
noextract
inline_for_extraction
[@@ norm_field_attr]
let cell = struct_typedef cell_struct_def
[@@__reduce__]
let llist_nil (p: ptr cell) : Tot vprop =
pure (p == null _)
[@@__reduce__]
let llist_cons (p: ptr cell) (a: U32.t) (q: Ghost.erased (list U32.t)) (llist: (ptr cell -> (l: Ghost.erased (list U32.t) { List.Tot.length l < List.Tot.length (a :: q) }) -> Tot vprop)) : Tot vprop =
exists_ (fun (p1: ref cell) -> exists_ (fun (p2: ptr cell) ->
pts_to p1 ({ hd = mk_scalar a; tl = mk_scalar p2 }) `star`
llist p2 q `star`
freeable p1 `star`
pure (p == p1)
))
let rec llist (p: ptr cell) (l: Ghost.erased (list U32.t)) : Tot vprop (decreases (List.Tot.length l)) =
match Ghost.reveal l with
| [] -> llist_nil p
| a :: q -> llist_cons p a q llist
let intro_llist_cons
(#opened: _)
(p1: ref cell) (#v1: Ghost.erased (typeof cell)) (p2: ptr cell) (a: U32.t) (q: Ghost.erased (list U32.t))
: STGhost unit opened
(pts_to p1 v1 `star`
llist p2 q `star`
freeable p1
)
(fun _ -> llist p1 (a :: q))
(Ghost.reveal v1 == ({ hd = mk_scalar a; tl = mk_scalar p2 }))
(fun _ -> True)
= noop ();
rewrite_with_tactic (llist_cons p1 a q llist) (llist p1 (a :: q))
let elim_llist_cons
(#opened: _)
(p1: ptr cell) (a: U32.t) (q: Ghost.erased (list U32.t))
: STGhostT (p2: Ghost.erased (ptr cell) { ~ (p1 == null _) }) opened
(llist p1 (a :: q))
(fun p2 ->
pts_to p1 ({ hd = mk_scalar a; tl = mk_scalar (Ghost.reveal p2) }) `star`
llist p2 q `star`
freeable p1
)
= rewrite_with_tactic (llist p1 (a :: q)) (llist_cons p1 a q llist);
let _ = gen_elim () in
let p2' = vpattern_erased (fun x -> llist x q) in
let p2 : (p2: Ghost.erased (ptr cell) { ~ (p1 == null _) }) = p2' in
vpattern_rewrite (fun x -> llist x q) p2;
rewrite (pts_to _ _) (pts_to _ _);
rewrite (freeable _) (freeable _);
_
|
{
"checked_file": "/",
"dependencies": [
"Steel.ST.GenElim.fsti.checked",
"Steel.ST.C.Types.UserStruct.fsti.checked",
"Steel.ST.C.Types.Struct.Aux.fsti.checked",
"Steel.ST.C.Types.fst.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LList2.fst"
}
|
[
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.UserStruct // hides Struct",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.UserStruct",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.Struct.Aux",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
p:
Steel.ST.C.Types.Base.ref (Steel.ST.C.Types.Scalar.scalar (Steel.ST.C.Types.Base.ptr LList2.cell
)) ->
l: FStar.Ghost.erased (Prims.list FStar.UInt32.t)
-> Steel.Effect.Common.vprop
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Steel.ST.C.Types.Base.ref",
"Steel.ST.C.Types.Scalar.scalar_t",
"Steel.ST.C.Types.Base.ptr",
"LList2.cell_t",
"LList2.cell",
"Steel.ST.C.Types.Scalar.scalar",
"FStar.Ghost.erased",
"Prims.list",
"FStar.UInt32.t",
"Steel.ST.Util.exists_",
"Steel.Effect.Common.star",
"Steel.ST.C.Types.Base.pts_to",
"FStar.Ghost.hide",
"Steel.ST.C.Types.Scalar.mk_scalar",
"LList2.llist",
"Steel.Effect.Common.vprop"
] |
[] | false | false | false | true | false |
let pllist0 (p: ref (scalar (ptr cell))) (l: Ghost.erased (list U32.t)) : Tot vprop =
|
exists_ (fun (pc: ptr cell) -> (pts_to p (mk_scalar pc)) `star` (llist pc l))
| false |
Spec.P256.PointOps.fst
|
Spec.P256.PointOps.point_add
|
val point_add (p q: proj_point) : proj_point
|
val point_add (p q: proj_point) : proj_point
|
let point_add (p q:proj_point) : proj_point =
let x1, y1, z1 = p in
let x2, y2, z2 = q in
let t0 = x1 *% x2 in
let t1 = y1 *% y2 in
let t2 = z1 *% z2 in
let t3 = x1 +% y1 in
let t4 = x2 +% y2 in
let t3 = t3 *% t4 in
let t4 = t0 +% t1 in
let t3 = t3 -% t4 in
let t4 = y1 +% z1 in
let t5 = y2 +% z2 in
let t4 = t4 *% t5 in
let t5 = t1 +% t2 in
let t4 = t4 -% t5 in
let x3 = x1 +% z1 in
let y3 = x2 +% z2 in
let x3 = x3 *% y3 in
let y3 = t0 +% t2 in
let y3 = x3 -% y3 in
let z3 = b_coeff *% t2 in
let x3 = y3 -% z3 in
let z3 = x3 +% x3 in
let x3 = x3 +% z3 in
let z3 = t1 -% x3 in
let x3 = t1 +% x3 in
let y3 = b_coeff *% y3 in
let t1 = t2 +% t2 in
let t2 = t1 +% t2 in
let y3 = y3 -% t2 in
let y3 = y3 -% t0 in
let t1 = y3 +% y3 in
let y3 = t1 +% y3 in
let t1 = t0 +% t0 in
let t0 = t1 +% t0 in
let t0 = t0 -% t2 in
let t1 = t4 *% y3 in
let t2 = t0 *% y3 in
let y3 = x3 *% z3 in
let y3 = y3 +% t2 in
let x3 = t3 *% x3 in
let x3 = x3 -% t1 in
let z3 = t4 *% z3 in
let t1 = t3 *% t0 in
let z3 = z3 +% t1 in
(x3, y3, z3)
|
{
"file_name": "specs/Spec.P256.PointOps.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 14,
"end_line": 186,
"start_col": 0,
"start_line": 140
}
|
module Spec.P256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Base field
// 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff
let prime: (a:pos{a = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff /\ a < pow2 256}) =
let p = pow2 256 - pow2 224 + pow2 192 + pow2 96 - 1 in
assert_norm (0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff = p);
assert_norm (p < pow2 256); p
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (a:felem) : felem = M.pow_mod #prime a (prime - 2)
let fsqrt (a:felem) : felem = M.pow_mod #prime a ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let order: (a:pos{a < pow2 256}) =
let o = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551 in
assert_norm (o < pow2 256); o
let qelem = x:nat{x < order}
let qadd (x y:qelem) : qelem = (x + y) % order
let qmul (x y:qelem) : qelem = (x * y) % order
let qinv (x:qelem) : qelem = M.pow_mod #order x (order - 2)
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve `y^2 = x^3 + a * x + b`
let aff_point = p:tuple2 nat nat{let (px, py) = p in px < prime /\ py < prime}
let proj_point = p:tuple3 nat nat nat{let (px, py, pz) = p in px < prime /\ py < prime /\ pz < prime}
// let aff_point = felem & felem // Affine point
// let proj_point = felem & felem & felem // Projective coordinates
let a_coeff : felem = (-3) % prime
let b_coeff : felem =
let b = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b in
assert_norm (b < prime); b
// Base point
let g_x : felem =
let x = 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296 in
assert_norm (x < prime); x
let g_y : felem =
let y = 0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5 in
assert_norm (y < prime); y
let base_point : proj_point = (g_x, g_y, one)
let is_on_curve (p:aff_point) : bool =
let (x, y) = p in y *% y = x *% x *% x +% a_coeff *% x +% b_coeff
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
let is_point_at_inf (p:proj_point) =
let (_, _, z) = p in z = 0
let to_proj_point (p:aff_point) : proj_point =
let (x, y) = p in (x, y, one)
let to_aff_point (p:proj_point) : aff_point =
// if is_proj_point_at_inf p then aff_point_at_inf
let (px, py, pz) = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y)
/// Point addition in affine coordinates
let aff_point_double (p:aff_point) : aff_point =
let (px, py) = p in
if is_aff_point_at_inf p then p
else begin
if py = 0 then aff_point_at_inf
else begin
let lambda = (3 *% px *% px +% a_coeff) /% (2 *% py) in
let rx = lambda *% lambda -% px -% px in
let ry = lambda *% (px -% rx) -% py in
(rx, ry) end
end
let aff_point_add (p:aff_point) (q:aff_point) : aff_point =
let (px, py) = p in let (qx, qy) = q in
if is_aff_point_at_inf p then q
else begin
if is_aff_point_at_inf q then p
else begin
if p = q then aff_point_double p
else begin
if qx = px then aff_point_at_inf
else begin
let lambda = (qy -% py) /% (qx -% px) in
let rx = lambda *% lambda -% px -% qx in
let ry = lambda *% (px -% rx) -% py in
(rx, ry)
end
end
end
end
/// Point addition and doubling in projective coordinates
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.P256.PointOps.fst"
}
|
[
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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": "Spec.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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 |
p: Spec.P256.PointOps.proj_point -> q: Spec.P256.PointOps.proj_point
-> Spec.P256.PointOps.proj_point
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Spec.P256.PointOps.proj_point",
"Prims.nat",
"FStar.Pervasives.Native.Mktuple3",
"Spec.P256.PointOps.felem",
"Spec.P256.PointOps.op_Plus_Percent",
"Spec.P256.PointOps.op_Star_Percent",
"Spec.P256.PointOps.op_Subtraction_Percent",
"Spec.P256.PointOps.b_coeff"
] |
[] | false | false | false | true | false |
let point_add (p q: proj_point) : proj_point =
|
let x1, y1, z1 = p in
let x2, y2, z2 = q in
let t0 = x1 *% x2 in
let t1 = y1 *% y2 in
let t2 = z1 *% z2 in
let t3 = x1 +% y1 in
let t4 = x2 +% y2 in
let t3 = t3 *% t4 in
let t4 = t0 +% t1 in
let t3 = t3 -% t4 in
let t4 = y1 +% z1 in
let t5 = y2 +% z2 in
let t4 = t4 *% t5 in
let t5 = t1 +% t2 in
let t4 = t4 -% t5 in
let x3 = x1 +% z1 in
let y3 = x2 +% z2 in
let x3 = x3 *% y3 in
let y3 = t0 +% t2 in
let y3 = x3 -% y3 in
let z3 = b_coeff *% t2 in
let x3 = y3 -% z3 in
let z3 = x3 +% x3 in
let x3 = x3 +% z3 in
let z3 = t1 -% x3 in
let x3 = t1 +% x3 in
let y3 = b_coeff *% y3 in
let t1 = t2 +% t2 in
let t2 = t1 +% t2 in
let y3 = y3 -% t2 in
let y3 = y3 -% t0 in
let t1 = y3 +% y3 in
let y3 = t1 +% y3 in
let t1 = t0 +% t0 in
let t0 = t1 +% t0 in
let t0 = t0 -% t2 in
let t1 = t4 *% y3 in
let t2 = t0 *% y3 in
let y3 = x3 *% z3 in
let y3 = y3 +% t2 in
let x3 = t3 *% x3 in
let x3 = x3 -% t1 in
let z3 = t4 *% z3 in
let t1 = t3 *% t0 in
let z3 = z3 +% t1 in
(x3, y3, z3)
| false |
LList2.fst
|
LList2.pllist
|
val pllist (p: ref (scalar (ptr cell))) (l: Ghost.erased (list U32.t)) : Tot vprop
|
val pllist (p: ref (scalar (ptr cell))) (l: Ghost.erased (list U32.t)) : Tot vprop
|
let pllist
(p: ref (scalar (ptr cell)))
(l: Ghost.erased (list U32.t))
: Tot vprop
= pllist0 p l
|
{
"file_name": "share/steel/examples/steelc/LList2.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
}
|
{
"end_col": 13,
"end_line": 104,
"start_col": 0,
"start_line": 100
}
|
module LList2
open Steel.ST.GenElim
open Steel.ST.C.Types
open Steel.ST.C.Types.Struct.Aux
open Steel.ST.C.Types.UserStruct // hides Struct
module U32 = FStar.UInt32
noeq
type cell_t = {
hd: scalar_t U32.t;
tl: scalar_t (ptr_gen cell_t);
}
noextract
inline_for_extraction
[@@ norm_field_attr]
let cell_struct_def : struct_def cell_t =
let fields = FStar.Set.add "hd" (FStar.Set.singleton "tl") in
let field_desc : field_description_gen_t (field_t fields) = {
fd_nonempty = nonempty_set_nonempty_type "hd" fields;
fd_type = (fun (n: field_t fields) -> match n with "hd" -> scalar_t U32.t | "tl" -> scalar_t (ptr_gen cell_t));
fd_typedef = (fun (n: field_t fields) -> match n with "hd" -> scalar U32.t | "tl" -> scalar (ptr_gen cell_t));
}
in {
fields = fields;
field_desc = field_desc;
mk = (fun f -> Mkcell_t (f "hd") (f "tl"));
get = (fun x (f: field_t fields) -> match f with "hd" -> x.hd | "tl" -> x.tl);
get_mk = (fun _ _ -> ());
extensionality = (fun s1 s2 phi -> phi "hd"; phi "tl");
}
noextract
inline_for_extraction
[@@ norm_field_attr]
let cell = struct_typedef cell_struct_def
[@@__reduce__]
let llist_nil (p: ptr cell) : Tot vprop =
pure (p == null _)
[@@__reduce__]
let llist_cons (p: ptr cell) (a: U32.t) (q: Ghost.erased (list U32.t)) (llist: (ptr cell -> (l: Ghost.erased (list U32.t) { List.Tot.length l < List.Tot.length (a :: q) }) -> Tot vprop)) : Tot vprop =
exists_ (fun (p1: ref cell) -> exists_ (fun (p2: ptr cell) ->
pts_to p1 ({ hd = mk_scalar a; tl = mk_scalar p2 }) `star`
llist p2 q `star`
freeable p1 `star`
pure (p == p1)
))
let rec llist (p: ptr cell) (l: Ghost.erased (list U32.t)) : Tot vprop (decreases (List.Tot.length l)) =
match Ghost.reveal l with
| [] -> llist_nil p
| a :: q -> llist_cons p a q llist
let intro_llist_cons
(#opened: _)
(p1: ref cell) (#v1: Ghost.erased (typeof cell)) (p2: ptr cell) (a: U32.t) (q: Ghost.erased (list U32.t))
: STGhost unit opened
(pts_to p1 v1 `star`
llist p2 q `star`
freeable p1
)
(fun _ -> llist p1 (a :: q))
(Ghost.reveal v1 == ({ hd = mk_scalar a; tl = mk_scalar p2 }))
(fun _ -> True)
= noop ();
rewrite_with_tactic (llist_cons p1 a q llist) (llist p1 (a :: q))
let elim_llist_cons
(#opened: _)
(p1: ptr cell) (a: U32.t) (q: Ghost.erased (list U32.t))
: STGhostT (p2: Ghost.erased (ptr cell) { ~ (p1 == null _) }) opened
(llist p1 (a :: q))
(fun p2 ->
pts_to p1 ({ hd = mk_scalar a; tl = mk_scalar (Ghost.reveal p2) }) `star`
llist p2 q `star`
freeable p1
)
= rewrite_with_tactic (llist p1 (a :: q)) (llist_cons p1 a q llist);
let _ = gen_elim () in
let p2' = vpattern_erased (fun x -> llist x q) in
let p2 : (p2: Ghost.erased (ptr cell) { ~ (p1 == null _) }) = p2' in
vpattern_rewrite (fun x -> llist x q) p2;
rewrite (pts_to _ _) (pts_to _ _);
rewrite (freeable _) (freeable _);
_
[@@__reduce__]
let pllist0
(p: ref (scalar (ptr cell)))
(l: Ghost.erased (list U32.t))
: Tot vprop
= exists_ (fun (pc: ptr cell) ->
pts_to p (mk_scalar pc) `star`
llist pc l
)
|
{
"checked_file": "/",
"dependencies": [
"Steel.ST.GenElim.fsti.checked",
"Steel.ST.C.Types.UserStruct.fsti.checked",
"Steel.ST.C.Types.Struct.Aux.fsti.checked",
"Steel.ST.C.Types.fst.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LList2.fst"
}
|
[
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.UserStruct // hides Struct",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.UserStruct",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.Struct.Aux",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
p:
Steel.ST.C.Types.Base.ref (Steel.ST.C.Types.Scalar.scalar (Steel.ST.C.Types.Base.ptr LList2.cell
)) ->
l: FStar.Ghost.erased (Prims.list FStar.UInt32.t)
-> Steel.Effect.Common.vprop
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Steel.ST.C.Types.Base.ref",
"Steel.ST.C.Types.Scalar.scalar_t",
"Steel.ST.C.Types.Base.ptr",
"LList2.cell_t",
"LList2.cell",
"Steel.ST.C.Types.Scalar.scalar",
"FStar.Ghost.erased",
"Prims.list",
"FStar.UInt32.t",
"LList2.pllist0",
"Steel.Effect.Common.vprop"
] |
[] | false | false | false | true | false |
let pllist (p: ref (scalar (ptr cell))) (l: Ghost.erased (list U32.t)) : Tot vprop =
|
pllist0 p l
| false |
Spec.P256.PointOps.fst
|
Spec.P256.PointOps.aff_point_store
|
val aff_point_store (p: aff_point) : BSeq.lbytes 64
|
val aff_point_store (p: aff_point) : BSeq.lbytes 64
|
let aff_point_store (p:aff_point) : BSeq.lbytes 64 =
let (px, py) = p in
let pxb = BSeq.nat_to_bytes_be 32 px in
let pxy = BSeq.nat_to_bytes_be 32 py in
concat #uint8 #32 #32 pxb pxy
|
{
"file_name": "specs/Spec.P256.PointOps.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 31,
"end_line": 251,
"start_col": 0,
"start_line": 247
}
|
module Spec.P256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Base field
// 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff
let prime: (a:pos{a = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff /\ a < pow2 256}) =
let p = pow2 256 - pow2 224 + pow2 192 + pow2 96 - 1 in
assert_norm (0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff = p);
assert_norm (p < pow2 256); p
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (a:felem) : felem = M.pow_mod #prime a (prime - 2)
let fsqrt (a:felem) : felem = M.pow_mod #prime a ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let order: (a:pos{a < pow2 256}) =
let o = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551 in
assert_norm (o < pow2 256); o
let qelem = x:nat{x < order}
let qadd (x y:qelem) : qelem = (x + y) % order
let qmul (x y:qelem) : qelem = (x * y) % order
let qinv (x:qelem) : qelem = M.pow_mod #order x (order - 2)
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve `y^2 = x^3 + a * x + b`
let aff_point = p:tuple2 nat nat{let (px, py) = p in px < prime /\ py < prime}
let proj_point = p:tuple3 nat nat nat{let (px, py, pz) = p in px < prime /\ py < prime /\ pz < prime}
// let aff_point = felem & felem // Affine point
// let proj_point = felem & felem & felem // Projective coordinates
let a_coeff : felem = (-3) % prime
let b_coeff : felem =
let b = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b in
assert_norm (b < prime); b
// Base point
let g_x : felem =
let x = 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296 in
assert_norm (x < prime); x
let g_y : felem =
let y = 0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5 in
assert_norm (y < prime); y
let base_point : proj_point = (g_x, g_y, one)
let is_on_curve (p:aff_point) : bool =
let (x, y) = p in y *% y = x *% x *% x +% a_coeff *% x +% b_coeff
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
let is_point_at_inf (p:proj_point) =
let (_, _, z) = p in z = 0
let to_proj_point (p:aff_point) : proj_point =
let (x, y) = p in (x, y, one)
let to_aff_point (p:proj_point) : aff_point =
// if is_proj_point_at_inf p then aff_point_at_inf
let (px, py, pz) = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y)
/// Point addition in affine coordinates
let aff_point_double (p:aff_point) : aff_point =
let (px, py) = p in
if is_aff_point_at_inf p then p
else begin
if py = 0 then aff_point_at_inf
else begin
let lambda = (3 *% px *% px +% a_coeff) /% (2 *% py) in
let rx = lambda *% lambda -% px -% px in
let ry = lambda *% (px -% rx) -% py in
(rx, ry) end
end
let aff_point_add (p:aff_point) (q:aff_point) : aff_point =
let (px, py) = p in let (qx, qy) = q in
if is_aff_point_at_inf p then q
else begin
if is_aff_point_at_inf q then p
else begin
if p = q then aff_point_double p
else begin
if qx = px then aff_point_at_inf
else begin
let lambda = (qy -% py) /% (qx -% px) in
let rx = lambda *% lambda -% px -% qx in
let ry = lambda *% (px -% rx) -% py in
(rx, ry)
end
end
end
end
/// Point addition and doubling in projective coordinates
// Alg 4 from https://eprint.iacr.org/2015/1060.pdf
let point_add (p q:proj_point) : proj_point =
let x1, y1, z1 = p in
let x2, y2, z2 = q in
let t0 = x1 *% x2 in
let t1 = y1 *% y2 in
let t2 = z1 *% z2 in
let t3 = x1 +% y1 in
let t4 = x2 +% y2 in
let t3 = t3 *% t4 in
let t4 = t0 +% t1 in
let t3 = t3 -% t4 in
let t4 = y1 +% z1 in
let t5 = y2 +% z2 in
let t4 = t4 *% t5 in
let t5 = t1 +% t2 in
let t4 = t4 -% t5 in
let x3 = x1 +% z1 in
let y3 = x2 +% z2 in
let x3 = x3 *% y3 in
let y3 = t0 +% t2 in
let y3 = x3 -% y3 in
let z3 = b_coeff *% t2 in
let x3 = y3 -% z3 in
let z3 = x3 +% x3 in
let x3 = x3 +% z3 in
let z3 = t1 -% x3 in
let x3 = t1 +% x3 in
let y3 = b_coeff *% y3 in
let t1 = t2 +% t2 in
let t2 = t1 +% t2 in
let y3 = y3 -% t2 in
let y3 = y3 -% t0 in
let t1 = y3 +% y3 in
let y3 = t1 +% y3 in
let t1 = t0 +% t0 in
let t0 = t1 +% t0 in
let t0 = t0 -% t2 in
let t1 = t4 *% y3 in
let t2 = t0 *% y3 in
let y3 = x3 *% z3 in
let y3 = y3 +% t2 in
let x3 = t3 *% x3 in
let x3 = x3 -% t1 in
let z3 = t4 *% z3 in
let t1 = t3 *% t0 in
let z3 = z3 +% t1 in
(x3, y3, z3)
// Alg 6 from https://eprint.iacr.org/2015/1060.pdf
let point_double (p:proj_point) : proj_point =
let (x, y, z) = p in
let t0 = x *% x in
let t1 = y *% y in
let t2 = z *% z in
let t3 = x *% y in
let t3 = t3 +% t3 in
let t4 = y *% z in
let z3 = x *% z in
let z3 = z3 +% z3 in
let y3 = b_coeff *% t2 in
let y3 = y3 -% z3 in
let x3 = y3 +% y3 in
let y3 = x3 +% y3 in
let x3 = t1 -% y3 in
let y3 = t1 +% y3 in
let y3 = x3 *% y3 in
let x3 = x3 *% t3 in
let t3 = t2 +% t2 in
let t2 = t2 +% t3 in
let z3 = b_coeff *% z3 in
let z3 = z3 -% t2 in
let z3 = z3 -% t0 in
let t3 = z3 +% z3 in
let z3 = z3 +% t3 in
let t3 = t0 +% t0 in
let t0 = t3 +% t0 in
let t0 = t0 -% t2 in
let t0 = t0 *% z3 in
let y3 = y3 +% t0 in
let t0 = t4 +% t4 in
let z3 = t0 *% z3 in
let x3 = x3 -% z3 in
let z3 = t0 *% t1 in
let z3 = z3 +% z3 in
let z3 = z3 +% z3 in
(x3, y3, z3)
/// Point conversion between affine, projective and bytes representation
let aff_point_load (b:BSeq.lbytes 64) : option aff_point =
let pk_x = BSeq.nat_from_bytes_be (sub b 0 32) in
let pk_y = BSeq.nat_from_bytes_be (sub b 32 32) in
let is_x_valid = pk_x < prime in
let is_y_valid = pk_y < prime in
let is_xy_on_curve =
if is_x_valid && is_y_valid then is_on_curve (pk_x, pk_y) else false in
if is_xy_on_curve then Some (pk_x, pk_y) else None
let load_point (b:BSeq.lbytes 64) : option proj_point =
match (aff_point_load b) with
| Some p -> Some (to_proj_point p)
| None -> None
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.P256.PointOps.fst"
}
|
[
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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": "Spec.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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 |
p: Spec.P256.PointOps.aff_point -> Lib.ByteSequence.lbytes 64
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Spec.P256.PointOps.aff_point",
"Prims.nat",
"Lib.Sequence.concat",
"Lib.IntTypes.uint8",
"Lib.Sequence.seq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.l_and",
"Prims.eq2",
"Lib.Sequence.length",
"Prims.l_or",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.pow2",
"Prims.op_Multiply",
"Lib.ByteSequence.nat_from_intseq_be",
"Lib.ByteSequence.nat_to_bytes_be",
"Lib.ByteSequence.lbytes"
] |
[] | false | false | false | false | false |
let aff_point_store (p: aff_point) : BSeq.lbytes 64 =
|
let px, py = p in
let pxb = BSeq.nat_to_bytes_be 32 px in
let pxy = BSeq.nat_to_bytes_be 32 py in
concat #uint8 #32 #32 pxb pxy
| false |
Spec.P256.PointOps.fst
|
Spec.P256.PointOps.point_store
|
val point_store (p: proj_point) : BSeq.lbytes 64
|
val point_store (p: proj_point) : BSeq.lbytes 64
|
let point_store (p:proj_point) : BSeq.lbytes 64 =
aff_point_store (to_aff_point p)
|
{
"file_name": "specs/Spec.P256.PointOps.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 34,
"end_line": 255,
"start_col": 0,
"start_line": 254
}
|
module Spec.P256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Base field
// 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff
let prime: (a:pos{a = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff /\ a < pow2 256}) =
let p = pow2 256 - pow2 224 + pow2 192 + pow2 96 - 1 in
assert_norm (0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff = p);
assert_norm (p < pow2 256); p
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (a:felem) : felem = M.pow_mod #prime a (prime - 2)
let fsqrt (a:felem) : felem = M.pow_mod #prime a ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let order: (a:pos{a < pow2 256}) =
let o = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551 in
assert_norm (o < pow2 256); o
let qelem = x:nat{x < order}
let qadd (x y:qelem) : qelem = (x + y) % order
let qmul (x y:qelem) : qelem = (x * y) % order
let qinv (x:qelem) : qelem = M.pow_mod #order x (order - 2)
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve `y^2 = x^3 + a * x + b`
let aff_point = p:tuple2 nat nat{let (px, py) = p in px < prime /\ py < prime}
let proj_point = p:tuple3 nat nat nat{let (px, py, pz) = p in px < prime /\ py < prime /\ pz < prime}
// let aff_point = felem & felem // Affine point
// let proj_point = felem & felem & felem // Projective coordinates
let a_coeff : felem = (-3) % prime
let b_coeff : felem =
let b = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b in
assert_norm (b < prime); b
// Base point
let g_x : felem =
let x = 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296 in
assert_norm (x < prime); x
let g_y : felem =
let y = 0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5 in
assert_norm (y < prime); y
let base_point : proj_point = (g_x, g_y, one)
let is_on_curve (p:aff_point) : bool =
let (x, y) = p in y *% y = x *% x *% x +% a_coeff *% x +% b_coeff
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
let is_point_at_inf (p:proj_point) =
let (_, _, z) = p in z = 0
let to_proj_point (p:aff_point) : proj_point =
let (x, y) = p in (x, y, one)
let to_aff_point (p:proj_point) : aff_point =
// if is_proj_point_at_inf p then aff_point_at_inf
let (px, py, pz) = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y)
/// Point addition in affine coordinates
let aff_point_double (p:aff_point) : aff_point =
let (px, py) = p in
if is_aff_point_at_inf p then p
else begin
if py = 0 then aff_point_at_inf
else begin
let lambda = (3 *% px *% px +% a_coeff) /% (2 *% py) in
let rx = lambda *% lambda -% px -% px in
let ry = lambda *% (px -% rx) -% py in
(rx, ry) end
end
let aff_point_add (p:aff_point) (q:aff_point) : aff_point =
let (px, py) = p in let (qx, qy) = q in
if is_aff_point_at_inf p then q
else begin
if is_aff_point_at_inf q then p
else begin
if p = q then aff_point_double p
else begin
if qx = px then aff_point_at_inf
else begin
let lambda = (qy -% py) /% (qx -% px) in
let rx = lambda *% lambda -% px -% qx in
let ry = lambda *% (px -% rx) -% py in
(rx, ry)
end
end
end
end
/// Point addition and doubling in projective coordinates
// Alg 4 from https://eprint.iacr.org/2015/1060.pdf
let point_add (p q:proj_point) : proj_point =
let x1, y1, z1 = p in
let x2, y2, z2 = q in
let t0 = x1 *% x2 in
let t1 = y1 *% y2 in
let t2 = z1 *% z2 in
let t3 = x1 +% y1 in
let t4 = x2 +% y2 in
let t3 = t3 *% t4 in
let t4 = t0 +% t1 in
let t3 = t3 -% t4 in
let t4 = y1 +% z1 in
let t5 = y2 +% z2 in
let t4 = t4 *% t5 in
let t5 = t1 +% t2 in
let t4 = t4 -% t5 in
let x3 = x1 +% z1 in
let y3 = x2 +% z2 in
let x3 = x3 *% y3 in
let y3 = t0 +% t2 in
let y3 = x3 -% y3 in
let z3 = b_coeff *% t2 in
let x3 = y3 -% z3 in
let z3 = x3 +% x3 in
let x3 = x3 +% z3 in
let z3 = t1 -% x3 in
let x3 = t1 +% x3 in
let y3 = b_coeff *% y3 in
let t1 = t2 +% t2 in
let t2 = t1 +% t2 in
let y3 = y3 -% t2 in
let y3 = y3 -% t0 in
let t1 = y3 +% y3 in
let y3 = t1 +% y3 in
let t1 = t0 +% t0 in
let t0 = t1 +% t0 in
let t0 = t0 -% t2 in
let t1 = t4 *% y3 in
let t2 = t0 *% y3 in
let y3 = x3 *% z3 in
let y3 = y3 +% t2 in
let x3 = t3 *% x3 in
let x3 = x3 -% t1 in
let z3 = t4 *% z3 in
let t1 = t3 *% t0 in
let z3 = z3 +% t1 in
(x3, y3, z3)
// Alg 6 from https://eprint.iacr.org/2015/1060.pdf
let point_double (p:proj_point) : proj_point =
let (x, y, z) = p in
let t0 = x *% x in
let t1 = y *% y in
let t2 = z *% z in
let t3 = x *% y in
let t3 = t3 +% t3 in
let t4 = y *% z in
let z3 = x *% z in
let z3 = z3 +% z3 in
let y3 = b_coeff *% t2 in
let y3 = y3 -% z3 in
let x3 = y3 +% y3 in
let y3 = x3 +% y3 in
let x3 = t1 -% y3 in
let y3 = t1 +% y3 in
let y3 = x3 *% y3 in
let x3 = x3 *% t3 in
let t3 = t2 +% t2 in
let t2 = t2 +% t3 in
let z3 = b_coeff *% z3 in
let z3 = z3 -% t2 in
let z3 = z3 -% t0 in
let t3 = z3 +% z3 in
let z3 = z3 +% t3 in
let t3 = t0 +% t0 in
let t0 = t3 +% t0 in
let t0 = t0 -% t2 in
let t0 = t0 *% z3 in
let y3 = y3 +% t0 in
let t0 = t4 +% t4 in
let z3 = t0 *% z3 in
let x3 = x3 -% z3 in
let z3 = t0 *% t1 in
let z3 = z3 +% z3 in
let z3 = z3 +% z3 in
(x3, y3, z3)
/// Point conversion between affine, projective and bytes representation
let aff_point_load (b:BSeq.lbytes 64) : option aff_point =
let pk_x = BSeq.nat_from_bytes_be (sub b 0 32) in
let pk_y = BSeq.nat_from_bytes_be (sub b 32 32) in
let is_x_valid = pk_x < prime in
let is_y_valid = pk_y < prime in
let is_xy_on_curve =
if is_x_valid && is_y_valid then is_on_curve (pk_x, pk_y) else false in
if is_xy_on_curve then Some (pk_x, pk_y) else None
let load_point (b:BSeq.lbytes 64) : option proj_point =
match (aff_point_load b) with
| Some p -> Some (to_proj_point p)
| None -> None
let aff_point_store (p:aff_point) : BSeq.lbytes 64 =
let (px, py) = p in
let pxb = BSeq.nat_to_bytes_be 32 px in
let pxy = BSeq.nat_to_bytes_be 32 py in
concat #uint8 #32 #32 pxb pxy
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.P256.PointOps.fst"
}
|
[
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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": "Spec.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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 |
p: Spec.P256.PointOps.proj_point -> Lib.ByteSequence.lbytes 64
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Spec.P256.PointOps.proj_point",
"Spec.P256.PointOps.aff_point_store",
"Spec.P256.PointOps.to_aff_point",
"Lib.ByteSequence.lbytes"
] |
[] | false | false | false | false | false |
let point_store (p: proj_point) : BSeq.lbytes 64 =
|
aff_point_store (to_aff_point p)
| false |
Spec.P256.PointOps.fst
|
Spec.P256.PointOps.load_point
|
val load_point (b: BSeq.lbytes 64) : option proj_point
|
val load_point (b: BSeq.lbytes 64) : option proj_point
|
let load_point (b:BSeq.lbytes 64) : option proj_point =
match (aff_point_load b) with
| Some p -> Some (to_proj_point p)
| None -> None
|
{
"file_name": "specs/Spec.P256.PointOps.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 16,
"end_line": 244,
"start_col": 0,
"start_line": 241
}
|
module Spec.P256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Base field
// 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff
let prime: (a:pos{a = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff /\ a < pow2 256}) =
let p = pow2 256 - pow2 224 + pow2 192 + pow2 96 - 1 in
assert_norm (0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff = p);
assert_norm (p < pow2 256); p
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (a:felem) : felem = M.pow_mod #prime a (prime - 2)
let fsqrt (a:felem) : felem = M.pow_mod #prime a ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let order: (a:pos{a < pow2 256}) =
let o = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551 in
assert_norm (o < pow2 256); o
let qelem = x:nat{x < order}
let qadd (x y:qelem) : qelem = (x + y) % order
let qmul (x y:qelem) : qelem = (x * y) % order
let qinv (x:qelem) : qelem = M.pow_mod #order x (order - 2)
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve `y^2 = x^3 + a * x + b`
let aff_point = p:tuple2 nat nat{let (px, py) = p in px < prime /\ py < prime}
let proj_point = p:tuple3 nat nat nat{let (px, py, pz) = p in px < prime /\ py < prime /\ pz < prime}
// let aff_point = felem & felem // Affine point
// let proj_point = felem & felem & felem // Projective coordinates
let a_coeff : felem = (-3) % prime
let b_coeff : felem =
let b = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b in
assert_norm (b < prime); b
// Base point
let g_x : felem =
let x = 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296 in
assert_norm (x < prime); x
let g_y : felem =
let y = 0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5 in
assert_norm (y < prime); y
let base_point : proj_point = (g_x, g_y, one)
let is_on_curve (p:aff_point) : bool =
let (x, y) = p in y *% y = x *% x *% x +% a_coeff *% x +% b_coeff
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
let is_point_at_inf (p:proj_point) =
let (_, _, z) = p in z = 0
let to_proj_point (p:aff_point) : proj_point =
let (x, y) = p in (x, y, one)
let to_aff_point (p:proj_point) : aff_point =
// if is_proj_point_at_inf p then aff_point_at_inf
let (px, py, pz) = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y)
/// Point addition in affine coordinates
let aff_point_double (p:aff_point) : aff_point =
let (px, py) = p in
if is_aff_point_at_inf p then p
else begin
if py = 0 then aff_point_at_inf
else begin
let lambda = (3 *% px *% px +% a_coeff) /% (2 *% py) in
let rx = lambda *% lambda -% px -% px in
let ry = lambda *% (px -% rx) -% py in
(rx, ry) end
end
let aff_point_add (p:aff_point) (q:aff_point) : aff_point =
let (px, py) = p in let (qx, qy) = q in
if is_aff_point_at_inf p then q
else begin
if is_aff_point_at_inf q then p
else begin
if p = q then aff_point_double p
else begin
if qx = px then aff_point_at_inf
else begin
let lambda = (qy -% py) /% (qx -% px) in
let rx = lambda *% lambda -% px -% qx in
let ry = lambda *% (px -% rx) -% py in
(rx, ry)
end
end
end
end
/// Point addition and doubling in projective coordinates
// Alg 4 from https://eprint.iacr.org/2015/1060.pdf
let point_add (p q:proj_point) : proj_point =
let x1, y1, z1 = p in
let x2, y2, z2 = q in
let t0 = x1 *% x2 in
let t1 = y1 *% y2 in
let t2 = z1 *% z2 in
let t3 = x1 +% y1 in
let t4 = x2 +% y2 in
let t3 = t3 *% t4 in
let t4 = t0 +% t1 in
let t3 = t3 -% t4 in
let t4 = y1 +% z1 in
let t5 = y2 +% z2 in
let t4 = t4 *% t5 in
let t5 = t1 +% t2 in
let t4 = t4 -% t5 in
let x3 = x1 +% z1 in
let y3 = x2 +% z2 in
let x3 = x3 *% y3 in
let y3 = t0 +% t2 in
let y3 = x3 -% y3 in
let z3 = b_coeff *% t2 in
let x3 = y3 -% z3 in
let z3 = x3 +% x3 in
let x3 = x3 +% z3 in
let z3 = t1 -% x3 in
let x3 = t1 +% x3 in
let y3 = b_coeff *% y3 in
let t1 = t2 +% t2 in
let t2 = t1 +% t2 in
let y3 = y3 -% t2 in
let y3 = y3 -% t0 in
let t1 = y3 +% y3 in
let y3 = t1 +% y3 in
let t1 = t0 +% t0 in
let t0 = t1 +% t0 in
let t0 = t0 -% t2 in
let t1 = t4 *% y3 in
let t2 = t0 *% y3 in
let y3 = x3 *% z3 in
let y3 = y3 +% t2 in
let x3 = t3 *% x3 in
let x3 = x3 -% t1 in
let z3 = t4 *% z3 in
let t1 = t3 *% t0 in
let z3 = z3 +% t1 in
(x3, y3, z3)
// Alg 6 from https://eprint.iacr.org/2015/1060.pdf
let point_double (p:proj_point) : proj_point =
let (x, y, z) = p in
let t0 = x *% x in
let t1 = y *% y in
let t2 = z *% z in
let t3 = x *% y in
let t3 = t3 +% t3 in
let t4 = y *% z in
let z3 = x *% z in
let z3 = z3 +% z3 in
let y3 = b_coeff *% t2 in
let y3 = y3 -% z3 in
let x3 = y3 +% y3 in
let y3 = x3 +% y3 in
let x3 = t1 -% y3 in
let y3 = t1 +% y3 in
let y3 = x3 *% y3 in
let x3 = x3 *% t3 in
let t3 = t2 +% t2 in
let t2 = t2 +% t3 in
let z3 = b_coeff *% z3 in
let z3 = z3 -% t2 in
let z3 = z3 -% t0 in
let t3 = z3 +% z3 in
let z3 = z3 +% t3 in
let t3 = t0 +% t0 in
let t0 = t3 +% t0 in
let t0 = t0 -% t2 in
let t0 = t0 *% z3 in
let y3 = y3 +% t0 in
let t0 = t4 +% t4 in
let z3 = t0 *% z3 in
let x3 = x3 -% z3 in
let z3 = t0 *% t1 in
let z3 = z3 +% z3 in
let z3 = z3 +% z3 in
(x3, y3, z3)
/// Point conversion between affine, projective and bytes representation
let aff_point_load (b:BSeq.lbytes 64) : option aff_point =
let pk_x = BSeq.nat_from_bytes_be (sub b 0 32) in
let pk_y = BSeq.nat_from_bytes_be (sub b 32 32) in
let is_x_valid = pk_x < prime in
let is_y_valid = pk_y < prime in
let is_xy_on_curve =
if is_x_valid && is_y_valid then is_on_curve (pk_x, pk_y) else false in
if is_xy_on_curve then Some (pk_x, pk_y) else None
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.P256.PointOps.fst"
}
|
[
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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": "Spec.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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 |
b: Lib.ByteSequence.lbytes 64 -> FStar.Pervasives.Native.option Spec.P256.PointOps.proj_point
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Lib.ByteSequence.lbytes",
"Spec.P256.PointOps.aff_point_load",
"Spec.P256.PointOps.aff_point",
"FStar.Pervasives.Native.Some",
"Spec.P256.PointOps.proj_point",
"Spec.P256.PointOps.to_proj_point",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option"
] |
[] | false | false | false | false | false |
let load_point (b: BSeq.lbytes 64) : option proj_point =
|
match (aff_point_load b) with
| Some p -> Some (to_proj_point p)
| None -> None
| false |
Spec.P256.PointOps.fst
|
Spec.P256.PointOps.aff_point_load
|
val aff_point_load (b: BSeq.lbytes 64) : option aff_point
|
val aff_point_load (b: BSeq.lbytes 64) : option aff_point
|
let aff_point_load (b:BSeq.lbytes 64) : option aff_point =
let pk_x = BSeq.nat_from_bytes_be (sub b 0 32) in
let pk_y = BSeq.nat_from_bytes_be (sub b 32 32) in
let is_x_valid = pk_x < prime in
let is_y_valid = pk_y < prime in
let is_xy_on_curve =
if is_x_valid && is_y_valid then is_on_curve (pk_x, pk_y) else false in
if is_xy_on_curve then Some (pk_x, pk_y) else None
|
{
"file_name": "specs/Spec.P256.PointOps.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 52,
"end_line": 238,
"start_col": 0,
"start_line": 231
}
|
module Spec.P256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Base field
// 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff
let prime: (a:pos{a = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff /\ a < pow2 256}) =
let p = pow2 256 - pow2 224 + pow2 192 + pow2 96 - 1 in
assert_norm (0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff = p);
assert_norm (p < pow2 256); p
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (a:felem) : felem = M.pow_mod #prime a (prime - 2)
let fsqrt (a:felem) : felem = M.pow_mod #prime a ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let order: (a:pos{a < pow2 256}) =
let o = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551 in
assert_norm (o < pow2 256); o
let qelem = x:nat{x < order}
let qadd (x y:qelem) : qelem = (x + y) % order
let qmul (x y:qelem) : qelem = (x * y) % order
let qinv (x:qelem) : qelem = M.pow_mod #order x (order - 2)
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve `y^2 = x^3 + a * x + b`
let aff_point = p:tuple2 nat nat{let (px, py) = p in px < prime /\ py < prime}
let proj_point = p:tuple3 nat nat nat{let (px, py, pz) = p in px < prime /\ py < prime /\ pz < prime}
// let aff_point = felem & felem // Affine point
// let proj_point = felem & felem & felem // Projective coordinates
let a_coeff : felem = (-3) % prime
let b_coeff : felem =
let b = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b in
assert_norm (b < prime); b
// Base point
let g_x : felem =
let x = 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296 in
assert_norm (x < prime); x
let g_y : felem =
let y = 0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5 in
assert_norm (y < prime); y
let base_point : proj_point = (g_x, g_y, one)
let is_on_curve (p:aff_point) : bool =
let (x, y) = p in y *% y = x *% x *% x +% a_coeff *% x +% b_coeff
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
let is_point_at_inf (p:proj_point) =
let (_, _, z) = p in z = 0
let to_proj_point (p:aff_point) : proj_point =
let (x, y) = p in (x, y, one)
let to_aff_point (p:proj_point) : aff_point =
// if is_proj_point_at_inf p then aff_point_at_inf
let (px, py, pz) = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y)
/// Point addition in affine coordinates
let aff_point_double (p:aff_point) : aff_point =
let (px, py) = p in
if is_aff_point_at_inf p then p
else begin
if py = 0 then aff_point_at_inf
else begin
let lambda = (3 *% px *% px +% a_coeff) /% (2 *% py) in
let rx = lambda *% lambda -% px -% px in
let ry = lambda *% (px -% rx) -% py in
(rx, ry) end
end
let aff_point_add (p:aff_point) (q:aff_point) : aff_point =
let (px, py) = p in let (qx, qy) = q in
if is_aff_point_at_inf p then q
else begin
if is_aff_point_at_inf q then p
else begin
if p = q then aff_point_double p
else begin
if qx = px then aff_point_at_inf
else begin
let lambda = (qy -% py) /% (qx -% px) in
let rx = lambda *% lambda -% px -% qx in
let ry = lambda *% (px -% rx) -% py in
(rx, ry)
end
end
end
end
/// Point addition and doubling in projective coordinates
// Alg 4 from https://eprint.iacr.org/2015/1060.pdf
let point_add (p q:proj_point) : proj_point =
let x1, y1, z1 = p in
let x2, y2, z2 = q in
let t0 = x1 *% x2 in
let t1 = y1 *% y2 in
let t2 = z1 *% z2 in
let t3 = x1 +% y1 in
let t4 = x2 +% y2 in
let t3 = t3 *% t4 in
let t4 = t0 +% t1 in
let t3 = t3 -% t4 in
let t4 = y1 +% z1 in
let t5 = y2 +% z2 in
let t4 = t4 *% t5 in
let t5 = t1 +% t2 in
let t4 = t4 -% t5 in
let x3 = x1 +% z1 in
let y3 = x2 +% z2 in
let x3 = x3 *% y3 in
let y3 = t0 +% t2 in
let y3 = x3 -% y3 in
let z3 = b_coeff *% t2 in
let x3 = y3 -% z3 in
let z3 = x3 +% x3 in
let x3 = x3 +% z3 in
let z3 = t1 -% x3 in
let x3 = t1 +% x3 in
let y3 = b_coeff *% y3 in
let t1 = t2 +% t2 in
let t2 = t1 +% t2 in
let y3 = y3 -% t2 in
let y3 = y3 -% t0 in
let t1 = y3 +% y3 in
let y3 = t1 +% y3 in
let t1 = t0 +% t0 in
let t0 = t1 +% t0 in
let t0 = t0 -% t2 in
let t1 = t4 *% y3 in
let t2 = t0 *% y3 in
let y3 = x3 *% z3 in
let y3 = y3 +% t2 in
let x3 = t3 *% x3 in
let x3 = x3 -% t1 in
let z3 = t4 *% z3 in
let t1 = t3 *% t0 in
let z3 = z3 +% t1 in
(x3, y3, z3)
// Alg 6 from https://eprint.iacr.org/2015/1060.pdf
let point_double (p:proj_point) : proj_point =
let (x, y, z) = p in
let t0 = x *% x in
let t1 = y *% y in
let t2 = z *% z in
let t3 = x *% y in
let t3 = t3 +% t3 in
let t4 = y *% z in
let z3 = x *% z in
let z3 = z3 +% z3 in
let y3 = b_coeff *% t2 in
let y3 = y3 -% z3 in
let x3 = y3 +% y3 in
let y3 = x3 +% y3 in
let x3 = t1 -% y3 in
let y3 = t1 +% y3 in
let y3 = x3 *% y3 in
let x3 = x3 *% t3 in
let t3 = t2 +% t2 in
let t2 = t2 +% t3 in
let z3 = b_coeff *% z3 in
let z3 = z3 -% t2 in
let z3 = z3 -% t0 in
let t3 = z3 +% z3 in
let z3 = z3 +% t3 in
let t3 = t0 +% t0 in
let t0 = t3 +% t0 in
let t0 = t0 -% t2 in
let t0 = t0 *% z3 in
let y3 = y3 +% t0 in
let t0 = t4 +% t4 in
let z3 = t0 *% z3 in
let x3 = x3 -% z3 in
let z3 = t0 *% t1 in
let z3 = z3 +% z3 in
let z3 = z3 +% z3 in
(x3, y3, z3)
/// Point conversion between affine, projective and bytes representation
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.P256.PointOps.fst"
}
|
[
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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": "Spec.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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 |
b: Lib.ByteSequence.lbytes 64 -> FStar.Pervasives.Native.option Spec.P256.PointOps.aff_point
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Lib.ByteSequence.lbytes",
"FStar.Pervasives.Native.Some",
"Spec.P256.PointOps.aff_point",
"FStar.Pervasives.Native.Mktuple2",
"Prims.nat",
"Prims.bool",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option",
"Prims.op_AmpAmp",
"Spec.P256.PointOps.is_on_curve",
"Prims.op_LessThan",
"Spec.P256.PointOps.prime",
"Prims.b2t",
"Prims.pow2",
"Prims.op_Multiply",
"Lib.Sequence.length",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.Sequence.sub",
"Lib.ByteSequence.nat_from_bytes_be",
"Lib.IntTypes.uint_t"
] |
[] | false | false | false | false | false |
let aff_point_load (b: BSeq.lbytes 64) : option aff_point =
|
let pk_x = BSeq.nat_from_bytes_be (sub b 0 32) in
let pk_y = BSeq.nat_from_bytes_be (sub b 32 32) in
let is_x_valid = pk_x < prime in
let is_y_valid = pk_y < prime in
let is_xy_on_curve = if is_x_valid && is_y_valid then is_on_curve (pk_x, pk_y) else false in
if is_xy_on_curve then Some (pk_x, pk_y) else None
| false |
Vale.SHA.PPC64LE.Rounds.fsti
|
Vale.SHA.PPC64LE.Rounds.va_wp_Loop_rounds_16_47
|
val va_wp_Loop_rounds_16_47
(i: nat)
(k_b: buffer128)
(block: block_w)
(hash_orig: hash256)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0
|
val va_wp_Loop_rounds_16_47
(i: nat)
(k_b: buffer128)
(block: block_w)
(hash_orig: hash256)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0
|
let va_wp_Loop_rounds_16_47 (i:nat) (k_b:buffer128) (block:block_w) (hash_orig:hash256)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (l_or (i == 16) (i == 32) /\ validSrcAddrsOffset128 (va_get_mem_heaplet 0
va_s0) (va_get_reg 6 va_s0) k_b (i `op_Division` 4 + 1) 4 (va_get_mem_layout va_s0) Secret /\
(let ks = buffer128_as_seq (va_get_mem_heaplet 0 va_s0) k_b in k_reqs ks /\ va_get_reg 6 va_s0
+ 64 < pow2_64 /\ (let hash = repeat_range_vale i block hash_orig in l_and (l_and (l_and (l_and
(l_and (l_and (l_and ((va_get_vec 16 va_s0).hi3 == word_to_nat32 (index hash 0)) ((va_get_vec
17 va_s0).hi3 == word_to_nat32 (index hash 1))) ((va_get_vec 18 va_s0).hi3 == word_to_nat32
(index hash 2))) ((va_get_vec 19 va_s0).hi3 == word_to_nat32 (index hash 3))) ((va_get_vec 20
va_s0).hi3 == word_to_nat32 (index hash 4))) ((va_get_vec 21 va_s0).hi3 == word_to_nat32 (index
hash 5))) ((va_get_vec 22 va_s0).hi3 == word_to_nat32 (index hash 6))) ((va_get_vec 23
va_s0).hi3 == add_wrap32 (word_to_nat32 (index hash 7)) (k_index ks i))) /\ l_and (l_and (l_and
(l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and
((va_get_vec 0 va_s0).hi3 == ws_opaque block i) ((va_get_vec 1 va_s0).hi3 == ws_opaque block (i
- 15))) ((va_get_vec 2 va_s0).hi3 == ws_opaque block (i - 14))) ((va_get_vec 3 va_s0).hi3 ==
ws_opaque block (i - 13))) ((va_get_vec 4 va_s0).hi3 == ws_opaque block (i - 12))) ((va_get_vec
5 va_s0).hi3 == ws_opaque block (i - 11))) ((va_get_vec 6 va_s0).hi3 == ws_opaque block (i -
10))) ((va_get_vec 7 va_s0).hi3 == ws_opaque block (i - 9))) ((va_get_vec 8 va_s0).hi3 ==
ws_opaque block (i - 8))) ((va_get_vec 9 va_s0).hi3 == ws_opaque block (i - 7))) ((va_get_vec
10 va_s0).hi3 == ws_opaque block (i - 6))) ((va_get_vec 11 va_s0).hi3 == ws_opaque block (i -
5))) ((va_get_vec 12 va_s0).hi3 == ws_opaque block (i - 4))) ((va_get_vec 13 va_s0).hi3 ==
ws_opaque block (i - 3))) ((va_get_vec 14 va_s0).hi3 == ws_opaque block (i - 2))) ((va_get_vec
15 va_s0).hi3 == ws_opaque block (i - 1)) /\ l_and (l_and ((va_get_vec 24 va_s0).hi3 == k_index
ks (i + 1)) ((va_get_vec 24 va_s0).hi2 == k_index ks (i + 2))) ((va_get_vec 24 va_s0).lo1 ==
k_index ks (i + 3)))) /\ (forall (va_x_r6: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)
(va_x_v7:quad32) (va_x_v8:quad32) (va_x_v9:quad32) (va_x_v10:quad32) (va_x_v11:quad32)
(va_x_v12:quad32) (va_x_v13:quad32) (va_x_v14:quad32) (va_x_v15:quad32) (va_x_v16:quad32)
(va_x_v17:quad32) (va_x_v18:quad32) (va_x_v19:quad32) (va_x_v20:quad32) (va_x_v21:quad32)
(va_x_v22:quad32) (va_x_v23:quad32) (va_x_v24:quad32) (va_x_v25:quad32) (va_x_v26:quad32) . let
va_sM = va_upd_vec 26 va_x_v26 (va_upd_vec 25 va_x_v25 (va_upd_vec 24 va_x_v24 (va_upd_vec 23
va_x_v23 (va_upd_vec 22 va_x_v22 (va_upd_vec 21 va_x_v21 (va_upd_vec 20 va_x_v20 (va_upd_vec 19
va_x_v19 (va_upd_vec 18 va_x_v18 (va_upd_vec 17 va_x_v17 (va_upd_vec 16 va_x_v16 (va_upd_vec 15
va_x_v15 (va_upd_vec 14 va_x_v14 (va_upd_vec 13 va_x_v13 (va_upd_vec 12 va_x_v12 (va_upd_vec 11
va_x_v11 (va_upd_vec 10 va_x_v10 (va_upd_vec 9 va_x_v9 (va_upd_vec 8 va_x_v8 (va_upd_vec 7
va_x_v7 (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 6 va_x_r6
va_s0))))))))))))))))))))))))))) in va_get_ok va_sM /\ (va_get_reg 6 va_sM == va_get_reg 6
va_s0 + 64 /\ (let ks = buffer128_as_seq (va_get_mem_heaplet 0 va_sM) k_b in (let next_hash =
repeat_range_vale (i + 16) block hash_orig in l_and (l_and (l_and (l_and (l_and (l_and (l_and
((va_get_vec 16 va_sM).hi3 == word_to_nat32 (index next_hash 0)) ((va_get_vec 17 va_sM).hi3 ==
word_to_nat32 (index next_hash 1))) ((va_get_vec 18 va_sM).hi3 == word_to_nat32 (index
next_hash 2))) ((va_get_vec 19 va_sM).hi3 == word_to_nat32 (index next_hash 3))) ((va_get_vec
20 va_sM).hi3 == word_to_nat32 (index next_hash 4))) ((va_get_vec 21 va_sM).hi3 ==
word_to_nat32 (index next_hash 5))) ((va_get_vec 22 va_sM).hi3 == word_to_nat32 (index
next_hash 6))) ((va_get_vec 23 va_sM).hi3 == add_wrap32 (word_to_nat32 (index next_hash 7))
(k_index ks (i + 16)))) /\ l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and
(l_and (l_and (l_and (l_and (l_and ((va_get_vec 0 va_sM).hi3 == ws_opaque block (i + 16))
((va_get_vec 1 va_sM).hi3 == ws_opaque block (i + 1))) ((va_get_vec 2 va_sM).hi3 == ws_opaque
block (i + 2))) ((va_get_vec 3 va_sM).hi3 == ws_opaque block (i + 3))) ((va_get_vec 4
va_sM).hi3 == ws_opaque block (i + 4))) ((va_get_vec 5 va_sM).hi3 == ws_opaque block (i + 5)))
((va_get_vec 6 va_sM).hi3 == ws_opaque block (i + 6))) ((va_get_vec 7 va_sM).hi3 == ws_opaque
block (i + 7))) ((va_get_vec 8 va_sM).hi3 == ws_opaque block (i + 8))) ((va_get_vec 9
va_sM).hi3 == ws_opaque block (i + 9))) ((va_get_vec 10 va_sM).hi3 == ws_opaque block (i +
10))) ((va_get_vec 11 va_sM).hi3 == ws_opaque block (i + 11))) ((va_get_vec 12 va_sM).hi3 ==
ws_opaque block (i + 12))) ((va_get_vec 13 va_sM).hi3 == ws_opaque block (i + 13)))
((va_get_vec 14 va_sM).hi3 == ws_opaque block (i + 14))) ((va_get_vec 15 va_sM).hi3 ==
ws_opaque block (i + 15)) /\ l_and (l_and ((va_get_vec 24 va_sM).hi3 == k_index ks (i + 17))
((va_get_vec 24 va_sM).hi2 == k_index ks (i + 18))) ((va_get_vec 24 va_sM).lo1 == k_index ks (i
+ 19)))) ==> va_k va_sM (())))
|
{
"file_name": "obj/Vale.SHA.PPC64LE.Rounds.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 34,
"end_line": 351,
"start_col": 0,
"start_line": 292
}
|
module Vale.SHA.PPC64LE.Rounds
open Vale.Def.Opaque_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsStack
open Vale.PPC64LE.InsVector
open Vale.SHA.PPC64LE.SHA_helpers
open Spec.SHA2
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Loops
open Vale.SHA.PPC64LE.Rounds.Core
open Vale.SHA2.Wrapper
#reset-options "--z3rlimit 2000"
//-- Loop_rounds_0_15
val va_code_Loop_rounds_0_15 : va_dummy:unit -> Tot va_code
val va_codegen_success_Loop_rounds_0_15 : va_dummy:unit -> Tot va_pbool
val va_lemma_Loop_rounds_0_15 : va_b0:va_code -> va_s0:va_state -> in_b:buffer128 -> offset:nat ->
k_b:buffer128 -> block:block_w -> hash_orig:hash256 -> input_BE:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Loop_rounds_0_15 ()) va_s0 /\ va_get_ok va_s0 /\
(Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 0 va_s0) (va_get_reg 4 va_s0)
in_b (offset + 1) 3 (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 0 va_s0) (va_get_reg 6 va_s0) k_b
1 4 (va_get_mem_layout va_s0) Secret /\ (let ks = Vale.PPC64LE.Decls.buffer128_as_seq
(va_get_mem_heaplet 0 va_s0) k_b in Vale.SHA.PPC64LE.SHA_helpers.k_reqs ks /\ va_get_reg 4
va_s0 + 48 < pow2_64 /\ va_get_reg 6 va_s0 + 64 < pow2_64 /\ input_BE ==
Vale.Arch.Types.reverse_bytes_quad32_seq (FStar.Seq.Base.slice #Vale.PPC64LE.Machine_s.quad32
(Vale.PPC64LE.Decls.buffer128_as_seq (va_get_mem_heaplet 0 va_s0) in_b) offset (offset + 4)) /\
block == Vale.SHA.PPC64LE.SHA_helpers.quads_to_block_be input_BE /\ va_get_vec 0 va_s0 ==
FStar.Seq.Base.index #quad32 input_BE 0 /\ (let hash =
Vale.SHA.PPC64LE.SHA_helpers.repeat_range_vale 0 block hash_orig in l_and (l_and (l_and (l_and
(l_and (l_and (l_and ((va_get_vec 16 va_s0).hi3 == Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32
(FStar.Seq.Base.index #Vale.SHA.PPC64LE.SHA_helpers.word hash 0)) ((va_get_vec 17 va_s0).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 (FStar.Seq.Base.index
#Vale.SHA.PPC64LE.SHA_helpers.word hash 1))) ((va_get_vec 18 va_s0).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 (FStar.Seq.Base.index
#Vale.SHA.PPC64LE.SHA_helpers.word hash 2))) ((va_get_vec 19 va_s0).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 (FStar.Seq.Base.index
#Vale.SHA.PPC64LE.SHA_helpers.word hash 3))) ((va_get_vec 20 va_s0).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 (FStar.Seq.Base.index
#Vale.SHA.PPC64LE.SHA_helpers.word hash 4))) ((va_get_vec 21 va_s0).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 (FStar.Seq.Base.index
#Vale.SHA.PPC64LE.SHA_helpers.word hash 5))) ((va_get_vec 22 va_s0).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 (FStar.Seq.Base.index
#Vale.SHA.PPC64LE.SHA_helpers.word hash 6))) ((va_get_vec 23 va_s0).hi3 ==
Vale.Arch.Types.add_wrap32 (Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 (FStar.Seq.Base.index
#Vale.SHA.PPC64LE.SHA_helpers.word hash 7)) (Vale.SHA.PPC64LE.SHA_helpers.k_index ks 0))) /\
l_and (l_and ((va_get_vec 24 va_s0).hi3 == Vale.SHA.PPC64LE.SHA_helpers.k_index ks 1)
((va_get_vec 24 va_s0).hi2 == Vale.SHA.PPC64LE.SHA_helpers.k_index ks 2)) ((va_get_vec 24
va_s0).lo1 == Vale.SHA.PPC64LE.SHA_helpers.k_index ks 3)))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(va_get_reg 6 va_sM == va_get_reg 6 va_s0 + 64 /\ va_get_reg 4 va_sM == va_get_reg 4 va_s0 + 48
/\ (let ks = Vale.PPC64LE.Decls.buffer128_as_seq (va_get_mem_heaplet 0 va_sM) k_b in (let
next_hash = Vale.SHA.PPC64LE.SHA_helpers.repeat_range_vale 16 block hash_orig in l_and (l_and
(l_and (l_and (l_and (l_and (l_and ((va_get_vec 16 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 (FStar.Seq.Base.index
#Vale.SHA.PPC64LE.SHA_helpers.word next_hash 0)) ((va_get_vec 17 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 (FStar.Seq.Base.index
#Vale.SHA.PPC64LE.SHA_helpers.word next_hash 1))) ((va_get_vec 18 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 (FStar.Seq.Base.index
#Vale.SHA.PPC64LE.SHA_helpers.word next_hash 2))) ((va_get_vec 19 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 (FStar.Seq.Base.index
#Vale.SHA.PPC64LE.SHA_helpers.word next_hash 3))) ((va_get_vec 20 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 (FStar.Seq.Base.index
#Vale.SHA.PPC64LE.SHA_helpers.word next_hash 4))) ((va_get_vec 21 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 (FStar.Seq.Base.index
#Vale.SHA.PPC64LE.SHA_helpers.word next_hash 5))) ((va_get_vec 22 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 (FStar.Seq.Base.index
#Vale.SHA.PPC64LE.SHA_helpers.word next_hash 6))) ((va_get_vec 23 va_sM).hi3 ==
Vale.Arch.Types.add_wrap32 (Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 (FStar.Seq.Base.index
#Vale.SHA.PPC64LE.SHA_helpers.word next_hash 7)) (Vale.SHA.PPC64LE.SHA_helpers.k_index ks 16)))
/\ l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and
(l_and (l_and ((va_get_vec 0 va_sM).hi3 == Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 16)
((va_get_vec 1 va_sM).hi3 == Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 1)) ((va_get_vec 2
va_sM).hi3 == Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 2)) ((va_get_vec 3 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 3)) ((va_get_vec 4 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 4)) ((va_get_vec 5 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 5)) ((va_get_vec 6 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 6)) ((va_get_vec 7 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 7)) ((va_get_vec 8 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 8)) ((va_get_vec 9 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 9)) ((va_get_vec 10 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 10)) ((va_get_vec 11 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 11)) ((va_get_vec 12 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 12)) ((va_get_vec 13 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 13)) ((va_get_vec 14 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 14)) ((va_get_vec 15 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 15) /\ l_and (l_and ((va_get_vec 24 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.k_index ks 17) ((va_get_vec 24 va_sM).hi2 ==
Vale.SHA.PPC64LE.SHA_helpers.k_index ks 18)) ((va_get_vec 24 va_sM).lo1 ==
Vale.SHA.PPC64LE.SHA_helpers.k_index ks 19))) /\ va_state_eq va_sM (va_update_vec 26 va_sM
(va_update_vec 25 va_sM (va_update_vec 24 va_sM (va_update_vec 23 va_sM (va_update_vec 22 va_sM
(va_update_vec 21 va_sM (va_update_vec 20 va_sM (va_update_vec 19 va_sM (va_update_vec 18 va_sM
(va_update_vec 17 va_sM (va_update_vec 16 va_sM (va_update_vec 15 va_sM (va_update_vec 14 va_sM
(va_update_vec 13 va_sM (va_update_vec 12 va_sM (va_update_vec 11 va_sM (va_update_vec 10 va_sM
(va_update_vec 9 va_sM (va_update_vec 8 va_sM (va_update_vec 7 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 6 va_sM (va_update_reg 4 va_sM
(va_update_ok va_sM va_s0))))))))))))))))))))))))))))))))
[@ va_qattr]
let va_wp_Loop_rounds_0_15 (in_b:buffer128) (offset:nat) (k_b:buffer128) (block:block_w)
(hash_orig:hash256) (input_BE:(seq quad32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) :
Type0 =
(va_get_ok va_s0 /\ (Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 0 va_s0)
(va_get_reg 4 va_s0) in_b (offset + 1) 3 (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 0 va_s0) (va_get_reg 6 va_s0) k_b
1 4 (va_get_mem_layout va_s0) Secret /\ (let ks = Vale.PPC64LE.Decls.buffer128_as_seq
(va_get_mem_heaplet 0 va_s0) k_b in Vale.SHA.PPC64LE.SHA_helpers.k_reqs ks /\ va_get_reg 4
va_s0 + 48 < pow2_64 /\ va_get_reg 6 va_s0 + 64 < pow2_64 /\ input_BE ==
Vale.Arch.Types.reverse_bytes_quad32_seq (FStar.Seq.Base.slice #Vale.PPC64LE.Machine_s.quad32
(Vale.PPC64LE.Decls.buffer128_as_seq (va_get_mem_heaplet 0 va_s0) in_b) offset (offset + 4)) /\
block == Vale.SHA.PPC64LE.SHA_helpers.quads_to_block_be input_BE /\ va_get_vec 0 va_s0 ==
FStar.Seq.Base.index #quad32 input_BE 0 /\ (let hash =
Vale.SHA.PPC64LE.SHA_helpers.repeat_range_vale 0 block hash_orig in l_and (l_and (l_and (l_and
(l_and (l_and (l_and ((va_get_vec 16 va_s0).hi3 == Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32
(FStar.Seq.Base.index #Vale.SHA.PPC64LE.SHA_helpers.word hash 0)) ((va_get_vec 17 va_s0).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 (FStar.Seq.Base.index
#Vale.SHA.PPC64LE.SHA_helpers.word hash 1))) ((va_get_vec 18 va_s0).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 (FStar.Seq.Base.index
#Vale.SHA.PPC64LE.SHA_helpers.word hash 2))) ((va_get_vec 19 va_s0).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 (FStar.Seq.Base.index
#Vale.SHA.PPC64LE.SHA_helpers.word hash 3))) ((va_get_vec 20 va_s0).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 (FStar.Seq.Base.index
#Vale.SHA.PPC64LE.SHA_helpers.word hash 4))) ((va_get_vec 21 va_s0).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 (FStar.Seq.Base.index
#Vale.SHA.PPC64LE.SHA_helpers.word hash 5))) ((va_get_vec 22 va_s0).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 (FStar.Seq.Base.index
#Vale.SHA.PPC64LE.SHA_helpers.word hash 6))) ((va_get_vec 23 va_s0).hi3 ==
Vale.Arch.Types.add_wrap32 (Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 (FStar.Seq.Base.index
#Vale.SHA.PPC64LE.SHA_helpers.word hash 7)) (Vale.SHA.PPC64LE.SHA_helpers.k_index ks 0))) /\
l_and (l_and ((va_get_vec 24 va_s0).hi3 == Vale.SHA.PPC64LE.SHA_helpers.k_index ks 1)
((va_get_vec 24 va_s0).hi2 == Vale.SHA.PPC64LE.SHA_helpers.k_index ks 2)) ((va_get_vec 24
va_s0).lo1 == Vale.SHA.PPC64LE.SHA_helpers.k_index ks 3))) /\ (forall (va_x_r4:nat64)
(va_x_r6: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) (va_x_v7:quad32) (va_x_v8:quad32)
(va_x_v9:quad32) (va_x_v10:quad32) (va_x_v11:quad32) (va_x_v12:quad32) (va_x_v13:quad32)
(va_x_v14:quad32) (va_x_v15:quad32) (va_x_v16:quad32) (va_x_v17:quad32) (va_x_v18:quad32)
(va_x_v19:quad32) (va_x_v20:quad32) (va_x_v21:quad32) (va_x_v22:quad32) (va_x_v23:quad32)
(va_x_v24:quad32) (va_x_v25:quad32) (va_x_v26:quad32) . let va_sM = va_upd_vec 26 va_x_v26
(va_upd_vec 25 va_x_v25 (va_upd_vec 24 va_x_v24 (va_upd_vec 23 va_x_v23 (va_upd_vec 22 va_x_v22
(va_upd_vec 21 va_x_v21 (va_upd_vec 20 va_x_v20 (va_upd_vec 19 va_x_v19 (va_upd_vec 18 va_x_v18
(va_upd_vec 17 va_x_v17 (va_upd_vec 16 va_x_v16 (va_upd_vec 15 va_x_v15 (va_upd_vec 14 va_x_v14
(va_upd_vec 13 va_x_v13 (va_upd_vec 12 va_x_v12 (va_upd_vec 11 va_x_v11 (va_upd_vec 10 va_x_v10
(va_upd_vec 9 va_x_v9 (va_upd_vec 8 va_x_v8 (va_upd_vec 7 va_x_v7 (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 6 va_x_r6 (va_upd_reg 4 va_x_r4
va_s0)))))))))))))))))))))))))))) in va_get_ok va_sM /\ (va_get_reg 6 va_sM == va_get_reg 6
va_s0 + 64 /\ va_get_reg 4 va_sM == va_get_reg 4 va_s0 + 48 /\ (let ks =
Vale.PPC64LE.Decls.buffer128_as_seq (va_get_mem_heaplet 0 va_sM) k_b in (let next_hash =
Vale.SHA.PPC64LE.SHA_helpers.repeat_range_vale 16 block hash_orig in l_and (l_and (l_and (l_and
(l_and (l_and (l_and ((va_get_vec 16 va_sM).hi3 == Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32
(FStar.Seq.Base.index #Vale.SHA.PPC64LE.SHA_helpers.word next_hash 0)) ((va_get_vec 17
va_sM).hi3 == Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 (FStar.Seq.Base.index
#Vale.SHA.PPC64LE.SHA_helpers.word next_hash 1))) ((va_get_vec 18 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 (FStar.Seq.Base.index
#Vale.SHA.PPC64LE.SHA_helpers.word next_hash 2))) ((va_get_vec 19 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 (FStar.Seq.Base.index
#Vale.SHA.PPC64LE.SHA_helpers.word next_hash 3))) ((va_get_vec 20 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 (FStar.Seq.Base.index
#Vale.SHA.PPC64LE.SHA_helpers.word next_hash 4))) ((va_get_vec 21 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 (FStar.Seq.Base.index
#Vale.SHA.PPC64LE.SHA_helpers.word next_hash 5))) ((va_get_vec 22 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 (FStar.Seq.Base.index
#Vale.SHA.PPC64LE.SHA_helpers.word next_hash 6))) ((va_get_vec 23 va_sM).hi3 ==
Vale.Arch.Types.add_wrap32 (Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32 (FStar.Seq.Base.index
#Vale.SHA.PPC64LE.SHA_helpers.word next_hash 7)) (Vale.SHA.PPC64LE.SHA_helpers.k_index ks 16)))
/\ l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and
(l_and (l_and ((va_get_vec 0 va_sM).hi3 == Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 16)
((va_get_vec 1 va_sM).hi3 == Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 1)) ((va_get_vec 2
va_sM).hi3 == Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 2)) ((va_get_vec 3 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 3)) ((va_get_vec 4 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 4)) ((va_get_vec 5 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 5)) ((va_get_vec 6 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 6)) ((va_get_vec 7 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 7)) ((va_get_vec 8 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 8)) ((va_get_vec 9 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 9)) ((va_get_vec 10 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 10)) ((va_get_vec 11 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 11)) ((va_get_vec 12 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 12)) ((va_get_vec 13 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 13)) ((va_get_vec 14 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 14)) ((va_get_vec 15 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.ws_opaque block 15) /\ l_and (l_and ((va_get_vec 24 va_sM).hi3 ==
Vale.SHA.PPC64LE.SHA_helpers.k_index ks 17) ((va_get_vec 24 va_sM).hi2 ==
Vale.SHA.PPC64LE.SHA_helpers.k_index ks 18)) ((va_get_vec 24 va_sM).lo1 ==
Vale.SHA.PPC64LE.SHA_helpers.k_index ks 19))) ==> va_k va_sM (())))
val va_wpProof_Loop_rounds_0_15 : in_b:buffer128 -> offset:nat -> k_b:buffer128 -> block:block_w ->
hash_orig:hash256 -> input_BE:(seq quad32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Loop_rounds_0_15 in_b offset k_b block hash_orig input_BE
va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Loop_rounds_0_15 ()) ([va_Mod_vec 26;
va_Mod_vec 25; va_Mod_vec 24; va_Mod_vec 23; va_Mod_vec 22; va_Mod_vec 21; va_Mod_vec 20;
va_Mod_vec 19; va_Mod_vec 18; va_Mod_vec 17; va_Mod_vec 16; va_Mod_vec 15; va_Mod_vec 14;
va_Mod_vec 13; va_Mod_vec 12; va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8;
va_Mod_vec 7; 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 6; va_Mod_reg 4]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_Loop_rounds_0_15 (in_b:buffer128) (offset:nat) (k_b:buffer128) (block:block_w)
(hash_orig:hash256) (input_BE:(seq quad32)) : (va_quickCode unit (va_code_Loop_rounds_0_15 ())) =
(va_QProc (va_code_Loop_rounds_0_15 ()) ([va_Mod_vec 26; va_Mod_vec 25; va_Mod_vec 24; va_Mod_vec
23; va_Mod_vec 22; va_Mod_vec 21; va_Mod_vec 20; va_Mod_vec 19; va_Mod_vec 18; va_Mod_vec 17;
va_Mod_vec 16; va_Mod_vec 15; va_Mod_vec 14; va_Mod_vec 13; va_Mod_vec 12; va_Mod_vec 11;
va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 7; 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 6; va_Mod_reg 4])
(va_wp_Loop_rounds_0_15 in_b offset k_b block hash_orig input_BE) (va_wpProof_Loop_rounds_0_15
in_b offset k_b block hash_orig input_BE))
//--
//-- Loop_rounds_16_47
val va_code_Loop_rounds_16_47 : i:nat -> Tot va_code
val va_codegen_success_Loop_rounds_16_47 : i:nat -> Tot va_pbool
val va_lemma_Loop_rounds_16_47 : va_b0:va_code -> va_s0:va_state -> i:nat -> k_b:buffer128 ->
block:block_w -> hash_orig:hash256
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Loop_rounds_16_47 i) va_s0 /\ va_get_ok va_s0 /\ (l_or
(i == 16) (i == 32) /\ validSrcAddrsOffset128 (va_get_mem_heaplet 0 va_s0) (va_get_reg 6 va_s0)
k_b (i `op_Division` 4 + 1) 4 (va_get_mem_layout va_s0) Secret /\ (let ks = buffer128_as_seq
(va_get_mem_heaplet 0 va_s0) k_b in k_reqs ks /\ va_get_reg 6 va_s0 + 64 < pow2_64 /\ (let hash
= repeat_range_vale i block hash_orig in l_and (l_and (l_and (l_and (l_and (l_and (l_and
((va_get_vec 16 va_s0).hi3 == word_to_nat32 (index hash 0)) ((va_get_vec 17 va_s0).hi3 ==
word_to_nat32 (index hash 1))) ((va_get_vec 18 va_s0).hi3 == word_to_nat32 (index hash 2)))
((va_get_vec 19 va_s0).hi3 == word_to_nat32 (index hash 3))) ((va_get_vec 20 va_s0).hi3 ==
word_to_nat32 (index hash 4))) ((va_get_vec 21 va_s0).hi3 == word_to_nat32 (index hash 5)))
((va_get_vec 22 va_s0).hi3 == word_to_nat32 (index hash 6))) ((va_get_vec 23 va_s0).hi3 ==
add_wrap32 (word_to_nat32 (index hash 7)) (k_index ks i))) /\ l_and (l_and (l_and (l_and (l_and
(l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and ((va_get_vec 0 va_s0).hi3
== ws_opaque block i) ((va_get_vec 1 va_s0).hi3 == ws_opaque block (i - 15))) ((va_get_vec 2
va_s0).hi3 == ws_opaque block (i - 14))) ((va_get_vec 3 va_s0).hi3 == ws_opaque block (i -
13))) ((va_get_vec 4 va_s0).hi3 == ws_opaque block (i - 12))) ((va_get_vec 5 va_s0).hi3 ==
ws_opaque block (i - 11))) ((va_get_vec 6 va_s0).hi3 == ws_opaque block (i - 10))) ((va_get_vec
7 va_s0).hi3 == ws_opaque block (i - 9))) ((va_get_vec 8 va_s0).hi3 == ws_opaque block (i -
8))) ((va_get_vec 9 va_s0).hi3 == ws_opaque block (i - 7))) ((va_get_vec 10 va_s0).hi3 ==
ws_opaque block (i - 6))) ((va_get_vec 11 va_s0).hi3 == ws_opaque block (i - 5))) ((va_get_vec
12 va_s0).hi3 == ws_opaque block (i - 4))) ((va_get_vec 13 va_s0).hi3 == ws_opaque block (i -
3))) ((va_get_vec 14 va_s0).hi3 == ws_opaque block (i - 2))) ((va_get_vec 15 va_s0).hi3 ==
ws_opaque block (i - 1)) /\ l_and (l_and ((va_get_vec 24 va_s0).hi3 == k_index ks (i + 1))
((va_get_vec 24 va_s0).hi2 == k_index ks (i + 2))) ((va_get_vec 24 va_s0).lo1 == k_index ks (i
+ 3))))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(va_get_reg 6 va_sM == va_get_reg 6 va_s0 + 64 /\ (let ks = buffer128_as_seq
(va_get_mem_heaplet 0 va_sM) k_b in (let next_hash = repeat_range_vale (i + 16) block hash_orig
in l_and (l_and (l_and (l_and (l_and (l_and (l_and ((va_get_vec 16 va_sM).hi3 == word_to_nat32
(index next_hash 0)) ((va_get_vec 17 va_sM).hi3 == word_to_nat32 (index next_hash 1)))
((va_get_vec 18 va_sM).hi3 == word_to_nat32 (index next_hash 2))) ((va_get_vec 19 va_sM).hi3 ==
word_to_nat32 (index next_hash 3))) ((va_get_vec 20 va_sM).hi3 == word_to_nat32 (index
next_hash 4))) ((va_get_vec 21 va_sM).hi3 == word_to_nat32 (index next_hash 5))) ((va_get_vec
22 va_sM).hi3 == word_to_nat32 (index next_hash 6))) ((va_get_vec 23 va_sM).hi3 == add_wrap32
(word_to_nat32 (index next_hash 7)) (k_index ks (i + 16)))) /\ l_and (l_and (l_and (l_and
(l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and ((va_get_vec 0
va_sM).hi3 == ws_opaque block (i + 16)) ((va_get_vec 1 va_sM).hi3 == ws_opaque block (i + 1)))
((va_get_vec 2 va_sM).hi3 == ws_opaque block (i + 2))) ((va_get_vec 3 va_sM).hi3 == ws_opaque
block (i + 3))) ((va_get_vec 4 va_sM).hi3 == ws_opaque block (i + 4))) ((va_get_vec 5
va_sM).hi3 == ws_opaque block (i + 5))) ((va_get_vec 6 va_sM).hi3 == ws_opaque block (i + 6)))
((va_get_vec 7 va_sM).hi3 == ws_opaque block (i + 7))) ((va_get_vec 8 va_sM).hi3 == ws_opaque
block (i + 8))) ((va_get_vec 9 va_sM).hi3 == ws_opaque block (i + 9))) ((va_get_vec 10
va_sM).hi3 == ws_opaque block (i + 10))) ((va_get_vec 11 va_sM).hi3 == ws_opaque block (i +
11))) ((va_get_vec 12 va_sM).hi3 == ws_opaque block (i + 12))) ((va_get_vec 13 va_sM).hi3 ==
ws_opaque block (i + 13))) ((va_get_vec 14 va_sM).hi3 == ws_opaque block (i + 14)))
((va_get_vec 15 va_sM).hi3 == ws_opaque block (i + 15)) /\ l_and (l_and ((va_get_vec 24
va_sM).hi3 == k_index ks (i + 17)) ((va_get_vec 24 va_sM).hi2 == k_index ks (i + 18)))
((va_get_vec 24 va_sM).lo1 == k_index ks (i + 19)))) /\ va_state_eq va_sM (va_update_vec 26
va_sM (va_update_vec 25 va_sM (va_update_vec 24 va_sM (va_update_vec 23 va_sM (va_update_vec 22
va_sM (va_update_vec 21 va_sM (va_update_vec 20 va_sM (va_update_vec 19 va_sM (va_update_vec 18
va_sM (va_update_vec 17 va_sM (va_update_vec 16 va_sM (va_update_vec 15 va_sM (va_update_vec 14
va_sM (va_update_vec 13 va_sM (va_update_vec 12 va_sM (va_update_vec 11 va_sM (va_update_vec 10
va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM (va_update_vec 7 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 6 va_sM (va_update_ok va_sM
va_s0)))))))))))))))))))))))))))))))
|
{
"checked_file": "/",
"dependencies": [
"Vale.SHA2.Wrapper.fsti.checked",
"Vale.SHA.PPC64LE.SHA_helpers.fsti.checked",
"Vale.SHA.PPC64LE.Rounds.Core.fsti.checked",
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.Stack_i.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.InsStack.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Spec.SHA2.fsti.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.SHA.PPC64LE.Rounds.fsti"
}
|
[
{
"abbrev": false,
"full_module": "Vale.SHA2.Wrapper",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE.Rounds.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Loops",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsStack",
"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.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"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.Stack_i",
"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.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.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.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": 2000,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
i: Prims.nat ->
k_b: Vale.PPC64LE.Memory.buffer128 ->
block: Vale.SHA.PPC64LE.SHA_helpers.block_w ->
hash_orig: Vale.SHA.PPC64LE.SHA_helpers.hash256 ->
va_s0: Vale.PPC64LE.Decls.va_state ->
va_k: (_: Vale.PPC64LE.Decls.va_state -> _: Prims.unit -> Type0)
-> Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Prims.nat",
"Vale.PPC64LE.Memory.buffer128",
"Vale.SHA.PPC64LE.SHA_helpers.block_w",
"Vale.SHA.PPC64LE.SHA_helpers.hash256",
"Vale.PPC64LE.Decls.va_state",
"Prims.unit",
"Prims.l_and",
"Prims.b2t",
"Vale.PPC64LE.Decls.va_get_ok",
"Prims.l_or",
"Prims.eq2",
"Prims.int",
"Vale.PPC64LE.Decls.validSrcAddrsOffset128",
"Vale.PPC64LE.Decls.va_get_mem_heaplet",
"Vale.PPC64LE.Decls.va_get_reg",
"Prims.op_Addition",
"Prims.op_Division",
"Vale.PPC64LE.Decls.va_get_mem_layout",
"Vale.Arch.HeapTypes_s.Secret",
"Vale.SHA.PPC64LE.SHA_helpers.k_reqs",
"Prims.op_LessThan",
"Vale.PPC64LE.Machine_s.pow2_64",
"Vale.Def.Words_s.nat32",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"Vale.Def.Types_s.nat32",
"Vale.PPC64LE.Decls.va_get_vec",
"Vale.SHA.PPC64LE.SHA_helpers.word_to_nat32",
"FStar.Seq.Base.index",
"Vale.SHA.PPC64LE.SHA_helpers.word",
"Vale.Arch.Types.add_wrap32",
"Vale.SHA.PPC64LE.SHA_helpers.k_index",
"Vale.SHA.PPC64LE.SHA_helpers.repeat_range_vale",
"Vale.SHA.PPC64LE.SHA_helpers.ws_opaque",
"Prims.op_Subtraction",
"Vale.Def.Words_s.__proj__Mkfour__item__hi2",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.quad32",
"Vale.PPC64LE.Decls.buffer128_as_seq",
"Prims.l_Forall",
"Vale.PPC64LE.Memory.nat64",
"Vale.PPC64LE.Memory.quad32",
"Prims.l_imp",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.Decls.va_upd_vec",
"Vale.PPC64LE.Decls.va_upd_reg"
] |
[] | false | false | false | true | true |
let va_wp_Loop_rounds_16_47
(i: nat)
(k_b: buffer128)
(block: block_w)
(hash_orig: hash256)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 =
|
(va_get_ok va_s0 /\
(l_or (i == 16) (i == 32) /\
validSrcAddrsOffset128 (va_get_mem_heaplet 0 va_s0)
(va_get_reg 6 va_s0)
k_b
(i `op_Division` 4 + 1)
4
(va_get_mem_layout va_s0)
Secret /\
(let ks = buffer128_as_seq (va_get_mem_heaplet 0 va_s0) k_b in
k_reqs ks /\ va_get_reg 6 va_s0 + 64 < pow2_64 /\
(let hash = repeat_range_vale i block hash_orig in
l_and (l_and (l_and (l_and (l_and (l_and (l_and ((va_get_vec 16 va_s0).hi3 ==
word_to_nat32 (index hash 0))
((va_get_vec 17 va_s0).hi3 == word_to_nat32 (index hash 1)))
((va_get_vec 18 va_s0).hi3 == word_to_nat32 (index hash 2)))
((va_get_vec 19 va_s0).hi3 == word_to_nat32 (index hash 3)))
((va_get_vec 20 va_s0).hi3 == word_to_nat32 (index hash 4)))
((va_get_vec 21 va_s0).hi3 == word_to_nat32 (index hash 5)))
((va_get_vec 22 va_s0).hi3 == word_to_nat32 (index hash 6)))
((va_get_vec 23 va_s0).hi3 == add_wrap32 (word_to_nat32 (index hash 7)) (k_index ks i))) /\
l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and
(l_and ((va_get_vec 0 va_s0).hi3 ==
ws_opaque block i)
((va_get_vec 1 va_s0).hi3 ==
ws_opaque block (i - 15)))
((va_get_vec 2 va_s0).hi3 ==
ws_opaque block (i - 14)))
((va_get_vec 3 va_s0).hi3 ==
ws_opaque block (i - 13)))
((va_get_vec 4 va_s0).hi3 ==
ws_opaque block (i - 12)))
((va_get_vec 5 va_s0).hi3 ==
ws_opaque block (i - 11)))
((va_get_vec 6 va_s0).hi3 == ws_opaque block (i - 10)))
((va_get_vec 7 va_s0).hi3 == ws_opaque block (i - 9)))
((va_get_vec 8 va_s0).hi3 == ws_opaque block (i - 8)))
((va_get_vec 9 va_s0).hi3 == ws_opaque block (i - 7)))
((va_get_vec 10 va_s0).hi3 == ws_opaque block (i - 6)))
((va_get_vec 11 va_s0).hi3 == ws_opaque block (i - 5)))
((va_get_vec 12 va_s0).hi3 == ws_opaque block (i - 4)))
((va_get_vec 13 va_s0).hi3 == ws_opaque block (i - 3)))
((va_get_vec 14 va_s0).hi3 == ws_opaque block (i - 2)))
((va_get_vec 15 va_s0).hi3 == ws_opaque block (i - 1)) /\
l_and (l_and ((va_get_vec 24 va_s0).hi3 == k_index ks (i + 1))
((va_get_vec 24 va_s0).hi2 == k_index ks (i + 2)))
((va_get_vec 24 va_s0).lo1 == k_index ks (i + 3)))) /\
(forall (va_x_r6: 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) (va_x_v7: quad32) (va_x_v8: quad32)
(va_x_v9: quad32) (va_x_v10: quad32) (va_x_v11: quad32) (va_x_v12: quad32) (va_x_v13: quad32)
(va_x_v14: quad32) (va_x_v15: quad32) (va_x_v16: quad32) (va_x_v17: quad32) (va_x_v18: quad32)
(va_x_v19: quad32) (va_x_v20: quad32) (va_x_v21: quad32) (va_x_v22: quad32) (va_x_v23: quad32)
(va_x_v24: quad32) (va_x_v25: quad32) (va_x_v26: quad32).
let va_sM =
va_upd_vec 26
va_x_v26
(va_upd_vec 25
va_x_v25
(va_upd_vec 24
va_x_v24
(va_upd_vec 23
va_x_v23
(va_upd_vec 22
va_x_v22
(va_upd_vec 21
va_x_v21
(va_upd_vec 20
va_x_v20
(va_upd_vec 19
va_x_v19
(va_upd_vec 18
va_x_v18
(va_upd_vec 17
va_x_v17
(va_upd_vec 16
va_x_v16
(va_upd_vec 15
va_x_v15
(va_upd_vec 14
va_x_v14
(va_upd_vec 13
va_x_v13
(va_upd_vec 12
va_x_v12
(va_upd_vec 11
va_x_v11
(va_upd_vec 10
va_x_v10
(va_upd_vec 9
va_x_v9
(va_upd_vec 8
va_x_v8
(va_upd_vec 7
va_x_v7
(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
6
va_x_r6
va_s0
)
)
)
)
))
))))))))))
)))))))))))
in
va_get_ok va_sM /\
(va_get_reg 6 va_sM == va_get_reg 6 va_s0 + 64 /\
(let ks = buffer128_as_seq (va_get_mem_heaplet 0 va_sM) k_b in
(let next_hash = repeat_range_vale (i + 16) block hash_orig in
l_and (l_and (l_and (l_and (l_and (l_and (l_and ((va_get_vec 16 va_sM).hi3 ==
word_to_nat32 (index next_hash 0))
((va_get_vec 17 va_sM).hi3 ==
word_to_nat32 (index next_hash 1)))
((va_get_vec 18 va_sM).hi3 == word_to_nat32 (index next_hash 2)))
((va_get_vec 19 va_sM).hi3 == word_to_nat32 (index next_hash 3)))
((va_get_vec 20 va_sM).hi3 == word_to_nat32 (index next_hash 4)))
((va_get_vec 21 va_sM).hi3 == word_to_nat32 (index next_hash 5)))
((va_get_vec 22 va_sM).hi3 == word_to_nat32 (index next_hash 6)))
((va_get_vec 23 va_sM).hi3 ==
add_wrap32 (word_to_nat32 (index next_hash 7)) (k_index ks (i + 16)))) /\
l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (l_and (
l_and (l_and ((va_get_vec 0 va_sM).hi3 ==
ws_opaque block (i + 16))
((va_get_vec 1 va_sM).hi3 ==
ws_opaque block (i + 1)))
((va_get_vec 2 va_sM).hi3 ==
ws_opaque block (i + 2)))
((va_get_vec 3 va_sM).hi3 ==
ws_opaque block (i + 3)))
((va_get_vec 4 va_sM).hi3 ==
ws_opaque block (i + 4)))
((va_get_vec 5 va_sM).hi3 ==
ws_opaque block (i + 5)))
((va_get_vec 6 va_sM).hi3 == ws_opaque block (i + 6)
))
((va_get_vec 7 va_sM).hi3 == ws_opaque block (i + 7)))
((va_get_vec 8 va_sM).hi3 == ws_opaque block (i + 8)))
((va_get_vec 9 va_sM).hi3 == ws_opaque block (i + 9)))
((va_get_vec 10 va_sM).hi3 == ws_opaque block (i + 10)))
((va_get_vec 11 va_sM).hi3 == ws_opaque block (i + 11)))
((va_get_vec 12 va_sM).hi3 == ws_opaque block (i + 12)))
((va_get_vec 13 va_sM).hi3 == ws_opaque block (i + 13)))
((va_get_vec 14 va_sM).hi3 == ws_opaque block (i + 14)))
((va_get_vec 15 va_sM).hi3 == ws_opaque block (i + 15)) /\
l_and (l_and ((va_get_vec 24 va_sM).hi3 == k_index ks (i + 17))
((va_get_vec 24 va_sM).hi2 == k_index ks (i + 18)))
((va_get_vec 24 va_sM).lo1 == k_index ks (i + 19)))) ==>
va_k va_sM (())))
| false |
Spec.P256.PointOps.fst
|
Spec.P256.PointOps.aff_point_decompress
|
val aff_point_decompress (s: BSeq.lbytes 33) : option aff_point
|
val aff_point_decompress (s: BSeq.lbytes 33) : option aff_point
|
let aff_point_decompress (s:BSeq.lbytes 33) : option aff_point =
let s0 = Lib.RawIntTypes.u8_to_UInt8 s.[0] in
if not (s0 = 0x02uy || s0 = 0x03uy) then None
else begin
let x = BSeq.nat_from_bytes_be (sub s 1 32) in
let is_x_valid = x < prime in
let is_y_odd = s0 = 0x03uy in
if not is_x_valid then None
else
match (recover_y x is_y_odd) with
| Some y -> Some (x, y)
| None -> None end
|
{
"file_name": "specs/Spec.P256.PointOps.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 24,
"end_line": 279,
"start_col": 0,
"start_line": 267
}
|
module Spec.P256.PointOps
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
module M = Lib.NatMod
module BSeq = Lib.ByteSequence
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Base field
// 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff
let prime: (a:pos{a = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff /\ a < pow2 256}) =
let p = pow2 256 - pow2 224 + pow2 192 + pow2 96 - 1 in
assert_norm (0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff = p);
assert_norm (p < pow2 256); p
let felem = x:nat{x < prime}
let zero : felem = 0
let one : felem = 1
let fadd (x y:felem) : felem = (x + y) % prime
let fsub (x y:felem) : felem = (x - y) % prime
let fmul (x y:felem) : felem = (x * y) % prime
let finv (a:felem) : felem = M.pow_mod #prime a (prime - 2)
let fsqrt (a:felem) : felem = M.pow_mod #prime a ((prime + 1) / 4)
let is_fodd (x:nat) : bool = x % 2 = 1
let ( +% ) = fadd
let ( -% ) = fsub
let ( *% ) = fmul
let ( /% ) (x y:felem) = x *% finv y
/// Scalar field
// Group order
let order: (a:pos{a < pow2 256}) =
let o = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551 in
assert_norm (o < pow2 256); o
let qelem = x:nat{x < order}
let qadd (x y:qelem) : qelem = (x + y) % order
let qmul (x y:qelem) : qelem = (x * y) % order
let qinv (x:qelem) : qelem = M.pow_mod #order x (order - 2)
let ( +^ ) = qadd
let ( *^ ) = qmul
/// Elliptic curve `y^2 = x^3 + a * x + b`
let aff_point = p:tuple2 nat nat{let (px, py) = p in px < prime /\ py < prime}
let proj_point = p:tuple3 nat nat nat{let (px, py, pz) = p in px < prime /\ py < prime /\ pz < prime}
// let aff_point = felem & felem // Affine point
// let proj_point = felem & felem & felem // Projective coordinates
let a_coeff : felem = (-3) % prime
let b_coeff : felem =
let b = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b in
assert_norm (b < prime); b
// Base point
let g_x : felem =
let x = 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296 in
assert_norm (x < prime); x
let g_y : felem =
let y = 0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5 in
assert_norm (y < prime); y
let base_point : proj_point = (g_x, g_y, one)
let is_on_curve (p:aff_point) : bool =
let (x, y) = p in y *% y = x *% x *% x +% a_coeff *% x +% b_coeff
let aff_point_at_inf : aff_point = (zero, zero) // not on the curve!
let point_at_inf : proj_point = (zero, one, zero)
let is_aff_point_at_inf (p:aff_point) : bool =
let (x, y) = p in x = zero && y = zero
let is_point_at_inf (p:proj_point) =
let (_, _, z) = p in z = 0
let to_proj_point (p:aff_point) : proj_point =
let (x, y) = p in (x, y, one)
let to_aff_point (p:proj_point) : aff_point =
// if is_proj_point_at_inf p then aff_point_at_inf
let (px, py, pz) = p in
let zinv = finv pz in
let x = px *% zinv in
let y = py *% zinv in
(x, y)
/// Point addition in affine coordinates
let aff_point_double (p:aff_point) : aff_point =
let (px, py) = p in
if is_aff_point_at_inf p then p
else begin
if py = 0 then aff_point_at_inf
else begin
let lambda = (3 *% px *% px +% a_coeff) /% (2 *% py) in
let rx = lambda *% lambda -% px -% px in
let ry = lambda *% (px -% rx) -% py in
(rx, ry) end
end
let aff_point_add (p:aff_point) (q:aff_point) : aff_point =
let (px, py) = p in let (qx, qy) = q in
if is_aff_point_at_inf p then q
else begin
if is_aff_point_at_inf q then p
else begin
if p = q then aff_point_double p
else begin
if qx = px then aff_point_at_inf
else begin
let lambda = (qy -% py) /% (qx -% px) in
let rx = lambda *% lambda -% px -% qx in
let ry = lambda *% (px -% rx) -% py in
(rx, ry)
end
end
end
end
/// Point addition and doubling in projective coordinates
// Alg 4 from https://eprint.iacr.org/2015/1060.pdf
let point_add (p q:proj_point) : proj_point =
let x1, y1, z1 = p in
let x2, y2, z2 = q in
let t0 = x1 *% x2 in
let t1 = y1 *% y2 in
let t2 = z1 *% z2 in
let t3 = x1 +% y1 in
let t4 = x2 +% y2 in
let t3 = t3 *% t4 in
let t4 = t0 +% t1 in
let t3 = t3 -% t4 in
let t4 = y1 +% z1 in
let t5 = y2 +% z2 in
let t4 = t4 *% t5 in
let t5 = t1 +% t2 in
let t4 = t4 -% t5 in
let x3 = x1 +% z1 in
let y3 = x2 +% z2 in
let x3 = x3 *% y3 in
let y3 = t0 +% t2 in
let y3 = x3 -% y3 in
let z3 = b_coeff *% t2 in
let x3 = y3 -% z3 in
let z3 = x3 +% x3 in
let x3 = x3 +% z3 in
let z3 = t1 -% x3 in
let x3 = t1 +% x3 in
let y3 = b_coeff *% y3 in
let t1 = t2 +% t2 in
let t2 = t1 +% t2 in
let y3 = y3 -% t2 in
let y3 = y3 -% t0 in
let t1 = y3 +% y3 in
let y3 = t1 +% y3 in
let t1 = t0 +% t0 in
let t0 = t1 +% t0 in
let t0 = t0 -% t2 in
let t1 = t4 *% y3 in
let t2 = t0 *% y3 in
let y3 = x3 *% z3 in
let y3 = y3 +% t2 in
let x3 = t3 *% x3 in
let x3 = x3 -% t1 in
let z3 = t4 *% z3 in
let t1 = t3 *% t0 in
let z3 = z3 +% t1 in
(x3, y3, z3)
// Alg 6 from https://eprint.iacr.org/2015/1060.pdf
let point_double (p:proj_point) : proj_point =
let (x, y, z) = p in
let t0 = x *% x in
let t1 = y *% y in
let t2 = z *% z in
let t3 = x *% y in
let t3 = t3 +% t3 in
let t4 = y *% z in
let z3 = x *% z in
let z3 = z3 +% z3 in
let y3 = b_coeff *% t2 in
let y3 = y3 -% z3 in
let x3 = y3 +% y3 in
let y3 = x3 +% y3 in
let x3 = t1 -% y3 in
let y3 = t1 +% y3 in
let y3 = x3 *% y3 in
let x3 = x3 *% t3 in
let t3 = t2 +% t2 in
let t2 = t2 +% t3 in
let z3 = b_coeff *% z3 in
let z3 = z3 -% t2 in
let z3 = z3 -% t0 in
let t3 = z3 +% z3 in
let z3 = z3 +% t3 in
let t3 = t0 +% t0 in
let t0 = t3 +% t0 in
let t0 = t0 -% t2 in
let t0 = t0 *% z3 in
let y3 = y3 +% t0 in
let t0 = t4 +% t4 in
let z3 = t0 *% z3 in
let x3 = x3 -% z3 in
let z3 = t0 *% t1 in
let z3 = z3 +% z3 in
let z3 = z3 +% z3 in
(x3, y3, z3)
/// Point conversion between affine, projective and bytes representation
let aff_point_load (b:BSeq.lbytes 64) : option aff_point =
let pk_x = BSeq.nat_from_bytes_be (sub b 0 32) in
let pk_y = BSeq.nat_from_bytes_be (sub b 32 32) in
let is_x_valid = pk_x < prime in
let is_y_valid = pk_y < prime in
let is_xy_on_curve =
if is_x_valid && is_y_valid then is_on_curve (pk_x, pk_y) else false in
if is_xy_on_curve then Some (pk_x, pk_y) else None
let load_point (b:BSeq.lbytes 64) : option proj_point =
match (aff_point_load b) with
| Some p -> Some (to_proj_point p)
| None -> None
let aff_point_store (p:aff_point) : BSeq.lbytes 64 =
let (px, py) = p in
let pxb = BSeq.nat_to_bytes_be 32 px in
let pxy = BSeq.nat_to_bytes_be 32 py in
concat #uint8 #32 #32 pxb pxy
let point_store (p:proj_point) : BSeq.lbytes 64 =
aff_point_store (to_aff_point p)
let recover_y (x:felem) (is_odd:bool) : option felem =
let y2 = x *% x *% x +% a_coeff *% x +% b_coeff in
let y = fsqrt y2 in
if y *% y <> y2 then None
else begin
let y = if is_fodd y <> is_odd then (prime - y) % prime else y in
Some y end
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.P256.PointOps.fst"
}
|
[
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"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": "Spec.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.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 |
s: Lib.ByteSequence.lbytes 33 -> FStar.Pervasives.Native.option Spec.P256.PointOps.aff_point
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Lib.ByteSequence.lbytes",
"Prims.op_Negation",
"Prims.op_BarBar",
"Prims.op_Equality",
"FStar.UInt8.t",
"FStar.UInt8.__uint_to_t",
"FStar.Pervasives.Native.None",
"Spec.P256.PointOps.aff_point",
"Prims.bool",
"Spec.P256.PointOps.recover_y",
"Spec.P256.PointOps.felem",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.Mktuple2",
"Prims.nat",
"FStar.Pervasives.Native.option",
"Prims.op_LessThan",
"Spec.P256.PointOps.prime",
"Prims.b2t",
"Prims.pow2",
"Prims.op_Multiply",
"Lib.Sequence.length",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.Sequence.sub",
"Lib.ByteSequence.nat_from_bytes_be",
"Lib.IntTypes.uint_t",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"FStar.UInt.size",
"Lib.IntTypes.v",
"Lib.Sequence.index",
"FStar.UInt8.v",
"Lib.RawIntTypes.u8_to_UInt8",
"Lib.Sequence.op_String_Access"
] |
[] | false | false | false | false | false |
let aff_point_decompress (s: BSeq.lbytes 33) : option aff_point =
|
let s0 = Lib.RawIntTypes.u8_to_UInt8 s.[ 0 ] in
if not (s0 = 0x02uy || s0 = 0x03uy)
then None
else
let x = BSeq.nat_from_bytes_be (sub s 1 32) in
let is_x_valid = x < prime in
let is_y_odd = s0 = 0x03uy in
if not is_x_valid
then None
else
match (recover_y x is_y_odd) with
| Some y -> Some (x, y)
| None -> None
| false |
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.felem2
|
val felem2 : s: Hacl.Impl.Curve25519.Fields.Core.field_spec -> Type0
|
let felem2 (s:field_spec) = lbuffer (limb s) (nlimb s +. nlimb s)
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 65,
"end_line": 65,
"start_col": 0,
"start_line": 65
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
unfold noextract
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
unfold noextract
let nwide (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 8ul
inline_for_extraction noextract
let felem (s:field_spec) = lbuffer (limb s) (nlimb s)
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
s: Hacl.Impl.Curve25519.Fields.Core.field_spec -> Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"Lib.Buffer.lbuffer",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Lib.IntTypes.op_Plus_Dot",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Curve25519.Fields.Core.nlimb"
] |
[] | false | false | false | true | true |
let felem2 (s: field_spec) =
|
lbuffer (limb s) (nlimb s +. nlimb s)
| false |
|
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.felem
|
val felem : s: Hacl.Impl.Curve25519.Fields.Core.field_spec -> Type0
|
let felem (s:field_spec) = lbuffer (limb s) (nlimb s)
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 53,
"end_line": 63,
"start_col": 0,
"start_line": 63
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
unfold noextract
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
unfold noextract
let nwide (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 8ul
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
s: Hacl.Impl.Curve25519.Fields.Core.field_spec -> Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"Lib.Buffer.lbuffer",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Hacl.Impl.Curve25519.Fields.Core.nlimb"
] |
[] | false | false | false | true | true |
let felem (s: field_spec) =
|
lbuffer (limb s) (nlimb s)
| false |
|
Hacl.Spec.K256.Field52.Definitions.Lemmas.fst
|
Hacl.Spec.K256.Field52.Definitions.Lemmas.lemma_pow2_260_mod_prime
|
val lemma_pow2_260_mod_prime: unit -> Lemma (pow2 260 % S.prime = 0x1000003D10)
|
val lemma_pow2_260_mod_prime: unit -> Lemma (pow2 260 % S.prime = 0x1000003D10)
|
let lemma_pow2_260_mod_prime () =
calc (==) {
pow2 260 % S.prime;
(==) { Math.Lemmas.pow2_plus 256 4 }
pow2 256 * pow2 4 % S.prime;
(==) { Math.Lemmas.lemma_mod_mul_distr_l (pow2 256) (pow2 4) S.prime }
(pow2 256 % S.prime) * pow2 4 % S.prime;
(==) { lemma_prime () }
0x1000003D1 * pow2 4 % S.prime;
(==) { assert_norm (0x1000003D1 * pow2 4 = 0x1000003D10) }
0x1000003D10 % S.prime;
(==) { Math.Lemmas.small_mod 0x1000003D10 S.prime }
0x1000003D10;
}
|
{
"file_name": "code/k256/Hacl.Spec.K256.Field52.Definitions.Lemmas.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 3,
"end_line": 89,
"start_col": 0,
"start_line": 76
}
|
module Hacl.Spec.K256.Field52.Definitions.Lemmas
open FStar.Mul
open Lib.IntTypes
open Hacl.Spec.K256.Field52.Definitions
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module S = Spec.K256
module ML = Hacl.Spec.K256.MathLemmas
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
val lemma_as_nat_mod2: x:felem5 ->
Lemma (let (x0,x1,x2,x3,x4) = x in as_nat5 x % 2 = v x0 % 2)
let lemma_as_nat_mod2 x =
let (x0,x1,x2,x3,x4) = x in
assert (as_nat5 x = v x0 + v x1 * pow52 + v x2 * pow104 + v x3 * pow156 + v x4 * pow208);
assert (as_nat5 x % 2 = (v x0 + v x1 * pow52 + v x2 * pow104 + v x3 * pow156 + v x4 * pow208) % 2);
ML.lemma_a_plus_b_pow2_mod2 (v x0 + v x1 * pow52 + v x2 * pow104 + v x3 * pow156) (v x4) 208;
ML.lemma_a_plus_b_pow2_mod2 (v x0 + v x1 * pow52 + v x2 * pow104) (v x3) 156;
ML.lemma_a_plus_b_pow2_mod2 (v x0 + v x1 * pow52) (v x2) 104;
ML.lemma_a_plus_b_pow2_mod2 (v x0) (v x1) 52;
assert (as_nat5 x % 2 = v x0 % 2)
val lemma_nat_from_bytes_be_mod2: f:LSeq.lseq uint8 32 ->
Lemma (BSeq.nat_from_bytes_be f % 2 = v (LSeq.index f 31) % 2)
let lemma_nat_from_bytes_be_mod2 f =
let x0 = LSeq.index f 31 in
BSeq.nat_from_intseq_be_slice_lemma f 31;
BSeq.nat_from_intseq_be_lemma0 (LSeq.slice f 31 32);
assert (BSeq.nat_from_intseq_be f == v x0 + pow2 8 * BSeq.nat_from_intseq_be (LSeq.slice f 0 31));
ML.lemma_a_plus_b_pow2_mod2 (v x0) (BSeq.nat_from_intseq_be (LSeq.slice f 0 31)) 8
val unfold_nat_from_uint64_four: b:LSeq.lseq uint64 4 ->
Lemma (BSeq.nat_from_intseq_be b ==
v (LSeq.index b 3) + v (LSeq.index b 2) * pow2 64 +
v (LSeq.index b 1) * pow2 128 + v (LSeq.index b 0) * pow2 192)
let unfold_nat_from_uint64_four b =
let b0 = v (LSeq.index b 0) in
let b1 = v (LSeq.index b 1) in
let b2 = v (LSeq.index b 2) in
let b3 = v (LSeq.index b 3) in
let res = BSeq.nat_from_intseq_be b in
BSeq.nat_from_intseq_be_slice_lemma b 3;
BSeq.nat_from_intseq_be_lemma0 (Seq.slice b 3 4);
assert (res == b3 + pow2 64 * (BSeq.nat_from_intseq_be (Seq.slice b 0 3)));
BSeq.nat_from_intseq_be_slice_lemma #U64 #SEC #3 (Seq.slice b 0 3) 2;
BSeq.nat_from_intseq_be_lemma0 (Seq.slice b 2 3);
assert (BSeq.nat_from_intseq_be (Seq.slice b 0 3) == b2 + pow2 64 * (BSeq.nat_from_intseq_be (Seq.slice b 0 2)));
BSeq.nat_from_intseq_be_slice_lemma #U64 #SEC #2 (Seq.slice b 0 2) 1;
BSeq.nat_from_intseq_be_lemma0 (Seq.slice b 1 2);
assert (BSeq.nat_from_intseq_be (Seq.slice b 0 2) == b1 + pow2 64 * (BSeq.nat_from_intseq_be (Seq.slice b 0 1)));
BSeq.nat_from_intseq_be_lemma0 (Seq.slice b 0 1);
assert (res == b3 + pow2 64 * (b2 + pow2 64 * (b1 + pow2 64 * b0)));
ML.lemma_as_nat64_horner b3 b2 b1 b0
val lemma_prime : unit -> Lemma (pow2 256 % S.prime = 0x1000003D1)
let lemma_prime () = ()
val lemma_pow2_256_minus_prime : unit -> Lemma (pow2 256 - S.prime = 0x1000003D1)
let lemma_pow2_256_minus_prime () = ()
|
{
"checked_file": "/",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.K256.MathLemmas.fst.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.Definitions.Lemmas.fst"
}
|
[
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.MathLemmas",
"short_module": "ML"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
_: Prims.unit
-> FStar.Pervasives.Lemma (ensures Prims.pow2 260 % Spec.K256.PointOps.prime = 0x1000003D10)
|
FStar.Pervasives.Lemma
|
[
"lemma"
] |
[] |
[
"Prims.unit",
"FStar.Calc.calc_finish",
"Prims.int",
"Prims.eq2",
"Prims.op_Modulus",
"Prims.pow2",
"Spec.K256.PointOps.prime",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"FStar.Calc.calc_step",
"FStar.Mul.op_Star",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"FStar.Math.Lemmas.pow2_plus",
"Prims.squash",
"FStar.Math.Lemmas.lemma_mod_mul_distr_l",
"Hacl.Spec.K256.Field52.Definitions.Lemmas.lemma_prime",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Math.Lemmas.small_mod"
] |
[] | false | false | true | false | false |
let lemma_pow2_260_mod_prime () =
|
calc ( == ) {
pow2 260 % S.prime;
( == ) { Math.Lemmas.pow2_plus 256 4 }
pow2 256 * pow2 4 % S.prime;
( == ) { Math.Lemmas.lemma_mod_mul_distr_l (pow2 256) (pow2 4) S.prime }
(pow2 256 % S.prime) * pow2 4 % S.prime;
( == ) { lemma_prime () }
0x1000003D1 * pow2 4 % S.prime;
( == ) { assert_norm (0x1000003D1 * pow2 4 = 0x1000003D10) }
0x1000003D10 % S.prime;
( == ) { Math.Lemmas.small_mod 0x1000003D10 S.prime }
0x1000003D10;
}
| false |
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.f51_felem_fits1
|
val f51_felem_fits1 : x: Lib.IntTypes.uint64 -> m: Hacl.Spec.Curve25519.Field51.Definition.scale64 -> Prims.bool
|
let f51_felem_fits1 = Hacl.Spec.Curve25519.Field51.Definition.felem_fits1
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 73,
"end_line": 92,
"start_col": 0,
"start_line": 92
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
unfold noextract
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
unfold noextract
let nwide (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 8ul
inline_for_extraction noextract
let felem (s:field_spec) = lbuffer (limb s) (nlimb s)
inline_for_extraction noextract
let felem2 (s:field_spec) = lbuffer (limb s) (nlimb s +. nlimb s)
inline_for_extraction noextract
let felem_wide (s:field_spec) = lbuffer (wide s) (nwide s)
inline_for_extraction noextract
let felem_wide2 (s:field_spec) = lbuffer (wide s) (nwide s +. nwide s)
/// Introduce representation for each field + helpers to be able to state pre & posts
/// ---------------------------------------------------------------------------------
noextract
let f51_as_felem (h:mem) (f:felem M51) : GTot Hacl.Spec.Curve25519.Field51.Definition.felem5 =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
(s0, s1, s2, s3, s4)
let f51_as_nat h e = Hacl.Spec.Curve25519.Field51.Definition.as_nat5 (f51_as_felem h e)
noextract
let f51_felem_fits (h:mem) (f:felem M51) (m:Hacl.Spec.Curve25519.Field51.Definition.scale64_5): Type0 =
Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 (f51_as_felem h f) m
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
x: Lib.IntTypes.uint64 -> m: Hacl.Spec.Curve25519.Field51.Definition.scale64 -> Prims.bool
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Hacl.Spec.Curve25519.Field51.Definition.felem_fits1"
] |
[] | false | false | false | true | false |
let f51_felem_fits1 =
|
Hacl.Spec.Curve25519.Field51.Definition.felem_fits1
| false |
|
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.f51_felem_fits
|
val f51_felem_fits (h: mem) (f: felem M51) (m: Hacl.Spec.Curve25519.Field51.Definition.scale64_5)
: Type0
|
val f51_felem_fits (h: mem) (f: felem M51) (m: Hacl.Spec.Curve25519.Field51.Definition.scale64_5)
: Type0
|
let f51_felem_fits (h:mem) (f:felem M51) (m:Hacl.Spec.Curve25519.Field51.Definition.scale64_5): Type0 =
Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 (f51_as_felem h f) m
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 74,
"end_line": 89,
"start_col": 0,
"start_line": 88
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
unfold noextract
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
unfold noextract
let nwide (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 8ul
inline_for_extraction noextract
let felem (s:field_spec) = lbuffer (limb s) (nlimb s)
inline_for_extraction noextract
let felem2 (s:field_spec) = lbuffer (limb s) (nlimb s +. nlimb s)
inline_for_extraction noextract
let felem_wide (s:field_spec) = lbuffer (wide s) (nwide s)
inline_for_extraction noextract
let felem_wide2 (s:field_spec) = lbuffer (wide s) (nwide s +. nwide s)
/// Introduce representation for each field + helpers to be able to state pre & posts
/// ---------------------------------------------------------------------------------
noextract
let f51_as_felem (h:mem) (f:felem M51) : GTot Hacl.Spec.Curve25519.Field51.Definition.felem5 =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
(s0, s1, s2, s3, s4)
let f51_as_nat h e = Hacl.Spec.Curve25519.Field51.Definition.as_nat5 (f51_as_felem h e)
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
h: FStar.Monotonic.HyperStack.mem ->
f: Hacl.Impl.Curve25519.Fields.Core.felem Hacl.Impl.Curve25519.Fields.Core.M51 ->
m: Hacl.Spec.Curve25519.Field51.Definition.scale64_5
-> Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Hacl.Impl.Curve25519.Fields.Core.M51",
"Hacl.Spec.Curve25519.Field51.Definition.scale64_5",
"Hacl.Spec.Curve25519.Field51.Definition.felem_fits5",
"Hacl.Impl.Curve25519.Fields.Core.f51_as_felem"
] |
[] | false | false | false | true | true |
let f51_felem_fits (h: mem) (f: felem M51) (m: Hacl.Spec.Curve25519.Field51.Definition.scale64_5)
: Type0 =
|
Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 (f51_as_felem h f) m
| false |
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.felem_wide2
|
val felem_wide2 : s: Hacl.Impl.Curve25519.Fields.Core.field_spec -> Type0
|
let felem_wide2 (s:field_spec) = lbuffer (wide s) (nwide s +. nwide s)
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 70,
"end_line": 69,
"start_col": 0,
"start_line": 69
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
unfold noextract
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
unfold noextract
let nwide (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 8ul
inline_for_extraction noextract
let felem (s:field_spec) = lbuffer (limb s) (nlimb s)
inline_for_extraction noextract
let felem2 (s:field_spec) = lbuffer (limb s) (nlimb s +. nlimb s)
inline_for_extraction noextract
let felem_wide (s:field_spec) = lbuffer (wide s) (nwide s)
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
s: Hacl.Impl.Curve25519.Fields.Core.field_spec -> Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"Lib.Buffer.lbuffer",
"Hacl.Impl.Curve25519.Fields.Core.wide",
"Lib.IntTypes.op_Plus_Dot",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Curve25519.Fields.Core.nwide"
] |
[] | false | false | false | true | true |
let felem_wide2 (s: field_spec) =
|
lbuffer (wide s) (nwide s +. nwide s)
| false |
|
LList2.fst
|
LList2.cell_struct_def
|
val cell_struct_def:struct_def cell_t
|
val cell_struct_def:struct_def cell_t
|
let cell_struct_def : struct_def cell_t =
let fields = FStar.Set.add "hd" (FStar.Set.singleton "tl") in
let field_desc : field_description_gen_t (field_t fields) = {
fd_nonempty = nonempty_set_nonempty_type "hd" fields;
fd_type = (fun (n: field_t fields) -> match n with "hd" -> scalar_t U32.t | "tl" -> scalar_t (ptr_gen cell_t));
fd_typedef = (fun (n: field_t fields) -> match n with "hd" -> scalar U32.t | "tl" -> scalar (ptr_gen cell_t));
}
in {
fields = fields;
field_desc = field_desc;
mk = (fun f -> Mkcell_t (f "hd") (f "tl"));
get = (fun x (f: field_t fields) -> match f with "hd" -> x.hd | "tl" -> x.tl);
get_mk = (fun _ _ -> ());
extensionality = (fun s1 s2 phi -> phi "hd"; phi "tl");
}
|
{
"file_name": "share/steel/examples/steelc/LList2.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
}
|
{
"end_col": 1,
"end_line": 32,
"start_col": 0,
"start_line": 18
}
|
module LList2
open Steel.ST.GenElim
open Steel.ST.C.Types
open Steel.ST.C.Types.Struct.Aux
open Steel.ST.C.Types.UserStruct // hides Struct
module U32 = FStar.UInt32
noeq
type cell_t = {
hd: scalar_t U32.t;
tl: scalar_t (ptr_gen cell_t);
}
noextract
inline_for_extraction
|
{
"checked_file": "/",
"dependencies": [
"Steel.ST.GenElim.fsti.checked",
"Steel.ST.C.Types.UserStruct.fsti.checked",
"Steel.ST.C.Types.Struct.Aux.fsti.checked",
"Steel.ST.C.Types.fst.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LList2.fst"
}
|
[
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.UserStruct // hides Struct",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.UserStruct",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.Struct.Aux",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 |
Steel.ST.C.Types.UserStruct.struct_def LList2.cell_t
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Steel.ST.C.Types.UserStruct.Mkstruct_def",
"LList2.cell_t",
"Steel.ST.C.Types.UserStruct.field_t",
"Steel.ST.C.Types.Struct.Aux.__proj__Mkfield_description_gen_t__item__fd_type",
"LList2.Mkcell_t",
"LList2.__proj__Mkcell_t__item__hd",
"LList2.__proj__Mkcell_t__item__tl",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Steel.ST.C.Types.Struct.Aux.field_description_gen_t",
"Steel.ST.C.Types.Struct.Aux.Mkfield_description_gen_t",
"Steel.ST.C.Types.UserStruct.nonempty_set_nonempty_type",
"Steel.ST.C.Types.Scalar.scalar_t",
"FStar.UInt32.t",
"Steel.ST.C.Types.Base.ptr_gen",
"Steel.ST.C.Types.Scalar.scalar",
"Steel.ST.C.Types.Base.typedef",
"FStar.Set.set",
"Prims.string",
"FStar.Set.add",
"FStar.Set.singleton"
] |
[] | false | false | false | true | false |
let cell_struct_def:struct_def cell_t =
|
let fields = FStar.Set.add "hd" (FStar.Set.singleton "tl") in
let field_desc:field_description_gen_t (field_t fields) =
{
fd_nonempty = nonempty_set_nonempty_type "hd" fields;
fd_type
=
(fun (n: field_t fields) ->
match n with
| "hd" -> scalar_t U32.t
| "tl" -> scalar_t (ptr_gen cell_t));
fd_typedef
=
(fun (n: field_t fields) ->
match n with
| "hd" -> scalar U32.t
| "tl" -> scalar (ptr_gen cell_t))
}
in
{
fields = fields;
field_desc = field_desc;
mk = (fun f -> Mkcell_t (f "hd") (f "tl"));
get
=
(fun x (f: field_t fields) ->
match f with
| "hd" -> x.hd
| "tl" -> x.tl);
get_mk = (fun _ _ -> ());
extensionality
=
(fun s1 s2 phi ->
phi "hd";
phi "tl")
}
| false |
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.f51_as_nat
|
val f51_as_nat : h: FStar.Monotonic.HyperStack.mem ->
e: Hacl.Impl.Curve25519.Fields.Core.felem Hacl.Impl.Curve25519.Fields.Core.M51
-> Prims.GTot Prims.nat
|
let f51_as_nat h e = Hacl.Spec.Curve25519.Field51.Definition.as_nat5 (f51_as_felem h e)
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 87,
"end_line": 85,
"start_col": 0,
"start_line": 85
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
unfold noextract
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
unfold noextract
let nwide (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 8ul
inline_for_extraction noextract
let felem (s:field_spec) = lbuffer (limb s) (nlimb s)
inline_for_extraction noextract
let felem2 (s:field_spec) = lbuffer (limb s) (nlimb s +. nlimb s)
inline_for_extraction noextract
let felem_wide (s:field_spec) = lbuffer (wide s) (nwide s)
inline_for_extraction noextract
let felem_wide2 (s:field_spec) = lbuffer (wide s) (nwide s +. nwide s)
/// Introduce representation for each field + helpers to be able to state pre & posts
/// ---------------------------------------------------------------------------------
noextract
let f51_as_felem (h:mem) (f:felem M51) : GTot Hacl.Spec.Curve25519.Field51.Definition.felem5 =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
(s0, s1, s2, s3, s4)
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
h: FStar.Monotonic.HyperStack.mem ->
e: Hacl.Impl.Curve25519.Fields.Core.felem Hacl.Impl.Curve25519.Fields.Core.M51
-> Prims.GTot Prims.nat
|
Prims.GTot
|
[
"sometrivial"
] |
[] |
[
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Hacl.Impl.Curve25519.Fields.Core.M51",
"Hacl.Spec.Curve25519.Field51.Definition.as_nat5",
"Hacl.Impl.Curve25519.Fields.Core.f51_as_felem",
"Prims.nat"
] |
[] | false | false | false | false | false |
let f51_as_nat h e =
|
Hacl.Spec.Curve25519.Field51.Definition.as_nat5 (f51_as_felem h e)
| false |
|
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.f51_mul_inv_t
|
val f51_mul_inv_t (h: mem) (f: felem M51) : GTot Type0
|
val f51_mul_inv_t (h: mem) (f: felem M51) : GTot Type0
|
let f51_mul_inv_t (h:mem) (f:felem M51) : GTot Type0 =
let f = f51_as_felem h f in
Hacl.Spec.Curve25519.Field51.mul_inv_t f
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 42,
"end_line": 97,
"start_col": 0,
"start_line": 95
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
unfold noextract
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
unfold noextract
let nwide (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 8ul
inline_for_extraction noextract
let felem (s:field_spec) = lbuffer (limb s) (nlimb s)
inline_for_extraction noextract
let felem2 (s:field_spec) = lbuffer (limb s) (nlimb s +. nlimb s)
inline_for_extraction noextract
let felem_wide (s:field_spec) = lbuffer (wide s) (nwide s)
inline_for_extraction noextract
let felem_wide2 (s:field_spec) = lbuffer (wide s) (nwide s +. nwide s)
/// Introduce representation for each field + helpers to be able to state pre & posts
/// ---------------------------------------------------------------------------------
noextract
let f51_as_felem (h:mem) (f:felem M51) : GTot Hacl.Spec.Curve25519.Field51.Definition.felem5 =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
(s0, s1, s2, s3, s4)
let f51_as_nat h e = Hacl.Spec.Curve25519.Field51.Definition.as_nat5 (f51_as_felem h e)
noextract
let f51_felem_fits (h:mem) (f:felem M51) (m:Hacl.Spec.Curve25519.Field51.Definition.scale64_5): Type0 =
Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 (f51_as_felem h f) m
noextract
let f51_felem_fits1 = Hacl.Spec.Curve25519.Field51.Definition.felem_fits1
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
h: FStar.Monotonic.HyperStack.mem ->
f: Hacl.Impl.Curve25519.Fields.Core.felem Hacl.Impl.Curve25519.Fields.Core.M51
-> Prims.GTot Type0
|
Prims.GTot
|
[
"sometrivial"
] |
[] |
[
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Hacl.Impl.Curve25519.Fields.Core.M51",
"Hacl.Spec.Curve25519.Field51.mul_inv_t",
"Hacl.Spec.Curve25519.Field51.Definition.felem5",
"Hacl.Impl.Curve25519.Fields.Core.f51_as_felem"
] |
[] | false | false | false | false | true |
let f51_mul_inv_t (h: mem) (f: felem M51) : GTot Type0 =
|
let f = f51_as_felem h f in
Hacl.Spec.Curve25519.Field51.mul_inv_t f
| false |
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.felem_wide
|
val felem_wide : s: Hacl.Impl.Curve25519.Fields.Core.field_spec -> Type0
|
let felem_wide (s:field_spec) = lbuffer (wide s) (nwide s)
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 58,
"end_line": 67,
"start_col": 0,
"start_line": 67
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
unfold noextract
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
unfold noextract
let nwide (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 8ul
inline_for_extraction noextract
let felem (s:field_spec) = lbuffer (limb s) (nlimb s)
inline_for_extraction noextract
let felem2 (s:field_spec) = lbuffer (limb s) (nlimb s +. nlimb s)
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
s: Hacl.Impl.Curve25519.Fields.Core.field_spec -> Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"Lib.Buffer.lbuffer",
"Hacl.Impl.Curve25519.Fields.Core.wide",
"Hacl.Impl.Curve25519.Fields.Core.nwide"
] |
[] | false | false | false | true | true |
let felem_wide (s: field_spec) =
|
lbuffer (wide s) (nwide s)
| false |
|
LList2.fst
|
LList2.llist_cons
|
val llist_cons
(p: ptr cell)
(a: U32.t)
(q: Ghost.erased (list U32.t))
(llist:
(ptr cell -> l: Ghost.erased (list U32.t) {List.Tot.length l < List.Tot.length (a :: q)}
-> Tot vprop))
: Tot vprop
|
val llist_cons
(p: ptr cell)
(a: U32.t)
(q: Ghost.erased (list U32.t))
(llist:
(ptr cell -> l: Ghost.erased (list U32.t) {List.Tot.length l < List.Tot.length (a :: q)}
-> Tot vprop))
: Tot vprop
|
let llist_cons (p: ptr cell) (a: U32.t) (q: Ghost.erased (list U32.t)) (llist: (ptr cell -> (l: Ghost.erased (list U32.t) { List.Tot.length l < List.Tot.length (a :: q) }) -> Tot vprop)) : Tot vprop =
exists_ (fun (p1: ref cell) -> exists_ (fun (p2: ptr cell) ->
pts_to p1 ({ hd = mk_scalar a; tl = mk_scalar p2 }) `star`
llist p2 q `star`
freeable p1 `star`
pure (p == p1)
))
|
{
"file_name": "share/steel/examples/steelc/LList2.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
}
|
{
"end_col": 4,
"end_line": 50,
"start_col": 0,
"start_line": 44
}
|
module LList2
open Steel.ST.GenElim
open Steel.ST.C.Types
open Steel.ST.C.Types.Struct.Aux
open Steel.ST.C.Types.UserStruct // hides Struct
module U32 = FStar.UInt32
noeq
type cell_t = {
hd: scalar_t U32.t;
tl: scalar_t (ptr_gen cell_t);
}
noextract
inline_for_extraction
[@@ norm_field_attr]
let cell_struct_def : struct_def cell_t =
let fields = FStar.Set.add "hd" (FStar.Set.singleton "tl") in
let field_desc : field_description_gen_t (field_t fields) = {
fd_nonempty = nonempty_set_nonempty_type "hd" fields;
fd_type = (fun (n: field_t fields) -> match n with "hd" -> scalar_t U32.t | "tl" -> scalar_t (ptr_gen cell_t));
fd_typedef = (fun (n: field_t fields) -> match n with "hd" -> scalar U32.t | "tl" -> scalar (ptr_gen cell_t));
}
in {
fields = fields;
field_desc = field_desc;
mk = (fun f -> Mkcell_t (f "hd") (f "tl"));
get = (fun x (f: field_t fields) -> match f with "hd" -> x.hd | "tl" -> x.tl);
get_mk = (fun _ _ -> ());
extensionality = (fun s1 s2 phi -> phi "hd"; phi "tl");
}
noextract
inline_for_extraction
[@@ norm_field_attr]
let cell = struct_typedef cell_struct_def
[@@__reduce__]
let llist_nil (p: ptr cell) : Tot vprop =
pure (p == null _)
|
{
"checked_file": "/",
"dependencies": [
"Steel.ST.GenElim.fsti.checked",
"Steel.ST.C.Types.UserStruct.fsti.checked",
"Steel.ST.C.Types.Struct.Aux.fsti.checked",
"Steel.ST.C.Types.fst.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LList2.fst"
}
|
[
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.UserStruct // hides Struct",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.UserStruct",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.Struct.Aux",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
p: Steel.ST.C.Types.Base.ptr LList2.cell ->
a: FStar.UInt32.t ->
q: FStar.Ghost.erased (Prims.list FStar.UInt32.t) ->
llist:
(
_: Steel.ST.C.Types.Base.ptr LList2.cell ->
l:
FStar.Ghost.erased (Prims.list FStar.UInt32.t)
{ FStar.List.Tot.Base.length (FStar.Ghost.reveal l) <
FStar.List.Tot.Base.length (a :: FStar.Ghost.reveal q) }
-> Steel.Effect.Common.vprop)
-> Steel.Effect.Common.vprop
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Steel.ST.C.Types.Base.ptr",
"LList2.cell_t",
"LList2.cell",
"FStar.UInt32.t",
"FStar.Ghost.erased",
"Prims.list",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.List.Tot.Base.length",
"FStar.Ghost.reveal",
"Prims.Cons",
"Steel.Effect.Common.vprop",
"Steel.ST.Util.exists_",
"Steel.ST.C.Types.Base.ref",
"Steel.Effect.Common.star",
"Steel.ST.C.Types.Base.pts_to",
"FStar.Ghost.hide",
"LList2.Mkcell_t",
"Steel.ST.C.Types.Scalar.mk_scalar",
"Steel.ST.C.Types.Base.ptr_gen",
"Steel.ST.C.Types.Base.freeable",
"Steel.ST.Util.pure",
"Prims.eq2"
] |
[] | false | false | false | false | false |
let llist_cons
(p: ptr cell)
(a: U32.t)
(q: Ghost.erased (list U32.t))
(llist:
(ptr cell -> l: Ghost.erased (list U32.t) {List.Tot.length l < List.Tot.length (a :: q)}
-> Tot vprop))
: Tot vprop =
|
exists_ (fun (p1: ref cell) ->
exists_ (fun (p2: ptr cell) ->
(((pts_to p1 ({ hd = mk_scalar a; tl = mk_scalar p2 })) `star` (llist p2 q))
`star`
(freeable p1))
`star`
(pure (p == p1))))
| false |
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.fadd_t
|
val fadd_t : s: Hacl.Impl.Curve25519.Fields.Core.field_spec -> p: Type0 -> Type0
|
let fadd_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint f1 f2 \/ f1 == f2) /\
fadd_fsub_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fadd_post h1 out /\
feval h1 out == P.fadd (feval h0 f1) (feval h0 f2))
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 57,
"end_line": 149,
"start_col": 0,
"start_line": 135
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
unfold noextract
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
unfold noextract
let nwide (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 8ul
inline_for_extraction noextract
let felem (s:field_spec) = lbuffer (limb s) (nlimb s)
inline_for_extraction noextract
let felem2 (s:field_spec) = lbuffer (limb s) (nlimb s +. nlimb s)
inline_for_extraction noextract
let felem_wide (s:field_spec) = lbuffer (wide s) (nwide s)
inline_for_extraction noextract
let felem_wide2 (s:field_spec) = lbuffer (wide s) (nwide s +. nwide s)
/// Introduce representation for each field + helpers to be able to state pre & posts
/// ---------------------------------------------------------------------------------
noextract
let f51_as_felem (h:mem) (f:felem M51) : GTot Hacl.Spec.Curve25519.Field51.Definition.felem5 =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
(s0, s1, s2, s3, s4)
let f51_as_nat h e = Hacl.Spec.Curve25519.Field51.Definition.as_nat5 (f51_as_felem h e)
noextract
let f51_felem_fits (h:mem) (f:felem M51) (m:Hacl.Spec.Curve25519.Field51.Definition.scale64_5): Type0 =
Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 (f51_as_felem h f) m
noextract
let f51_felem_fits1 = Hacl.Spec.Curve25519.Field51.Definition.felem_fits1
noextract
let f51_mul_inv_t (h:mem) (f:felem M51) : GTot Type0 =
let f = f51_as_felem h f in
Hacl.Spec.Curve25519.Field51.mul_inv_t f
noextract
let f64_as_nat (h:mem) (e: felem M64) : GTot nat =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
Hacl.Spec.Curve25519.Field64.Definition.as_nat4 (s0, s1, s2, s3)
noextract
let as_nat (#s:field_spec) (h:mem) (e:felem s): GTot nat =
match s with
| M51 -> f51_as_nat h e
| M64 -> f64_as_nat h e
noextract
let feval (#s:field_spec) (h:mem) (e:felem s): GTot P.elem =
(as_nat h e) % P.prime
/// Start of core combinators
/// -------------------------
let fadd_fsub_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:felem s): Type0 =
match s with
| M51 ->
f51_felem_fits h f1 (1, 2, 1, 1, 1) /\
f51_felem_fits h f2 (1, 2, 1, 1, 1)
| M64 -> True
let fadd_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (2, 4, 2, 2, 2)
| M64 -> True
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
s: Hacl.Impl.Curve25519.Fields.Core.field_spec -> p: Type0 -> Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Prims.l_or",
"Lib.Buffer.disjoint",
"Prims.eq2",
"Hacl.Impl.Curve25519.Fields.Core.fadd_fsub_pre",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Hacl.Impl.Curve25519.Fields.Core.fadd_post",
"Spec.Curve25519.elem",
"Hacl.Impl.Curve25519.Fields.Core.feval",
"Spec.Curve25519.fadd"
] |
[] | false | false | false | true | true |
let fadd_t (s: field_spec) (p: Type0) =
|
out: felem s -> f1: felem s -> f2: felem s
-> Stack unit
(requires
fun h ->
p /\ live h out /\ live h f1 /\ live h f2 /\ (disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\ (disjoint f1 f2 \/ f1 == f2) /\ fadd_fsub_pre h f1 f2)
(ensures
fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fadd_post h1 out /\
feval h1 out == P.fadd (feval h0 f1) (feval h0 f2))
| false |
|
LList2.fst
|
LList2.llist
|
val llist (p: ptr cell) (l: Ghost.erased (list U32.t)) : Tot vprop (decreases (List.Tot.length l))
|
val llist (p: ptr cell) (l: Ghost.erased (list U32.t)) : Tot vprop (decreases (List.Tot.length l))
|
let rec llist (p: ptr cell) (l: Ghost.erased (list U32.t)) : Tot vprop (decreases (List.Tot.length l)) =
match Ghost.reveal l with
| [] -> llist_nil p
| a :: q -> llist_cons p a q llist
|
{
"file_name": "share/steel/examples/steelc/LList2.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
}
|
{
"end_col": 36,
"end_line": 55,
"start_col": 0,
"start_line": 52
}
|
module LList2
open Steel.ST.GenElim
open Steel.ST.C.Types
open Steel.ST.C.Types.Struct.Aux
open Steel.ST.C.Types.UserStruct // hides Struct
module U32 = FStar.UInt32
noeq
type cell_t = {
hd: scalar_t U32.t;
tl: scalar_t (ptr_gen cell_t);
}
noextract
inline_for_extraction
[@@ norm_field_attr]
let cell_struct_def : struct_def cell_t =
let fields = FStar.Set.add "hd" (FStar.Set.singleton "tl") in
let field_desc : field_description_gen_t (field_t fields) = {
fd_nonempty = nonempty_set_nonempty_type "hd" fields;
fd_type = (fun (n: field_t fields) -> match n with "hd" -> scalar_t U32.t | "tl" -> scalar_t (ptr_gen cell_t));
fd_typedef = (fun (n: field_t fields) -> match n with "hd" -> scalar U32.t | "tl" -> scalar (ptr_gen cell_t));
}
in {
fields = fields;
field_desc = field_desc;
mk = (fun f -> Mkcell_t (f "hd") (f "tl"));
get = (fun x (f: field_t fields) -> match f with "hd" -> x.hd | "tl" -> x.tl);
get_mk = (fun _ _ -> ());
extensionality = (fun s1 s2 phi -> phi "hd"; phi "tl");
}
noextract
inline_for_extraction
[@@ norm_field_attr]
let cell = struct_typedef cell_struct_def
[@@__reduce__]
let llist_nil (p: ptr cell) : Tot vprop =
pure (p == null _)
[@@__reduce__]
let llist_cons (p: ptr cell) (a: U32.t) (q: Ghost.erased (list U32.t)) (llist: (ptr cell -> (l: Ghost.erased (list U32.t) { List.Tot.length l < List.Tot.length (a :: q) }) -> Tot vprop)) : Tot vprop =
exists_ (fun (p1: ref cell) -> exists_ (fun (p2: ptr cell) ->
pts_to p1 ({ hd = mk_scalar a; tl = mk_scalar p2 }) `star`
llist p2 q `star`
freeable p1 `star`
pure (p == p1)
))
|
{
"checked_file": "/",
"dependencies": [
"Steel.ST.GenElim.fsti.checked",
"Steel.ST.C.Types.UserStruct.fsti.checked",
"Steel.ST.C.Types.Struct.Aux.fsti.checked",
"Steel.ST.C.Types.fst.checked",
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LList2.fst"
}
|
[
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.UserStruct // hides Struct",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.UserStruct",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types.Struct.Aux",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.C.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.GenElim",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
p: Steel.ST.C.Types.Base.ptr LList2.cell -> l: FStar.Ghost.erased (Prims.list FStar.UInt32.t)
-> Prims.Tot Steel.Effect.Common.vprop
|
Prims.Tot
|
[
"total",
""
] |
[] |
[
"Steel.ST.C.Types.Base.ptr",
"LList2.cell_t",
"LList2.cell",
"FStar.Ghost.erased",
"Prims.list",
"FStar.UInt32.t",
"FStar.Ghost.reveal",
"LList2.llist_nil",
"LList2.llist_cons",
"FStar.Ghost.hide",
"LList2.llist",
"Steel.Effect.Common.vprop"
] |
[
"recursion"
] | false | false | false | true | false |
let rec llist (p: ptr cell) (l: Ghost.erased (list U32.t))
: Tot vprop (decreases (List.Tot.length l)) =
|
match Ghost.reveal l with
| [] -> llist_nil p
| a :: q -> llist_cons p a q llist
| false |
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.fsub_t
|
val fsub_t : s: Hacl.Impl.Curve25519.Fields.Core.field_spec -> p: Type0 -> Type0
|
let fsub_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint f1 f2 \/ f1 == f2) /\
fadd_fsub_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fsub_post h1 out /\
feval h1 out == P.fsub (feval h0 f1) (feval h0 f2))
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 57,
"end_line": 173,
"start_col": 0,
"start_line": 159
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
unfold noextract
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
unfold noextract
let nwide (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 8ul
inline_for_extraction noextract
let felem (s:field_spec) = lbuffer (limb s) (nlimb s)
inline_for_extraction noextract
let felem2 (s:field_spec) = lbuffer (limb s) (nlimb s +. nlimb s)
inline_for_extraction noextract
let felem_wide (s:field_spec) = lbuffer (wide s) (nwide s)
inline_for_extraction noextract
let felem_wide2 (s:field_spec) = lbuffer (wide s) (nwide s +. nwide s)
/// Introduce representation for each field + helpers to be able to state pre & posts
/// ---------------------------------------------------------------------------------
noextract
let f51_as_felem (h:mem) (f:felem M51) : GTot Hacl.Spec.Curve25519.Field51.Definition.felem5 =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
(s0, s1, s2, s3, s4)
let f51_as_nat h e = Hacl.Spec.Curve25519.Field51.Definition.as_nat5 (f51_as_felem h e)
noextract
let f51_felem_fits (h:mem) (f:felem M51) (m:Hacl.Spec.Curve25519.Field51.Definition.scale64_5): Type0 =
Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 (f51_as_felem h f) m
noextract
let f51_felem_fits1 = Hacl.Spec.Curve25519.Field51.Definition.felem_fits1
noextract
let f51_mul_inv_t (h:mem) (f:felem M51) : GTot Type0 =
let f = f51_as_felem h f in
Hacl.Spec.Curve25519.Field51.mul_inv_t f
noextract
let f64_as_nat (h:mem) (e: felem M64) : GTot nat =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
Hacl.Spec.Curve25519.Field64.Definition.as_nat4 (s0, s1, s2, s3)
noextract
let as_nat (#s:field_spec) (h:mem) (e:felem s): GTot nat =
match s with
| M51 -> f51_as_nat h e
| M64 -> f64_as_nat h e
noextract
let feval (#s:field_spec) (h:mem) (e:felem s): GTot P.elem =
(as_nat h e) % P.prime
/// Start of core combinators
/// -------------------------
let fadd_fsub_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:felem s): Type0 =
match s with
| M51 ->
f51_felem_fits h f1 (1, 2, 1, 1, 1) /\
f51_felem_fits h f2 (1, 2, 1, 1, 1)
| M64 -> True
let fadd_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (2, 4, 2, 2, 2)
| M64 -> True
inline_for_extraction
let fadd_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint f1 f2 \/ f1 == f2) /\
fadd_fsub_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fadd_post h1 out /\
feval h1 out == P.fadd (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize]
val fadd: #s:field_spec -> fadd_t s True
let fsub_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (9, 10, 9, 9, 9)
| M64 -> True
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
s: Hacl.Impl.Curve25519.Fields.Core.field_spec -> p: Type0 -> Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Prims.l_or",
"Lib.Buffer.disjoint",
"Prims.eq2",
"Hacl.Impl.Curve25519.Fields.Core.fadd_fsub_pre",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Hacl.Impl.Curve25519.Fields.Core.fsub_post",
"Spec.Curve25519.elem",
"Hacl.Impl.Curve25519.Fields.Core.feval",
"Spec.Curve25519.fsub"
] |
[] | false | false | false | true | true |
let fsub_t (s: field_spec) (p: Type0) =
|
out: felem s -> f1: felem s -> f2: felem s
-> Stack unit
(requires
fun h ->
p /\ live h out /\ live h f1 /\ live h f2 /\ (disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\ (disjoint f1 f2 \/ f1 == f2) /\ fadd_fsub_pre h f1 f2)
(ensures
fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fsub_post h1 out /\
feval h1 out == P.fsub (feval h0 f1) (feval h0 f2))
| false |
|
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.fmul_t
|
val fmul_t : s: Hacl.Impl.Curve25519.Fields.Core.field_spec -> p: Type0 -> Type0
|
let fmul_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> tmp:felem_wide2 s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\ live h tmp /\
fmul_disjoint out f1 f2 tmp /\
fmul_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out |+| loc tmp) h0 h1 /\ state_inv_t h1 out /\
feval h1 out == P.fmul (feval h0 f1) (feval h0 f2))
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 57,
"end_line": 215,
"start_col": 0,
"start_line": 202
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
unfold noextract
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
unfold noextract
let nwide (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 8ul
inline_for_extraction noextract
let felem (s:field_spec) = lbuffer (limb s) (nlimb s)
inline_for_extraction noextract
let felem2 (s:field_spec) = lbuffer (limb s) (nlimb s +. nlimb s)
inline_for_extraction noextract
let felem_wide (s:field_spec) = lbuffer (wide s) (nwide s)
inline_for_extraction noextract
let felem_wide2 (s:field_spec) = lbuffer (wide s) (nwide s +. nwide s)
/// Introduce representation for each field + helpers to be able to state pre & posts
/// ---------------------------------------------------------------------------------
noextract
let f51_as_felem (h:mem) (f:felem M51) : GTot Hacl.Spec.Curve25519.Field51.Definition.felem5 =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
(s0, s1, s2, s3, s4)
let f51_as_nat h e = Hacl.Spec.Curve25519.Field51.Definition.as_nat5 (f51_as_felem h e)
noextract
let f51_felem_fits (h:mem) (f:felem M51) (m:Hacl.Spec.Curve25519.Field51.Definition.scale64_5): Type0 =
Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 (f51_as_felem h f) m
noextract
let f51_felem_fits1 = Hacl.Spec.Curve25519.Field51.Definition.felem_fits1
noextract
let f51_mul_inv_t (h:mem) (f:felem M51) : GTot Type0 =
let f = f51_as_felem h f in
Hacl.Spec.Curve25519.Field51.mul_inv_t f
noextract
let f64_as_nat (h:mem) (e: felem M64) : GTot nat =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
Hacl.Spec.Curve25519.Field64.Definition.as_nat4 (s0, s1, s2, s3)
noextract
let as_nat (#s:field_spec) (h:mem) (e:felem s): GTot nat =
match s with
| M51 -> f51_as_nat h e
| M64 -> f64_as_nat h e
noextract
let feval (#s:field_spec) (h:mem) (e:felem s): GTot P.elem =
(as_nat h e) % P.prime
/// Start of core combinators
/// -------------------------
let fadd_fsub_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:felem s): Type0 =
match s with
| M51 ->
f51_felem_fits h f1 (1, 2, 1, 1, 1) /\
f51_felem_fits h f2 (1, 2, 1, 1, 1)
| M64 -> True
let fadd_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (2, 4, 2, 2, 2)
| M64 -> True
inline_for_extraction
let fadd_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint f1 f2 \/ f1 == f2) /\
fadd_fsub_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fadd_post h1 out /\
feval h1 out == P.fadd (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize]
val fadd: #s:field_spec -> fadd_t s True
let fsub_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (9, 10, 9, 9, 9)
| M64 -> True
inline_for_extraction
let fsub_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint f1 f2 \/ f1 == f2) /\
fadd_fsub_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fsub_post h1 out /\
feval h1 out == P.fsub (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize ]
val fsub: #s:field_spec -> fsub_t s True
let fmul_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:felem s): Type0 =
match s with
| M51 ->
f51_felem_fits h f1 (9, 10, 9, 9, 9) /\
f51_felem_fits h f2 (9, 10, 9, 9, 9)
| M64 -> True
let fmul_disjoint (#s:field_spec) (out f1 f2:felem s) (tmp:felem_wide2 s): Type0 =
match s with
| M51 -> True
| M64 ->
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint out tmp \/ out == tmp) /\
(disjoint f1 f2 \/ f1 == f2) /\
disjoint f1 tmp /\
disjoint f2 tmp
let state_inv_t (#s:field_spec) (h:mem) (f:felem s): Type0 =
match s with
| M51 -> f51_mul_inv_t h f
| M64 -> True
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
s: Hacl.Impl.Curve25519.Fields.Core.field_spec -> p: Type0 -> Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Hacl.Impl.Curve25519.Fields.Core.felem_wide2",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Hacl.Impl.Curve25519.Fields.Core.wide",
"Hacl.Impl.Curve25519.Fields.Core.fmul_disjoint",
"Hacl.Impl.Curve25519.Fields.Core.fmul_pre",
"Lib.Buffer.modifies",
"Lib.Buffer.op_Bar_Plus_Bar",
"Lib.Buffer.loc",
"Hacl.Impl.Curve25519.Fields.Core.state_inv_t",
"Prims.eq2",
"Spec.Curve25519.elem",
"Hacl.Impl.Curve25519.Fields.Core.feval",
"Spec.Curve25519.fmul"
] |
[] | false | false | false | true | true |
let fmul_t (s: field_spec) (p: Type0) =
|
out: felem s -> f1: felem s -> f2: felem s -> tmp: felem_wide2 s
-> Stack unit
(requires
fun h ->
p /\ live h out /\ live h f1 /\ live h f2 /\ live h tmp /\ fmul_disjoint out f1 f2 tmp /\
fmul_pre h f1 f2)
(ensures
fun h0 _ h1 ->
modifies (loc out |+| loc tmp) h0 h1 /\ state_inv_t h1 out /\
feval h1 out == P.fmul (feval h0 f1) (feval h0 f2))
| false |
|
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.nlimb
|
val nlimb (s: field_spec) : size_t
|
val nlimb (s: field_spec) : size_t
|
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 14,
"end_line": 42,
"start_col": 0,
"start_line": 39
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
s: Hacl.Impl.Curve25519.Fields.Core.field_spec -> Lib.IntTypes.size_t
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.size_t"
] |
[] | false | false | false | true | false |
let nlimb (s: field_spec) : size_t =
|
match s with
| M51 -> 5ul
| M64 -> 4ul
| false |
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.limb
|
val limb : s: Hacl.Impl.Curve25519.Fields.Core.field_spec -> Type0
|
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 17,
"end_line": 30,
"start_col": 0,
"start_line": 27
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
s: Hacl.Impl.Curve25519.Fields.Core.field_spec -> Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"Lib.IntTypes.uint64"
] |
[] | false | false | false | true | true |
let limb (s: field_spec) =
|
match s with
| M51 -> uint64
| M64 -> uint64
| false |
|
Steel.ST.GhostPCMReference.fst
|
Steel.ST.GhostPCMReference.alloc
|
val alloc (#o:inames)
(#a:Type)
(#pcm:pcm a)
(x:a)
: STGhost (ref a pcm) o
emp
(fun r -> pts_to r x)
(requires pcm.refine x)
(ensures fun _ -> True)
|
val alloc (#o:inames)
(#a:Type)
(#pcm:pcm a)
(x:a)
: STGhost (ref a pcm) o
emp
(fun r -> pts_to r x)
(requires pcm.refine x)
(ensures fun _ -> True)
|
let alloc (#o:inames)
(#a:Type)
(#pcm:pcm a)
(x:a)
: STGhost (ref a pcm) o
emp
(fun r -> pts_to r x)
(requires pcm.refine x)
(ensures fun _ -> True)
= coerce_ghost (fun _ -> G.alloc (raise_val x))
|
{
"file_name": "lib/steel/Steel.ST.GhostPCMReference.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
}
|
{
"end_col": 49,
"end_line": 42,
"start_col": 0,
"start_line": 33
}
|
(*
Copyright 2021 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.ST.GhostPCMReference
open FStar.Ghost
open Steel.ST.Util
open Steel.ST.Coercions
open FStar.PCM
open FStar.Universe
module UP = FStar.Universe.PCM
module G = Steel.GhostPCMReference
let ref (a:Type u#0) (p:pcm a) : Type u#0 =
G.ref (raise_t u#0 u#1 a) (UP.raise p)
/// pts_to is fixed to ref contents in u#0
let pts_to (#a:Type u#0) (#pcm:pcm a) (r:ref a pcm) ([@@@smt_fallback] v:a)
= G.pts_to #(raise_t a) #(UP.raise pcm) r (raise_val v)
|
{
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.ST.Coercions.fsti.checked",
"Steel.GhostPCMReference.fsti.checked",
"prims.fst.checked",
"FStar.Universe.PCM.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GhostPCMReference.fst"
}
|
[
{
"abbrev": true,
"full_module": "Steel.GhostPCMReference",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Universe.PCM",
"short_module": "UP"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Coercions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
x: a -> Steel.ST.Effect.Ghost.STGhost (Steel.ST.GhostPCMReference.ref a pcm)
|
Steel.ST.Effect.Ghost.STGhost
|
[] |
[] |
[
"Steel.Memory.inames",
"FStar.PCM.pcm",
"Steel.ST.Coercions.coerce_ghost",
"Steel.GhostPCMReference.ref",
"FStar.Universe.raise_t",
"FStar.Universe.PCM.raise",
"Steel.Effect.Common.emp",
"Steel.GhostPCMReference.pts_to",
"FStar.Universe.raise_val",
"Steel.Effect.Common.vprop",
"FStar.PCM.__proj__Mkpcm__item__refine",
"Prims.l_True",
"Prims.unit",
"Steel.GhostPCMReference.alloc",
"Steel.ST.GhostPCMReference.ref",
"Steel.ST.GhostPCMReference.pts_to"
] |
[] | false | true | false | false | false |
let alloc (#o: inames) (#a: Type) (#pcm: pcm a) (x: a)
: STGhost (ref a pcm)
o
emp
(fun r -> pts_to r x)
(requires pcm.refine x)
(ensures fun _ -> True) =
|
coerce_ghost (fun _ -> G.alloc (raise_val x))
| false |
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.fsqr_t
|
val fsqr_t : s: Hacl.Impl.Curve25519.Fields.Core.field_spec -> p: Type0 -> Type0
|
let fsqr_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> tmp:felem_wide s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h tmp /\
fsqr_disjoint out f1 tmp /\
fsqr_pre h f1)
(ensures fun h0 _ h1 ->
modifies (loc out |+| loc tmp) h0 h1 /\
state_inv_t h1 out /\
feval h1 out == P.fmul (feval h0 f1) (feval h0 f1))
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 57,
"end_line": 323,
"start_col": 0,
"start_line": 310
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
unfold noextract
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
unfold noextract
let nwide (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 8ul
inline_for_extraction noextract
let felem (s:field_spec) = lbuffer (limb s) (nlimb s)
inline_for_extraction noextract
let felem2 (s:field_spec) = lbuffer (limb s) (nlimb s +. nlimb s)
inline_for_extraction noextract
let felem_wide (s:field_spec) = lbuffer (wide s) (nwide s)
inline_for_extraction noextract
let felem_wide2 (s:field_spec) = lbuffer (wide s) (nwide s +. nwide s)
/// Introduce representation for each field + helpers to be able to state pre & posts
/// ---------------------------------------------------------------------------------
noextract
let f51_as_felem (h:mem) (f:felem M51) : GTot Hacl.Spec.Curve25519.Field51.Definition.felem5 =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
(s0, s1, s2, s3, s4)
let f51_as_nat h e = Hacl.Spec.Curve25519.Field51.Definition.as_nat5 (f51_as_felem h e)
noextract
let f51_felem_fits (h:mem) (f:felem M51) (m:Hacl.Spec.Curve25519.Field51.Definition.scale64_5): Type0 =
Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 (f51_as_felem h f) m
noextract
let f51_felem_fits1 = Hacl.Spec.Curve25519.Field51.Definition.felem_fits1
noextract
let f51_mul_inv_t (h:mem) (f:felem M51) : GTot Type0 =
let f = f51_as_felem h f in
Hacl.Spec.Curve25519.Field51.mul_inv_t f
noextract
let f64_as_nat (h:mem) (e: felem M64) : GTot nat =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
Hacl.Spec.Curve25519.Field64.Definition.as_nat4 (s0, s1, s2, s3)
noextract
let as_nat (#s:field_spec) (h:mem) (e:felem s): GTot nat =
match s with
| M51 -> f51_as_nat h e
| M64 -> f64_as_nat h e
noextract
let feval (#s:field_spec) (h:mem) (e:felem s): GTot P.elem =
(as_nat h e) % P.prime
/// Start of core combinators
/// -------------------------
let fadd_fsub_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:felem s): Type0 =
match s with
| M51 ->
f51_felem_fits h f1 (1, 2, 1, 1, 1) /\
f51_felem_fits h f2 (1, 2, 1, 1, 1)
| M64 -> True
let fadd_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (2, 4, 2, 2, 2)
| M64 -> True
inline_for_extraction
let fadd_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint f1 f2 \/ f1 == f2) /\
fadd_fsub_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fadd_post h1 out /\
feval h1 out == P.fadd (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize]
val fadd: #s:field_spec -> fadd_t s True
let fsub_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (9, 10, 9, 9, 9)
| M64 -> True
inline_for_extraction
let fsub_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint f1 f2 \/ f1 == f2) /\
fadd_fsub_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fsub_post h1 out /\
feval h1 out == P.fsub (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize ]
val fsub: #s:field_spec -> fsub_t s True
let fmul_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:felem s): Type0 =
match s with
| M51 ->
f51_felem_fits h f1 (9, 10, 9, 9, 9) /\
f51_felem_fits h f2 (9, 10, 9, 9, 9)
| M64 -> True
let fmul_disjoint (#s:field_spec) (out f1 f2:felem s) (tmp:felem_wide2 s): Type0 =
match s with
| M51 -> True
| M64 ->
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint out tmp \/ out == tmp) /\
(disjoint f1 f2 \/ f1 == f2) /\
disjoint f1 tmp /\
disjoint f2 tmp
let state_inv_t (#s:field_spec) (h:mem) (f:felem s): Type0 =
match s with
| M51 -> f51_mul_inv_t h f
| M64 -> True
inline_for_extraction
let fmul_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> tmp:felem_wide2 s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\ live h tmp /\
fmul_disjoint out f1 f2 tmp /\
fmul_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out |+| loc tmp) h0 h1 /\ state_inv_t h1 out /\
feval h1 out == P.fmul (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize ]
val fmul: #s:field_spec -> fmul_t s True
let fmul2_pre (#s:field_spec) (h:mem) (f1:felem2 s) (f2:felem2 s): Type0 =
match s with
| M51 ->
let f10 = gsub f1 0ul 5ul in
let f11 = gsub f1 5ul 5ul in
let f20 = gsub f2 0ul 5ul in
let f21 = gsub f2 5ul 5ul in
f51_felem_fits h f10 (9, 10, 9, 9, 9) /\
f51_felem_fits h f11 (9, 10, 9, 9, 9) /\
f51_felem_fits h f20 (9, 10, 9, 9, 9) /\
f51_felem_fits h f21 (9, 10, 9, 9, 9)
| M64 -> True
let fmul2_fsqr2_post (#s:field_spec) (h:mem) (out:felem2 s): Type0 =
match s with
| M51 ->
let out0 = gsub out 0ul 5ul in
let out1 = gsub out 5ul 5ul in
f51_mul_inv_t h out0 /\
f51_mul_inv_t h out1
| M64 -> True
inline_for_extraction
let fmul2_t (s:field_spec) (p: Type0) =
out:felem2 s
-> f1:felem2 s
-> f2:felem2 s
-> tmp:felem_wide2 s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\ live h tmp /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint out tmp) /\
(disjoint f1 f2 \/ f1 == f2) /\
disjoint f1 tmp /\
disjoint f2 tmp /\
fmul2_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out |+| loc tmp) h0 h1 /\ fmul2_fsqr2_post h1 out /\
(let out0 = gsub out 0ul (nlimb s) in
let out1 = gsub out (nlimb s) (nlimb s) in
let f10 = gsub f1 0ul (nlimb s) in
let f11 = gsub f1 (nlimb s) (nlimb s) in
let f20 = gsub f2 0ul (nlimb s) in
let f21 = gsub f2 (nlimb s) (nlimb s) in
feval h1 out0 == P.fmul (feval h0 f10) (feval h0 f20) /\
feval h1 out1 == P.fmul (feval h0 f11) (feval h0 f21)))
[@ Meta.Attribute.specialize ]
val fmul2: #s:field_spec -> fmul2_t s True
let fmul1_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:uint64): Type0 =
match s with
| M51 -> f51_felem_fits h f1 (9, 10, 9, 9, 9) /\ f51_felem_fits1 f2 1
| M64 -> v f2 < pow2 17
inline_for_extraction
let fmul1_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:uint64
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\
(disjoint out f1 \/ out == f1) /\
fmul1_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ state_inv_t h1 out /\
feval h1 out == P.fmul (feval h0 f1) (v f2))
// feval h1 out == (feval h0 f1 * v f2) % P.prime)
[@ Meta.Attribute.specialize ]
val fmul1: #s:field_spec -> fmul1_t s True
let fsqr_pre (#s:field_spec) (h:mem) (f:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h f (9, 10, 9, 9, 9)
| M64 -> True
let fsqr_disjoint (#s:field_spec) (out f1:felem s) (tmp:felem_wide s): Type0 =
match s with
| M51 -> True
| M64 ->
(disjoint out f1 \/ out == f1) /\
(disjoint out tmp \/ out == tmp) /\
disjoint tmp f1
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
s: Hacl.Impl.Curve25519.Fields.Core.field_spec -> p: Type0 -> Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Hacl.Impl.Curve25519.Fields.Core.felem_wide",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Hacl.Impl.Curve25519.Fields.Core.wide",
"Hacl.Impl.Curve25519.Fields.Core.fsqr_disjoint",
"Hacl.Impl.Curve25519.Fields.Core.fsqr_pre",
"Lib.Buffer.modifies",
"Lib.Buffer.op_Bar_Plus_Bar",
"Lib.Buffer.loc",
"Hacl.Impl.Curve25519.Fields.Core.state_inv_t",
"Prims.eq2",
"Spec.Curve25519.elem",
"Hacl.Impl.Curve25519.Fields.Core.feval",
"Spec.Curve25519.fmul"
] |
[] | false | false | false | true | true |
let fsqr_t (s: field_spec) (p: Type0) =
|
out: felem s -> f1: felem s -> tmp: felem_wide s
-> Stack unit
(requires
fun h ->
p /\ live h out /\ live h f1 /\ live h tmp /\ fsqr_disjoint out f1 tmp /\ fsqr_pre h f1)
(ensures
fun h0 _ h1 ->
modifies (loc out |+| loc tmp) h0 h1 /\ state_inv_t h1 out /\
feval h1 out == P.fmul (feval h0 f1) (feval h0 f1))
| false |
|
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.feval
|
val feval (#s: field_spec) (h: mem) (e: felem s) : GTot P.elem
|
val feval (#s: field_spec) (h: mem) (e: felem s) : GTot P.elem
|
let feval (#s:field_spec) (h:mem) (e:felem s): GTot P.elem =
(as_nat h e) % P.prime
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 24,
"end_line": 116,
"start_col": 0,
"start_line": 115
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
unfold noextract
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
unfold noextract
let nwide (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 8ul
inline_for_extraction noextract
let felem (s:field_spec) = lbuffer (limb s) (nlimb s)
inline_for_extraction noextract
let felem2 (s:field_spec) = lbuffer (limb s) (nlimb s +. nlimb s)
inline_for_extraction noextract
let felem_wide (s:field_spec) = lbuffer (wide s) (nwide s)
inline_for_extraction noextract
let felem_wide2 (s:field_spec) = lbuffer (wide s) (nwide s +. nwide s)
/// Introduce representation for each field + helpers to be able to state pre & posts
/// ---------------------------------------------------------------------------------
noextract
let f51_as_felem (h:mem) (f:felem M51) : GTot Hacl.Spec.Curve25519.Field51.Definition.felem5 =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
(s0, s1, s2, s3, s4)
let f51_as_nat h e = Hacl.Spec.Curve25519.Field51.Definition.as_nat5 (f51_as_felem h e)
noextract
let f51_felem_fits (h:mem) (f:felem M51) (m:Hacl.Spec.Curve25519.Field51.Definition.scale64_5): Type0 =
Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 (f51_as_felem h f) m
noextract
let f51_felem_fits1 = Hacl.Spec.Curve25519.Field51.Definition.felem_fits1
noextract
let f51_mul_inv_t (h:mem) (f:felem M51) : GTot Type0 =
let f = f51_as_felem h f in
Hacl.Spec.Curve25519.Field51.mul_inv_t f
noextract
let f64_as_nat (h:mem) (e: felem M64) : GTot nat =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
Hacl.Spec.Curve25519.Field64.Definition.as_nat4 (s0, s1, s2, s3)
noextract
let as_nat (#s:field_spec) (h:mem) (e:felem s): GTot nat =
match s with
| M51 -> f51_as_nat h e
| M64 -> f64_as_nat h e
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
h: FStar.Monotonic.HyperStack.mem -> e: Hacl.Impl.Curve25519.Fields.Core.felem s
-> Prims.GTot Spec.Curve25519.elem
|
Prims.GTot
|
[
"sometrivial"
] |
[] |
[
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Prims.op_Modulus",
"Hacl.Impl.Curve25519.Fields.Core.as_nat",
"Spec.Curve25519.prime",
"Spec.Curve25519.elem"
] |
[] | false | false | false | false | false |
let feval (#s: field_spec) (h: mem) (e: felem s) : GTot P.elem =
|
(as_nat h e) % P.prime
| false |
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.nwide
|
val nwide (s: field_spec) : size_t
|
val nwide (s: field_spec) : size_t
|
let nwide (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 8ul
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 14,
"end_line": 60,
"start_col": 0,
"start_line": 57
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
unfold noextract
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
s: Hacl.Impl.Curve25519.Fields.Core.field_spec -> Lib.IntTypes.size_t
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.size_t"
] |
[] | false | false | false | true | false |
let nwide (s: field_spec) : size_t =
|
match s with
| M51 -> 5ul
| M64 -> 8ul
| false |
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.add1_t
|
val add1_t : p: Type0 -> Type0
|
let add1_t (p: Type0) = out:felem M64 -> f1:felem M64 -> f2:uint64
-> Stack (Ghost.erased uint64)
(requires fun h ->
p /\
live h f1 /\ live h out /\
(disjoint out f1 \/ out == f1))
(ensures fun h0 c h1 ->
modifies (loc out) h0 h1 /\
as_nat h1 out + v c * pow2 256 == as_nat h0 f1 + v f2)
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 60,
"end_line": 392,
"start_col": 0,
"start_line": 384
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
unfold noextract
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
unfold noextract
let nwide (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 8ul
inline_for_extraction noextract
let felem (s:field_spec) = lbuffer (limb s) (nlimb s)
inline_for_extraction noextract
let felem2 (s:field_spec) = lbuffer (limb s) (nlimb s +. nlimb s)
inline_for_extraction noextract
let felem_wide (s:field_spec) = lbuffer (wide s) (nwide s)
inline_for_extraction noextract
let felem_wide2 (s:field_spec) = lbuffer (wide s) (nwide s +. nwide s)
/// Introduce representation for each field + helpers to be able to state pre & posts
/// ---------------------------------------------------------------------------------
noextract
let f51_as_felem (h:mem) (f:felem M51) : GTot Hacl.Spec.Curve25519.Field51.Definition.felem5 =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
(s0, s1, s2, s3, s4)
let f51_as_nat h e = Hacl.Spec.Curve25519.Field51.Definition.as_nat5 (f51_as_felem h e)
noextract
let f51_felem_fits (h:mem) (f:felem M51) (m:Hacl.Spec.Curve25519.Field51.Definition.scale64_5): Type0 =
Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 (f51_as_felem h f) m
noextract
let f51_felem_fits1 = Hacl.Spec.Curve25519.Field51.Definition.felem_fits1
noextract
let f51_mul_inv_t (h:mem) (f:felem M51) : GTot Type0 =
let f = f51_as_felem h f in
Hacl.Spec.Curve25519.Field51.mul_inv_t f
noextract
let f64_as_nat (h:mem) (e: felem M64) : GTot nat =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
Hacl.Spec.Curve25519.Field64.Definition.as_nat4 (s0, s1, s2, s3)
noextract
let as_nat (#s:field_spec) (h:mem) (e:felem s): GTot nat =
match s with
| M51 -> f51_as_nat h e
| M64 -> f64_as_nat h e
noextract
let feval (#s:field_spec) (h:mem) (e:felem s): GTot P.elem =
(as_nat h e) % P.prime
/// Start of core combinators
/// -------------------------
let fadd_fsub_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:felem s): Type0 =
match s with
| M51 ->
f51_felem_fits h f1 (1, 2, 1, 1, 1) /\
f51_felem_fits h f2 (1, 2, 1, 1, 1)
| M64 -> True
let fadd_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (2, 4, 2, 2, 2)
| M64 -> True
inline_for_extraction
let fadd_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint f1 f2 \/ f1 == f2) /\
fadd_fsub_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fadd_post h1 out /\
feval h1 out == P.fadd (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize]
val fadd: #s:field_spec -> fadd_t s True
let fsub_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (9, 10, 9, 9, 9)
| M64 -> True
inline_for_extraction
let fsub_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint f1 f2 \/ f1 == f2) /\
fadd_fsub_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fsub_post h1 out /\
feval h1 out == P.fsub (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize ]
val fsub: #s:field_spec -> fsub_t s True
let fmul_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:felem s): Type0 =
match s with
| M51 ->
f51_felem_fits h f1 (9, 10, 9, 9, 9) /\
f51_felem_fits h f2 (9, 10, 9, 9, 9)
| M64 -> True
let fmul_disjoint (#s:field_spec) (out f1 f2:felem s) (tmp:felem_wide2 s): Type0 =
match s with
| M51 -> True
| M64 ->
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint out tmp \/ out == tmp) /\
(disjoint f1 f2 \/ f1 == f2) /\
disjoint f1 tmp /\
disjoint f2 tmp
let state_inv_t (#s:field_spec) (h:mem) (f:felem s): Type0 =
match s with
| M51 -> f51_mul_inv_t h f
| M64 -> True
inline_for_extraction
let fmul_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> tmp:felem_wide2 s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\ live h tmp /\
fmul_disjoint out f1 f2 tmp /\
fmul_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out |+| loc tmp) h0 h1 /\ state_inv_t h1 out /\
feval h1 out == P.fmul (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize ]
val fmul: #s:field_spec -> fmul_t s True
let fmul2_pre (#s:field_spec) (h:mem) (f1:felem2 s) (f2:felem2 s): Type0 =
match s with
| M51 ->
let f10 = gsub f1 0ul 5ul in
let f11 = gsub f1 5ul 5ul in
let f20 = gsub f2 0ul 5ul in
let f21 = gsub f2 5ul 5ul in
f51_felem_fits h f10 (9, 10, 9, 9, 9) /\
f51_felem_fits h f11 (9, 10, 9, 9, 9) /\
f51_felem_fits h f20 (9, 10, 9, 9, 9) /\
f51_felem_fits h f21 (9, 10, 9, 9, 9)
| M64 -> True
let fmul2_fsqr2_post (#s:field_spec) (h:mem) (out:felem2 s): Type0 =
match s with
| M51 ->
let out0 = gsub out 0ul 5ul in
let out1 = gsub out 5ul 5ul in
f51_mul_inv_t h out0 /\
f51_mul_inv_t h out1
| M64 -> True
inline_for_extraction
let fmul2_t (s:field_spec) (p: Type0) =
out:felem2 s
-> f1:felem2 s
-> f2:felem2 s
-> tmp:felem_wide2 s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\ live h tmp /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint out tmp) /\
(disjoint f1 f2 \/ f1 == f2) /\
disjoint f1 tmp /\
disjoint f2 tmp /\
fmul2_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out |+| loc tmp) h0 h1 /\ fmul2_fsqr2_post h1 out /\
(let out0 = gsub out 0ul (nlimb s) in
let out1 = gsub out (nlimb s) (nlimb s) in
let f10 = gsub f1 0ul (nlimb s) in
let f11 = gsub f1 (nlimb s) (nlimb s) in
let f20 = gsub f2 0ul (nlimb s) in
let f21 = gsub f2 (nlimb s) (nlimb s) in
feval h1 out0 == P.fmul (feval h0 f10) (feval h0 f20) /\
feval h1 out1 == P.fmul (feval h0 f11) (feval h0 f21)))
[@ Meta.Attribute.specialize ]
val fmul2: #s:field_spec -> fmul2_t s True
let fmul1_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:uint64): Type0 =
match s with
| M51 -> f51_felem_fits h f1 (9, 10, 9, 9, 9) /\ f51_felem_fits1 f2 1
| M64 -> v f2 < pow2 17
inline_for_extraction
let fmul1_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:uint64
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\
(disjoint out f1 \/ out == f1) /\
fmul1_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ state_inv_t h1 out /\
feval h1 out == P.fmul (feval h0 f1) (v f2))
// feval h1 out == (feval h0 f1 * v f2) % P.prime)
[@ Meta.Attribute.specialize ]
val fmul1: #s:field_spec -> fmul1_t s True
let fsqr_pre (#s:field_spec) (h:mem) (f:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h f (9, 10, 9, 9, 9)
| M64 -> True
let fsqr_disjoint (#s:field_spec) (out f1:felem s) (tmp:felem_wide s): Type0 =
match s with
| M51 -> True
| M64 ->
(disjoint out f1 \/ out == f1) /\
(disjoint out tmp \/ out == tmp) /\
disjoint tmp f1
inline_for_extraction
let fsqr_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> tmp:felem_wide s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h tmp /\
fsqr_disjoint out f1 tmp /\
fsqr_pre h f1)
(ensures fun h0 _ h1 ->
modifies (loc out |+| loc tmp) h0 h1 /\
state_inv_t h1 out /\
feval h1 out == P.fmul (feval h0 f1) (feval h0 f1))
[@ Meta.Attribute.specialize ]
val fsqr: #s:field_spec -> fsqr_t s True
let fsqr2_pre (#s:field_spec) (h:mem) (f:felem2 s): Type0 =
match s with
| M51 ->
let f1 = gsub f 0ul 5ul in
let f2 = gsub f 5ul 5ul in
f51_felem_fits h f1 (9, 10, 9, 9, 9) /\
f51_felem_fits h f2 (9, 10, 9, 9, 9)
| M64 -> True
inline_for_extraction
let fsqr2_t (s:field_spec) (p: Type0) =
out:felem2 s
-> f:felem2 s
-> tmp:felem_wide2 s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f /\ live h tmp /\
(disjoint out f \/ out == f) /\
(disjoint out tmp) /\
disjoint tmp f /\
fsqr2_pre h f)
(ensures fun h0 _ h1 ->
modifies (loc out |+| loc tmp) h0 h1 /\ fmul2_fsqr2_post h1 out /\
(let out1 = gsub out 0ul (nlimb s) in
let out2 = gsub out (nlimb s) (nlimb s) in
let f1 = gsub f 0ul (nlimb s) in
let f2 = gsub f (nlimb s) (nlimb s) in
feval h1 out1 == P.fmul (feval h0 f1) (feval h0 f1) /\
feval h1 out2 == P.fmul (feval h0 f2) (feval h0 f2)))
[@ Meta.Attribute.specialize ]
val fsqr2: #s:field_spec -> fsqr2_t s True
inline_for_extraction
let cswap2_t (s:field_spec) (p: Type0) =
bit:uint64{v bit <= 1}
-> p1:felem2 s
-> p2:felem2 s
-> Stack unit
(requires fun h0 ->
p /\
live h0 p1 /\ live h0 p2 /\
(disjoint p1 p2 \/ p1 == p2))
(ensures fun h0 _ h1 ->
modifies (loc p1 |+| loc p2) h0 h1 /\
(v bit == 1 ==> as_seq h1 p1 == as_seq h0 p2 /\ as_seq h1 p2 == as_seq h0 p1) /\
(v bit == 0 ==> as_seq h1 p1 == as_seq h0 p1 /\ as_seq h1 p2 == as_seq h0 p2))
[@ Meta.Attribute.specialize ]
val cswap2: #s:field_spec -> cswap2_t s True
/// Field64-specific core operations
/// --------------------------------
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
p: Type0 -> Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Hacl.Impl.Curve25519.Fields.Core.M64",
"Lib.IntTypes.uint64",
"FStar.Ghost.erased",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Prims.l_or",
"Lib.Buffer.disjoint",
"Prims.eq2",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.int",
"Prims.op_Addition",
"Hacl.Impl.Curve25519.Fields.Core.as_nat",
"FStar.Mul.op_Star",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.Ghost.reveal",
"Prims.pow2"
] |
[] | false | false | false | true | true |
let add1_t (p: Type0) =
|
out: felem M64 -> f1: felem M64 -> f2: uint64
-> Stack (Ghost.erased uint64)
(requires fun h -> p /\ live h f1 /\ live h out /\ (disjoint out f1 \/ out == f1))
(ensures
fun h0 c h1 ->
modifies (loc out) h0 h1 /\ as_nat h1 out + v c * pow2 256 == as_nat h0 f1 + v f2)
| false |
|
Hacl.Impl.Ed25519.Field51.fst
|
Hacl.Impl.Ed25519.Field51.point
|
val point : Type0
|
let point = lbuffer uint64 20ul
|
{
"file_name": "code/ed25519/Hacl.Impl.Ed25519.Field51.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 31,
"end_line": 15,
"start_col": 0,
"start_line": 15
}
|
module Hacl.Impl.Ed25519.Field51
open FStar.HyperStack
open Lib.IntTypes
open Lib.Buffer
open FStar.Mul
module LSeq = Lib.Sequence
module P = Hacl.Impl.Curve25519.Field51
module S = Spec.Curve25519
|
{
"checked_file": "/",
"dependencies": [
"Spec.Ed25519.fst.checked",
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Ed25519.Field51.fst"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Field51",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Ed25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Ed25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t"
] |
[] | false | false | false | true | true |
let point =
|
lbuffer uint64 20ul
| false |
|
Hacl.Impl.Ed25519.Field51.fst
|
Hacl.Impl.Ed25519.Field51.felem
|
val felem : Type0
|
let felem = lbuffer uint64 5ul
|
{
"file_name": "code/ed25519/Hacl.Impl.Ed25519.Field51.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 30,
"end_line": 14,
"start_col": 0,
"start_line": 14
}
|
module Hacl.Impl.Ed25519.Field51
open FStar.HyperStack
open Lib.IntTypes
open Lib.Buffer
open FStar.Mul
module LSeq = Lib.Sequence
module P = Hacl.Impl.Curve25519.Field51
module S = Spec.Curve25519
|
{
"checked_file": "/",
"dependencies": [
"Spec.Ed25519.fst.checked",
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Ed25519.Field51.fst"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Field51",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Ed25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Ed25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t"
] |
[] | false | false | false | true | true |
let felem =
|
lbuffer uint64 5ul
| false |
|
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.wide
|
val wide : s: Hacl.Impl.Curve25519.Fields.Core.field_spec -> Type0
|
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 17,
"end_line": 48,
"start_col": 0,
"start_line": 45
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
s: Hacl.Impl.Curve25519.Fields.Core.field_spec -> Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"Lib.IntTypes.uint128",
"Lib.IntTypes.uint64"
] |
[] | false | false | false | true | true |
let wide (s: field_spec) =
|
match s with
| M51 -> uint128
| M64 -> uint64
| false |
|
Hacl.Impl.Ed25519.Field51.fst
|
Hacl.Impl.Ed25519.Field51.fevalh
|
val fevalh (h: mem) (f: felem) : GTot S.elem
|
val fevalh (h: mem) (f: felem) : GTot S.elem
|
let fevalh (h:mem) (f:felem) : GTot S.elem = P.fevalh h f
|
{
"file_name": "code/ed25519/Hacl.Impl.Ed25519.Field51.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 57,
"end_line": 19,
"start_col": 0,
"start_line": 19
}
|
module Hacl.Impl.Ed25519.Field51
open FStar.HyperStack
open Lib.IntTypes
open Lib.Buffer
open FStar.Mul
module LSeq = Lib.Sequence
module P = Hacl.Impl.Curve25519.Field51
module S = Spec.Curve25519
let felem = lbuffer uint64 5ul
let point = lbuffer uint64 20ul
let as_nat (h:mem) (f:felem) : GTot nat = P.as_nat h f
|
{
"checked_file": "/",
"dependencies": [
"Spec.Ed25519.fst.checked",
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Ed25519.Field51.fst"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Field51",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Ed25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Ed25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
h: FStar.Monotonic.HyperStack.mem -> f: Hacl.Impl.Ed25519.Field51.felem
-> Prims.GTot Spec.Curve25519.elem
|
Prims.GTot
|
[
"sometrivial"
] |
[] |
[
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Ed25519.Field51.felem",
"Hacl.Impl.Curve25519.Field51.fevalh",
"Spec.Curve25519.elem"
] |
[] | false | false | false | false | false |
let fevalh (h: mem) (f: felem) : GTot S.elem =
|
P.fevalh h f
| false |
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.wide_zero
|
val wide_zero (s: field_spec) : wide s
|
val wide_zero (s: field_spec) : wide s
|
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 16,
"end_line": 54,
"start_col": 0,
"start_line": 51
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
s: Hacl.Impl.Curve25519.Fields.Core.field_spec -> Hacl.Impl.Curve25519.Fields.Core.wide s
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"Lib.IntTypes.u128",
"Lib.IntTypes.u64",
"Hacl.Impl.Curve25519.Fields.Core.wide"
] |
[] | false | false | false | false | false |
let wide_zero (s: field_spec) : wide s =
|
match s with
| M51 -> u128 0
| M64 -> u64 0
| false |
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.limb_zero
|
val limb_zero (s: field_spec) : limb s
|
val limb_zero (s: field_spec) : limb s
|
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 16,
"end_line": 36,
"start_col": 0,
"start_line": 33
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
s: Hacl.Impl.Curve25519.Fields.Core.field_spec -> Hacl.Impl.Curve25519.Fields.Core.limb s
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"Lib.IntTypes.u64",
"Hacl.Impl.Curve25519.Fields.Core.limb"
] |
[] | false | false | false | false | false |
let limb_zero (s: field_spec) : limb s =
|
match s with
| M51 -> u64 0
| M64 -> u64 0
| false |
Steel.ST.GhostPCMReference.fst
|
Steel.ST.GhostPCMReference.upd_gen
|
val upd_gen (#o:inames)
(#a:Type)
(#p:pcm a)
(r:ref a p)
(x y:a)
(f:frame_preserving_upd p x y)
: STGhostT unit o
(pts_to r x)
(fun _ -> pts_to r y)
|
val upd_gen (#o:inames)
(#a:Type)
(#p:pcm a)
(r:ref a p)
(x y:a)
(f:frame_preserving_upd p x y)
: STGhostT unit o
(pts_to r x)
(fun _ -> pts_to r y)
|
let upd_gen (#o:inames)
(#a:Type)
(#p:pcm a)
(r:ref a p)
(x y:a)
(f:frame_preserving_upd p x y)
: STGhostT unit o
(pts_to r x)
(fun _ -> pts_to r y)
= coerce_ghost (fun _ -> G.upd_gen r (raise_val x) (raise_val y) (UP.raise_frame_preserving_upd f))
|
{
"file_name": "lib/steel/Steel.ST.GhostPCMReference.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
}
|
{
"end_col": 101,
"end_line": 80,
"start_col": 0,
"start_line": 71
}
|
(*
Copyright 2021 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.ST.GhostPCMReference
open FStar.Ghost
open Steel.ST.Util
open Steel.ST.Coercions
open FStar.PCM
open FStar.Universe
module UP = FStar.Universe.PCM
module G = Steel.GhostPCMReference
let ref (a:Type u#0) (p:pcm a) : Type u#0 =
G.ref (raise_t u#0 u#1 a) (UP.raise p)
/// pts_to is fixed to ref contents in u#0
let pts_to (#a:Type u#0) (#pcm:pcm a) (r:ref a pcm) ([@@@smt_fallback] v:a)
= G.pts_to #(raise_t a) #(UP.raise pcm) r (raise_val v)
/// Allocates a new reference, initially storing value [x].
let alloc (#o:inames)
(#a:Type)
(#pcm:pcm a)
(x:a)
: STGhost (ref a pcm) o
emp
(fun r -> pts_to r x)
(requires pcm.refine x)
(ensures fun _ -> True)
= coerce_ghost (fun _ -> G.alloc (raise_val x))
let read (#o:inames)
(#a:Type)
(#pcm:pcm a)
(#v0:a)
(r:ref a pcm)
: STGhost a o
(pts_to r v0)
(fun _ -> pts_to r v0)
(requires True)
(ensures fun v -> compatible pcm v0 v)
= let v = coerce_ghost (fun _ -> G.read r) in
downgrade_val v
let write (#o:inames)
(#a:Type)
(#pcm:pcm a)
(r:ref a pcm)
(v0:a)
(v1:a)
: STGhost unit o
(pts_to r v0)
(fun _ -> pts_to r v1)
(requires frame_preserving pcm v0 v1 /\ pcm.refine v1)
(ensures fun _ -> True)
= coerce_ghost (fun _ -> G.write r (raise_val v0) (raise_val v1))
|
{
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.ST.Coercions.fsti.checked",
"Steel.GhostPCMReference.fsti.checked",
"prims.fst.checked",
"FStar.Universe.PCM.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GhostPCMReference.fst"
}
|
[
{
"abbrev": true,
"full_module": "Steel.GhostPCMReference",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Universe.PCM",
"short_module": "UP"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Coercions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
r: Steel.ST.GhostPCMReference.ref a p -> x: a -> y: a -> f: FStar.PCM.frame_preserving_upd p x y
-> Steel.ST.Effect.Ghost.STGhostT Prims.unit
|
Steel.ST.Effect.Ghost.STGhostT
|
[] |
[] |
[
"Steel.Memory.inames",
"FStar.PCM.pcm",
"Steel.ST.GhostPCMReference.ref",
"FStar.PCM.frame_preserving_upd",
"Steel.ST.Coercions.coerce_ghost",
"Prims.unit",
"Steel.GhostPCMReference.pts_to",
"FStar.Universe.raise_t",
"FStar.Universe.PCM.raise",
"FStar.Universe.raise_val",
"Steel.Effect.Common.vprop",
"Prims.l_True",
"Steel.GhostPCMReference.upd_gen",
"FStar.Universe.PCM.raise_frame_preserving_upd",
"Steel.ST.GhostPCMReference.pts_to"
] |
[] | false | true | false | false | false |
let upd_gen
(#o: inames)
(#a: Type)
(#p: pcm a)
(r: ref a p)
(x y: a)
(f: frame_preserving_upd p x y)
: STGhostT unit o (pts_to r x) (fun _ -> pts_to r y) =
|
coerce_ghost (fun _ -> G.upd_gen r (raise_val x) (raise_val y) (UP.raise_frame_preserving_upd f))
| false |
Hacl.Impl.Ed25519.Field51.fst
|
Hacl.Impl.Ed25519.Field51.as_nat
|
val as_nat (h: mem) (f: felem) : GTot nat
|
val as_nat (h: mem) (f: felem) : GTot nat
|
let as_nat (h:mem) (f:felem) : GTot nat = P.as_nat h f
|
{
"file_name": "code/ed25519/Hacl.Impl.Ed25519.Field51.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 54,
"end_line": 17,
"start_col": 0,
"start_line": 17
}
|
module Hacl.Impl.Ed25519.Field51
open FStar.HyperStack
open Lib.IntTypes
open Lib.Buffer
open FStar.Mul
module LSeq = Lib.Sequence
module P = Hacl.Impl.Curve25519.Field51
module S = Spec.Curve25519
let felem = lbuffer uint64 5ul
let point = lbuffer uint64 20ul
|
{
"checked_file": "/",
"dependencies": [
"Spec.Ed25519.fst.checked",
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Ed25519.Field51.fst"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Field51",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Ed25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Ed25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
h: FStar.Monotonic.HyperStack.mem -> f: Hacl.Impl.Ed25519.Field51.felem -> Prims.GTot Prims.nat
|
Prims.GTot
|
[
"sometrivial"
] |
[] |
[
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Ed25519.Field51.felem",
"Hacl.Impl.Curve25519.Field51.as_nat",
"Prims.nat"
] |
[] | false | false | false | false | false |
let as_nat (h: mem) (f: felem) : GTot nat =
|
P.as_nat h f
| false |
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.fmul_pre
|
val fmul_pre (#s: field_spec) (h: mem) (f1 f2: felem s) : Type0
|
val fmul_pre (#s: field_spec) (h: mem) (f1 f2: felem s) : Type0
|
let fmul_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:felem s): Type0 =
match s with
| M51 ->
f51_felem_fits h f1 (9, 10, 9, 9, 9) /\
f51_felem_fits h f2 (9, 10, 9, 9, 9)
| M64 -> True
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 15,
"end_line": 182,
"start_col": 0,
"start_line": 177
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
unfold noextract
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
unfold noextract
let nwide (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 8ul
inline_for_extraction noextract
let felem (s:field_spec) = lbuffer (limb s) (nlimb s)
inline_for_extraction noextract
let felem2 (s:field_spec) = lbuffer (limb s) (nlimb s +. nlimb s)
inline_for_extraction noextract
let felem_wide (s:field_spec) = lbuffer (wide s) (nwide s)
inline_for_extraction noextract
let felem_wide2 (s:field_spec) = lbuffer (wide s) (nwide s +. nwide s)
/// Introduce representation for each field + helpers to be able to state pre & posts
/// ---------------------------------------------------------------------------------
noextract
let f51_as_felem (h:mem) (f:felem M51) : GTot Hacl.Spec.Curve25519.Field51.Definition.felem5 =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
(s0, s1, s2, s3, s4)
let f51_as_nat h e = Hacl.Spec.Curve25519.Field51.Definition.as_nat5 (f51_as_felem h e)
noextract
let f51_felem_fits (h:mem) (f:felem M51) (m:Hacl.Spec.Curve25519.Field51.Definition.scale64_5): Type0 =
Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 (f51_as_felem h f) m
noextract
let f51_felem_fits1 = Hacl.Spec.Curve25519.Field51.Definition.felem_fits1
noextract
let f51_mul_inv_t (h:mem) (f:felem M51) : GTot Type0 =
let f = f51_as_felem h f in
Hacl.Spec.Curve25519.Field51.mul_inv_t f
noextract
let f64_as_nat (h:mem) (e: felem M64) : GTot nat =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
Hacl.Spec.Curve25519.Field64.Definition.as_nat4 (s0, s1, s2, s3)
noextract
let as_nat (#s:field_spec) (h:mem) (e:felem s): GTot nat =
match s with
| M51 -> f51_as_nat h e
| M64 -> f64_as_nat h e
noextract
let feval (#s:field_spec) (h:mem) (e:felem s): GTot P.elem =
(as_nat h e) % P.prime
/// Start of core combinators
/// -------------------------
let fadd_fsub_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:felem s): Type0 =
match s with
| M51 ->
f51_felem_fits h f1 (1, 2, 1, 1, 1) /\
f51_felem_fits h f2 (1, 2, 1, 1, 1)
| M64 -> True
let fadd_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (2, 4, 2, 2, 2)
| M64 -> True
inline_for_extraction
let fadd_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint f1 f2 \/ f1 == f2) /\
fadd_fsub_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fadd_post h1 out /\
feval h1 out == P.fadd (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize]
val fadd: #s:field_spec -> fadd_t s True
let fsub_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (9, 10, 9, 9, 9)
| M64 -> True
inline_for_extraction
let fsub_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint f1 f2 \/ f1 == f2) /\
fadd_fsub_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fsub_post h1 out /\
feval h1 out == P.fsub (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize ]
val fsub: #s:field_spec -> fsub_t s True
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
h: FStar.Monotonic.HyperStack.mem ->
f1: Hacl.Impl.Curve25519.Fields.Core.felem s ->
f2: Hacl.Impl.Curve25519.Fields.Core.felem s
-> Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Prims.l_and",
"Hacl.Impl.Curve25519.Fields.Core.f51_felem_fits",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Prims.l_True"
] |
[] | false | false | false | false | true |
let fmul_pre (#s: field_spec) (h: mem) (f1 f2: felem s) : Type0 =
|
match s with
| M51 -> f51_felem_fits h f1 (9, 10, 9, 9, 9) /\ f51_felem_fits h f2 (9, 10, 9, 9, 9)
| M64 -> True
| false |
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.as_nat
|
val as_nat (#s: field_spec) (h: mem) (e: felem s) : GTot nat
|
val as_nat (#s: field_spec) (h: mem) (e: felem s) : GTot nat
|
let as_nat (#s:field_spec) (h:mem) (e:felem s): GTot nat =
match s with
| M51 -> f51_as_nat h e
| M64 -> f64_as_nat h e
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 25,
"end_line": 112,
"start_col": 0,
"start_line": 109
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
unfold noextract
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
unfold noextract
let nwide (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 8ul
inline_for_extraction noextract
let felem (s:field_spec) = lbuffer (limb s) (nlimb s)
inline_for_extraction noextract
let felem2 (s:field_spec) = lbuffer (limb s) (nlimb s +. nlimb s)
inline_for_extraction noextract
let felem_wide (s:field_spec) = lbuffer (wide s) (nwide s)
inline_for_extraction noextract
let felem_wide2 (s:field_spec) = lbuffer (wide s) (nwide s +. nwide s)
/// Introduce representation for each field + helpers to be able to state pre & posts
/// ---------------------------------------------------------------------------------
noextract
let f51_as_felem (h:mem) (f:felem M51) : GTot Hacl.Spec.Curve25519.Field51.Definition.felem5 =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
(s0, s1, s2, s3, s4)
let f51_as_nat h e = Hacl.Spec.Curve25519.Field51.Definition.as_nat5 (f51_as_felem h e)
noextract
let f51_felem_fits (h:mem) (f:felem M51) (m:Hacl.Spec.Curve25519.Field51.Definition.scale64_5): Type0 =
Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 (f51_as_felem h f) m
noextract
let f51_felem_fits1 = Hacl.Spec.Curve25519.Field51.Definition.felem_fits1
noextract
let f51_mul_inv_t (h:mem) (f:felem M51) : GTot Type0 =
let f = f51_as_felem h f in
Hacl.Spec.Curve25519.Field51.mul_inv_t f
noextract
let f64_as_nat (h:mem) (e: felem M64) : GTot nat =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
Hacl.Spec.Curve25519.Field64.Definition.as_nat4 (s0, s1, s2, s3)
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
h: FStar.Monotonic.HyperStack.mem -> e: Hacl.Impl.Curve25519.Fields.Core.felem s
-> Prims.GTot Prims.nat
|
Prims.GTot
|
[
"sometrivial"
] |
[] |
[
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Hacl.Impl.Curve25519.Fields.Core.f51_as_nat",
"Hacl.Impl.Curve25519.Fields.Core.f64_as_nat",
"Prims.nat"
] |
[] | false | false | false | false | false |
let as_nat (#s: field_spec) (h: mem) (e: felem s) : GTot nat =
|
match s with
| M51 -> f51_as_nat h e
| M64 -> f64_as_nat h e
| false |
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.fadd_post
|
val fadd_post (#s: field_spec) (h: mem) (out: felem s) : Type0
|
val fadd_post (#s: field_spec) (h: mem) (out: felem s) : Type0
|
let fadd_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (2, 4, 2, 2, 2)
| M64 -> True
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 15,
"end_line": 132,
"start_col": 0,
"start_line": 129
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
unfold noextract
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
unfold noextract
let nwide (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 8ul
inline_for_extraction noextract
let felem (s:field_spec) = lbuffer (limb s) (nlimb s)
inline_for_extraction noextract
let felem2 (s:field_spec) = lbuffer (limb s) (nlimb s +. nlimb s)
inline_for_extraction noextract
let felem_wide (s:field_spec) = lbuffer (wide s) (nwide s)
inline_for_extraction noextract
let felem_wide2 (s:field_spec) = lbuffer (wide s) (nwide s +. nwide s)
/// Introduce representation for each field + helpers to be able to state pre & posts
/// ---------------------------------------------------------------------------------
noextract
let f51_as_felem (h:mem) (f:felem M51) : GTot Hacl.Spec.Curve25519.Field51.Definition.felem5 =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
(s0, s1, s2, s3, s4)
let f51_as_nat h e = Hacl.Spec.Curve25519.Field51.Definition.as_nat5 (f51_as_felem h e)
noextract
let f51_felem_fits (h:mem) (f:felem M51) (m:Hacl.Spec.Curve25519.Field51.Definition.scale64_5): Type0 =
Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 (f51_as_felem h f) m
noextract
let f51_felem_fits1 = Hacl.Spec.Curve25519.Field51.Definition.felem_fits1
noextract
let f51_mul_inv_t (h:mem) (f:felem M51) : GTot Type0 =
let f = f51_as_felem h f in
Hacl.Spec.Curve25519.Field51.mul_inv_t f
noextract
let f64_as_nat (h:mem) (e: felem M64) : GTot nat =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
Hacl.Spec.Curve25519.Field64.Definition.as_nat4 (s0, s1, s2, s3)
noextract
let as_nat (#s:field_spec) (h:mem) (e:felem s): GTot nat =
match s with
| M51 -> f51_as_nat h e
| M64 -> f64_as_nat h e
noextract
let feval (#s:field_spec) (h:mem) (e:felem s): GTot P.elem =
(as_nat h e) % P.prime
/// Start of core combinators
/// -------------------------
let fadd_fsub_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:felem s): Type0 =
match s with
| M51 ->
f51_felem_fits h f1 (1, 2, 1, 1, 1) /\
f51_felem_fits h f2 (1, 2, 1, 1, 1)
| M64 -> True
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
h: FStar.Monotonic.HyperStack.mem -> out: Hacl.Impl.Curve25519.Fields.Core.felem s -> Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Hacl.Impl.Curve25519.Fields.Core.f51_felem_fits",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Prims.l_True"
] |
[] | false | false | false | false | true |
let fadd_post (#s: field_spec) (h: mem) (out: felem s) : Type0 =
|
match s with
| M51 -> f51_felem_fits h out (2, 4, 2, 2, 2)
| M64 -> True
| false |
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.fsub_post
|
val fsub_post (#s: field_spec) (h: mem) (out: felem s) : Type0
|
val fsub_post (#s: field_spec) (h: mem) (out: felem s) : Type0
|
let fsub_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (9, 10, 9, 9, 9)
| M64 -> True
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 15,
"end_line": 156,
"start_col": 0,
"start_line": 153
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
unfold noextract
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
unfold noextract
let nwide (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 8ul
inline_for_extraction noextract
let felem (s:field_spec) = lbuffer (limb s) (nlimb s)
inline_for_extraction noextract
let felem2 (s:field_spec) = lbuffer (limb s) (nlimb s +. nlimb s)
inline_for_extraction noextract
let felem_wide (s:field_spec) = lbuffer (wide s) (nwide s)
inline_for_extraction noextract
let felem_wide2 (s:field_spec) = lbuffer (wide s) (nwide s +. nwide s)
/// Introduce representation for each field + helpers to be able to state pre & posts
/// ---------------------------------------------------------------------------------
noextract
let f51_as_felem (h:mem) (f:felem M51) : GTot Hacl.Spec.Curve25519.Field51.Definition.felem5 =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
(s0, s1, s2, s3, s4)
let f51_as_nat h e = Hacl.Spec.Curve25519.Field51.Definition.as_nat5 (f51_as_felem h e)
noextract
let f51_felem_fits (h:mem) (f:felem M51) (m:Hacl.Spec.Curve25519.Field51.Definition.scale64_5): Type0 =
Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 (f51_as_felem h f) m
noextract
let f51_felem_fits1 = Hacl.Spec.Curve25519.Field51.Definition.felem_fits1
noextract
let f51_mul_inv_t (h:mem) (f:felem M51) : GTot Type0 =
let f = f51_as_felem h f in
Hacl.Spec.Curve25519.Field51.mul_inv_t f
noextract
let f64_as_nat (h:mem) (e: felem M64) : GTot nat =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
Hacl.Spec.Curve25519.Field64.Definition.as_nat4 (s0, s1, s2, s3)
noextract
let as_nat (#s:field_spec) (h:mem) (e:felem s): GTot nat =
match s with
| M51 -> f51_as_nat h e
| M64 -> f64_as_nat h e
noextract
let feval (#s:field_spec) (h:mem) (e:felem s): GTot P.elem =
(as_nat h e) % P.prime
/// Start of core combinators
/// -------------------------
let fadd_fsub_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:felem s): Type0 =
match s with
| M51 ->
f51_felem_fits h f1 (1, 2, 1, 1, 1) /\
f51_felem_fits h f2 (1, 2, 1, 1, 1)
| M64 -> True
let fadd_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (2, 4, 2, 2, 2)
| M64 -> True
inline_for_extraction
let fadd_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint f1 f2 \/ f1 == f2) /\
fadd_fsub_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fadd_post h1 out /\
feval h1 out == P.fadd (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize]
val fadd: #s:field_spec -> fadd_t s True
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
h: FStar.Monotonic.HyperStack.mem -> out: Hacl.Impl.Curve25519.Fields.Core.felem s -> Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Hacl.Impl.Curve25519.Fields.Core.f51_felem_fits",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Prims.l_True"
] |
[] | false | false | false | false | true |
let fsub_post (#s: field_spec) (h: mem) (out: felem s) : Type0 =
|
match s with
| M51 -> f51_felem_fits h out (9, 10, 9, 9, 9)
| M64 -> True
| false |
Hacl.Impl.Ed25519.Field51.fst
|
Hacl.Impl.Ed25519.Field51.felem_fits
|
val felem_fits: h:mem -> f:felem -> m:Hacl.Spec.Curve25519.Field51.Definition.scale64_5 -> Type0
|
val felem_fits: h:mem -> f:felem -> m:Hacl.Spec.Curve25519.Field51.Definition.scale64_5 -> Type0
|
let felem_fits h f m = P.felem_fits h f m
|
{
"file_name": "code/ed25519/Hacl.Impl.Ed25519.Field51.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 41,
"end_line": 32,
"start_col": 0,
"start_line": 32
}
|
module Hacl.Impl.Ed25519.Field51
open FStar.HyperStack
open Lib.IntTypes
open Lib.Buffer
open FStar.Mul
module LSeq = Lib.Sequence
module P = Hacl.Impl.Curve25519.Field51
module S = Spec.Curve25519
let felem = lbuffer uint64 5ul
let point = lbuffer uint64 20ul
let as_nat (h:mem) (f:felem) : GTot nat = P.as_nat h f
let fevalh (h:mem) (f:felem) : GTot S.elem = P.fevalh h f
noextract
val point_eval:h:mem -> p:point -> GTot Spec.Ed25519.ext_point
let point_eval h p =
let x = gsub p 0ul 5ul in
let y = gsub p 5ul 5ul in
let z = gsub p 10ul 5ul in
let t = gsub p 15ul 5ul in
(fevalh h x, fevalh h y, fevalh h z, fevalh h t)
noextract
|
{
"checked_file": "/",
"dependencies": [
"Spec.Ed25519.fst.checked",
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Ed25519.Field51.fst"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Field51",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Ed25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Ed25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
h: FStar.Monotonic.HyperStack.mem ->
f: Hacl.Impl.Ed25519.Field51.felem ->
m: Hacl.Spec.Curve25519.Field51.Definition.scale64_5
-> Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Ed25519.Field51.felem",
"Hacl.Spec.Curve25519.Field51.Definition.scale64_5",
"Hacl.Impl.Curve25519.Field51.felem_fits"
] |
[] | false | false | false | true | true |
let felem_fits h f m =
|
P.felem_fits h f m
| false |
Hacl.Impl.Ed25519.Field51.fst
|
Hacl.Impl.Ed25519.Field51.mul_inv_t
|
val mul_inv_t (h: mem) (f: felem) : GTot Type0
|
val mul_inv_t (h: mem) (f: felem) : GTot Type0
|
let mul_inv_t (h:mem) (f:felem) : GTot Type0 =
P.mul_inv_t h f
|
{
"file_name": "code/ed25519/Hacl.Impl.Ed25519.Field51.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 17,
"end_line": 40,
"start_col": 0,
"start_line": 39
}
|
module Hacl.Impl.Ed25519.Field51
open FStar.HyperStack
open Lib.IntTypes
open Lib.Buffer
open FStar.Mul
module LSeq = Lib.Sequence
module P = Hacl.Impl.Curve25519.Field51
module S = Spec.Curve25519
let felem = lbuffer uint64 5ul
let point = lbuffer uint64 20ul
let as_nat (h:mem) (f:felem) : GTot nat = P.as_nat h f
let fevalh (h:mem) (f:felem) : GTot S.elem = P.fevalh h f
noextract
val point_eval:h:mem -> p:point -> GTot Spec.Ed25519.ext_point
let point_eval h p =
let x = gsub p 0ul 5ul in
let y = gsub p 5ul 5ul in
let z = gsub p 10ul 5ul in
let t = gsub p 15ul 5ul in
(fevalh h x, fevalh h y, fevalh h z, fevalh h t)
noextract
val felem_fits: h:mem -> f:felem -> m:Hacl.Spec.Curve25519.Field51.Definition.scale64_5 -> Type0
let felem_fits h f m = P.felem_fits h f m
noextract
let as_felem (h:mem) (f:felem) =
P.as_felem h f
|
{
"checked_file": "/",
"dependencies": [
"Spec.Ed25519.fst.checked",
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Ed25519.Field51.fst"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Field51",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Ed25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Ed25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
h: FStar.Monotonic.HyperStack.mem -> f: Hacl.Impl.Ed25519.Field51.felem -> Prims.GTot Type0
|
Prims.GTot
|
[
"sometrivial"
] |
[] |
[
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Ed25519.Field51.felem",
"Hacl.Impl.Curve25519.Field51.mul_inv_t"
] |
[] | false | false | false | false | true |
let mul_inv_t (h: mem) (f: felem) : GTot Type0 =
|
P.mul_inv_t h f
| false |
Hacl.Impl.Ed25519.Field51.fst
|
Hacl.Impl.Ed25519.Field51.as_felem
|
val as_felem : h: FStar.Monotonic.HyperStack.mem -> f: Hacl.Impl.Ed25519.Field51.felem
-> Prims.GTot Hacl.Spec.Curve25519.Field51.Definition.felem5
|
let as_felem (h:mem) (f:felem) =
P.as_felem h f
|
{
"file_name": "code/ed25519/Hacl.Impl.Ed25519.Field51.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 16,
"end_line": 36,
"start_col": 0,
"start_line": 35
}
|
module Hacl.Impl.Ed25519.Field51
open FStar.HyperStack
open Lib.IntTypes
open Lib.Buffer
open FStar.Mul
module LSeq = Lib.Sequence
module P = Hacl.Impl.Curve25519.Field51
module S = Spec.Curve25519
let felem = lbuffer uint64 5ul
let point = lbuffer uint64 20ul
let as_nat (h:mem) (f:felem) : GTot nat = P.as_nat h f
let fevalh (h:mem) (f:felem) : GTot S.elem = P.fevalh h f
noextract
val point_eval:h:mem -> p:point -> GTot Spec.Ed25519.ext_point
let point_eval h p =
let x = gsub p 0ul 5ul in
let y = gsub p 5ul 5ul in
let z = gsub p 10ul 5ul in
let t = gsub p 15ul 5ul in
(fevalh h x, fevalh h y, fevalh h z, fevalh h t)
noextract
val felem_fits: h:mem -> f:felem -> m:Hacl.Spec.Curve25519.Field51.Definition.scale64_5 -> Type0
let felem_fits h f m = P.felem_fits h f m
|
{
"checked_file": "/",
"dependencies": [
"Spec.Ed25519.fst.checked",
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Ed25519.Field51.fst"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Curve25519.Field51",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"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.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Ed25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Ed25519",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
h: FStar.Monotonic.HyperStack.mem -> f: Hacl.Impl.Ed25519.Field51.felem
-> Prims.GTot Hacl.Spec.Curve25519.Field51.Definition.felem5
|
Prims.GTot
|
[
"sometrivial"
] |
[] |
[
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Ed25519.Field51.felem",
"Hacl.Impl.Curve25519.Field51.as_felem",
"Hacl.Spec.Curve25519.Field51.Definition.felem5"
] |
[] | false | false | false | false | false |
let as_felem (h: mem) (f: felem) =
|
P.as_felem h f
| false |
|
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.fmul_disjoint
|
val fmul_disjoint (#s: field_spec) (out f1 f2: felem s) (tmp: felem_wide2 s) : Type0
|
val fmul_disjoint (#s: field_spec) (out f1 f2: felem s) (tmp: felem_wide2 s) : Type0
|
let fmul_disjoint (#s:field_spec) (out f1 f2:felem s) (tmp:felem_wide2 s): Type0 =
match s with
| M51 -> True
| M64 ->
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint out tmp \/ out == tmp) /\
(disjoint f1 f2 \/ f1 == f2) /\
disjoint f1 tmp /\
disjoint f2 tmp
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 21,
"end_line": 193,
"start_col": 0,
"start_line": 184
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
unfold noextract
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
unfold noextract
let nwide (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 8ul
inline_for_extraction noextract
let felem (s:field_spec) = lbuffer (limb s) (nlimb s)
inline_for_extraction noextract
let felem2 (s:field_spec) = lbuffer (limb s) (nlimb s +. nlimb s)
inline_for_extraction noextract
let felem_wide (s:field_spec) = lbuffer (wide s) (nwide s)
inline_for_extraction noextract
let felem_wide2 (s:field_spec) = lbuffer (wide s) (nwide s +. nwide s)
/// Introduce representation for each field + helpers to be able to state pre & posts
/// ---------------------------------------------------------------------------------
noextract
let f51_as_felem (h:mem) (f:felem M51) : GTot Hacl.Spec.Curve25519.Field51.Definition.felem5 =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
(s0, s1, s2, s3, s4)
let f51_as_nat h e = Hacl.Spec.Curve25519.Field51.Definition.as_nat5 (f51_as_felem h e)
noextract
let f51_felem_fits (h:mem) (f:felem M51) (m:Hacl.Spec.Curve25519.Field51.Definition.scale64_5): Type0 =
Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 (f51_as_felem h f) m
noextract
let f51_felem_fits1 = Hacl.Spec.Curve25519.Field51.Definition.felem_fits1
noextract
let f51_mul_inv_t (h:mem) (f:felem M51) : GTot Type0 =
let f = f51_as_felem h f in
Hacl.Spec.Curve25519.Field51.mul_inv_t f
noextract
let f64_as_nat (h:mem) (e: felem M64) : GTot nat =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
Hacl.Spec.Curve25519.Field64.Definition.as_nat4 (s0, s1, s2, s3)
noextract
let as_nat (#s:field_spec) (h:mem) (e:felem s): GTot nat =
match s with
| M51 -> f51_as_nat h e
| M64 -> f64_as_nat h e
noextract
let feval (#s:field_spec) (h:mem) (e:felem s): GTot P.elem =
(as_nat h e) % P.prime
/// Start of core combinators
/// -------------------------
let fadd_fsub_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:felem s): Type0 =
match s with
| M51 ->
f51_felem_fits h f1 (1, 2, 1, 1, 1) /\
f51_felem_fits h f2 (1, 2, 1, 1, 1)
| M64 -> True
let fadd_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (2, 4, 2, 2, 2)
| M64 -> True
inline_for_extraction
let fadd_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint f1 f2 \/ f1 == f2) /\
fadd_fsub_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fadd_post h1 out /\
feval h1 out == P.fadd (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize]
val fadd: #s:field_spec -> fadd_t s True
let fsub_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (9, 10, 9, 9, 9)
| M64 -> True
inline_for_extraction
let fsub_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint f1 f2 \/ f1 == f2) /\
fadd_fsub_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fsub_post h1 out /\
feval h1 out == P.fsub (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize ]
val fsub: #s:field_spec -> fsub_t s True
let fmul_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:felem s): Type0 =
match s with
| M51 ->
f51_felem_fits h f1 (9, 10, 9, 9, 9) /\
f51_felem_fits h f2 (9, 10, 9, 9, 9)
| M64 -> True
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
out: Hacl.Impl.Curve25519.Fields.Core.felem s ->
f1: Hacl.Impl.Curve25519.Fields.Core.felem s ->
f2: Hacl.Impl.Curve25519.Fields.Core.felem s ->
tmp: Hacl.Impl.Curve25519.Fields.Core.felem_wide2 s
-> Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Hacl.Impl.Curve25519.Fields.Core.felem_wide2",
"Prims.l_True",
"Prims.l_and",
"Prims.l_or",
"Lib.Buffer.disjoint",
"Lib.Buffer.MUT",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Prims.eq2",
"Hacl.Impl.Curve25519.Fields.Core.wide",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Buffer.trivial_preorder",
"Prims.int",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Lib.IntTypes.range",
"Lib.IntTypes.U32",
"Lib.Buffer.length",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"Lib.IntTypes.op_Plus_Dot",
"Hacl.Impl.Curve25519.Fields.Core.nwide",
"Hacl.Impl.Curve25519.Fields.Core.nlimb"
] |
[] | false | false | false | false | true |
let fmul_disjoint (#s: field_spec) (out f1 f2: felem s) (tmp: felem_wide2 s) : Type0 =
|
match s with
| M51 -> True
| M64 ->
(disjoint out f1 \/ out == f1) /\ (disjoint out f2 \/ out == f2) /\
(disjoint out tmp \/ out == tmp) /\ (disjoint f1 f2 \/ f1 == f2) /\ disjoint f1 tmp /\
disjoint f2 tmp
| false |
Steel.ST.GhostPCMReference.fst
|
Steel.ST.GhostPCMReference.write
|
val write (#o:inames)
(#a:Type)
(#pcm:pcm a)
(r:ref a pcm)
(v0:a)
(v1:a)
: STGhost unit o
(pts_to r v0)
(fun _ -> pts_to r v1)
(requires frame_preserving pcm v0 v1 /\ pcm.refine v1)
(ensures fun _ -> True)
|
val write (#o:inames)
(#a:Type)
(#pcm:pcm a)
(r:ref a pcm)
(v0:a)
(v1:a)
: STGhost unit o
(pts_to r v0)
(fun _ -> pts_to r v1)
(requires frame_preserving pcm v0 v1 /\ pcm.refine v1)
(ensures fun _ -> True)
|
let write (#o:inames)
(#a:Type)
(#pcm:pcm a)
(r:ref a pcm)
(v0:a)
(v1:a)
: STGhost unit o
(pts_to r v0)
(fun _ -> pts_to r v1)
(requires frame_preserving pcm v0 v1 /\ pcm.refine v1)
(ensures fun _ -> True)
= coerce_ghost (fun _ -> G.write r (raise_val v0) (raise_val v1))
|
{
"file_name": "lib/steel/Steel.ST.GhostPCMReference.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
}
|
{
"end_col": 67,
"end_line": 69,
"start_col": 0,
"start_line": 58
}
|
(*
Copyright 2021 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.ST.GhostPCMReference
open FStar.Ghost
open Steel.ST.Util
open Steel.ST.Coercions
open FStar.PCM
open FStar.Universe
module UP = FStar.Universe.PCM
module G = Steel.GhostPCMReference
let ref (a:Type u#0) (p:pcm a) : Type u#0 =
G.ref (raise_t u#0 u#1 a) (UP.raise p)
/// pts_to is fixed to ref contents in u#0
let pts_to (#a:Type u#0) (#pcm:pcm a) (r:ref a pcm) ([@@@smt_fallback] v:a)
= G.pts_to #(raise_t a) #(UP.raise pcm) r (raise_val v)
/// Allocates a new reference, initially storing value [x].
let alloc (#o:inames)
(#a:Type)
(#pcm:pcm a)
(x:a)
: STGhost (ref a pcm) o
emp
(fun r -> pts_to r x)
(requires pcm.refine x)
(ensures fun _ -> True)
= coerce_ghost (fun _ -> G.alloc (raise_val x))
let read (#o:inames)
(#a:Type)
(#pcm:pcm a)
(#v0:a)
(r:ref a pcm)
: STGhost a o
(pts_to r v0)
(fun _ -> pts_to r v0)
(requires True)
(ensures fun v -> compatible pcm v0 v)
= let v = coerce_ghost (fun _ -> G.read r) in
downgrade_val v
|
{
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.ST.Coercions.fsti.checked",
"Steel.GhostPCMReference.fsti.checked",
"prims.fst.checked",
"FStar.Universe.PCM.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GhostPCMReference.fst"
}
|
[
{
"abbrev": true,
"full_module": "Steel.GhostPCMReference",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Universe.PCM",
"short_module": "UP"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Coercions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
r: Steel.ST.GhostPCMReference.ref a pcm -> v0: a -> v1: a
-> Steel.ST.Effect.Ghost.STGhost Prims.unit
|
Steel.ST.Effect.Ghost.STGhost
|
[] |
[] |
[
"Steel.Memory.inames",
"FStar.PCM.pcm",
"Steel.ST.GhostPCMReference.ref",
"Steel.ST.Coercions.coerce_ghost",
"Prims.unit",
"Steel.GhostPCMReference.pts_to",
"FStar.Universe.raise_t",
"FStar.Universe.PCM.raise",
"FStar.Universe.raise_val",
"Steel.Effect.Common.vprop",
"Prims.l_and",
"FStar.PCM.frame_preserving",
"FStar.PCM.__proj__Mkpcm__item__refine",
"Prims.l_True",
"Steel.GhostPCMReference.write",
"Steel.ST.GhostPCMReference.pts_to"
] |
[] | false | true | false | false | false |
let write (#o: inames) (#a: Type) (#pcm: pcm a) (r: ref a pcm) (v0 v1: a)
: STGhost unit
o
(pts_to r v0)
(fun _ -> pts_to r v1)
(requires frame_preserving pcm v0 v1 /\ pcm.refine v1)
(ensures fun _ -> True) =
|
coerce_ghost (fun _ -> G.write r (raise_val v0) (raise_val v1))
| false |
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.fadd_fsub_pre
|
val fadd_fsub_pre (#s: field_spec) (h: mem) (f1 f2: felem s) : Type0
|
val fadd_fsub_pre (#s: field_spec) (h: mem) (f1 f2: felem s) : Type0
|
let fadd_fsub_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:felem s): Type0 =
match s with
| M51 ->
f51_felem_fits h f1 (1, 2, 1, 1, 1) /\
f51_felem_fits h f2 (1, 2, 1, 1, 1)
| M64 -> True
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 15,
"end_line": 127,
"start_col": 0,
"start_line": 122
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
unfold noextract
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
unfold noextract
let nwide (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 8ul
inline_for_extraction noextract
let felem (s:field_spec) = lbuffer (limb s) (nlimb s)
inline_for_extraction noextract
let felem2 (s:field_spec) = lbuffer (limb s) (nlimb s +. nlimb s)
inline_for_extraction noextract
let felem_wide (s:field_spec) = lbuffer (wide s) (nwide s)
inline_for_extraction noextract
let felem_wide2 (s:field_spec) = lbuffer (wide s) (nwide s +. nwide s)
/// Introduce representation for each field + helpers to be able to state pre & posts
/// ---------------------------------------------------------------------------------
noextract
let f51_as_felem (h:mem) (f:felem M51) : GTot Hacl.Spec.Curve25519.Field51.Definition.felem5 =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
(s0, s1, s2, s3, s4)
let f51_as_nat h e = Hacl.Spec.Curve25519.Field51.Definition.as_nat5 (f51_as_felem h e)
noextract
let f51_felem_fits (h:mem) (f:felem M51) (m:Hacl.Spec.Curve25519.Field51.Definition.scale64_5): Type0 =
Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 (f51_as_felem h f) m
noextract
let f51_felem_fits1 = Hacl.Spec.Curve25519.Field51.Definition.felem_fits1
noextract
let f51_mul_inv_t (h:mem) (f:felem M51) : GTot Type0 =
let f = f51_as_felem h f in
Hacl.Spec.Curve25519.Field51.mul_inv_t f
noextract
let f64_as_nat (h:mem) (e: felem M64) : GTot nat =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
Hacl.Spec.Curve25519.Field64.Definition.as_nat4 (s0, s1, s2, s3)
noextract
let as_nat (#s:field_spec) (h:mem) (e:felem s): GTot nat =
match s with
| M51 -> f51_as_nat h e
| M64 -> f64_as_nat h e
noextract
let feval (#s:field_spec) (h:mem) (e:felem s): GTot P.elem =
(as_nat h e) % P.prime
/// Start of core combinators
/// -------------------------
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
h: FStar.Monotonic.HyperStack.mem ->
f1: Hacl.Impl.Curve25519.Fields.Core.felem s ->
f2: Hacl.Impl.Curve25519.Fields.Core.felem s
-> Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Prims.l_and",
"Hacl.Impl.Curve25519.Fields.Core.f51_felem_fits",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Prims.l_True"
] |
[] | false | false | false | false | true |
let fadd_fsub_pre (#s: field_spec) (h: mem) (f1 f2: felem s) : Type0 =
|
match s with
| M51 -> f51_felem_fits h f1 (1, 2, 1, 1, 1) /\ f51_felem_fits h f2 (1, 2, 1, 1, 1)
| M64 -> True
| false |
Bug96.fst
|
Bug96.mini_t
|
val mini_t : Prims.eqtype
|
let mini_t = int
|
{
"file_name": "share/steel/examples/pulse/bug-reports/Bug96.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
}
|
{
"end_col": 16,
"end_line": 21,
"start_col": 0,
"start_line": 21
}
|
(*
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 Bug96
open Pulse.Lib.Pervasives
|
{
"checked_file": "/",
"dependencies": [
"Pulse.Lib.Pervasives.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Bug96.fst"
}
|
[
{
"abbrev": false,
"full_module": "Pulse.Lib.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
Prims.eqtype
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Prims.int"
] |
[] | false | false | false | true | false |
let mini_t =
|
int
| false |
|
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.state_inv_t
|
val state_inv_t (#s: field_spec) (h: mem) (f: felem s) : Type0
|
val state_inv_t (#s: field_spec) (h: mem) (f: felem s) : Type0
|
let state_inv_t (#s:field_spec) (h:mem) (f:felem s): Type0 =
match s with
| M51 -> f51_mul_inv_t h f
| M64 -> True
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 15,
"end_line": 199,
"start_col": 0,
"start_line": 196
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
unfold noextract
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
unfold noextract
let nwide (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 8ul
inline_for_extraction noextract
let felem (s:field_spec) = lbuffer (limb s) (nlimb s)
inline_for_extraction noextract
let felem2 (s:field_spec) = lbuffer (limb s) (nlimb s +. nlimb s)
inline_for_extraction noextract
let felem_wide (s:field_spec) = lbuffer (wide s) (nwide s)
inline_for_extraction noextract
let felem_wide2 (s:field_spec) = lbuffer (wide s) (nwide s +. nwide s)
/// Introduce representation for each field + helpers to be able to state pre & posts
/// ---------------------------------------------------------------------------------
noextract
let f51_as_felem (h:mem) (f:felem M51) : GTot Hacl.Spec.Curve25519.Field51.Definition.felem5 =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
(s0, s1, s2, s3, s4)
let f51_as_nat h e = Hacl.Spec.Curve25519.Field51.Definition.as_nat5 (f51_as_felem h e)
noextract
let f51_felem_fits (h:mem) (f:felem M51) (m:Hacl.Spec.Curve25519.Field51.Definition.scale64_5): Type0 =
Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 (f51_as_felem h f) m
noextract
let f51_felem_fits1 = Hacl.Spec.Curve25519.Field51.Definition.felem_fits1
noextract
let f51_mul_inv_t (h:mem) (f:felem M51) : GTot Type0 =
let f = f51_as_felem h f in
Hacl.Spec.Curve25519.Field51.mul_inv_t f
noextract
let f64_as_nat (h:mem) (e: felem M64) : GTot nat =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
Hacl.Spec.Curve25519.Field64.Definition.as_nat4 (s0, s1, s2, s3)
noextract
let as_nat (#s:field_spec) (h:mem) (e:felem s): GTot nat =
match s with
| M51 -> f51_as_nat h e
| M64 -> f64_as_nat h e
noextract
let feval (#s:field_spec) (h:mem) (e:felem s): GTot P.elem =
(as_nat h e) % P.prime
/// Start of core combinators
/// -------------------------
let fadd_fsub_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:felem s): Type0 =
match s with
| M51 ->
f51_felem_fits h f1 (1, 2, 1, 1, 1) /\
f51_felem_fits h f2 (1, 2, 1, 1, 1)
| M64 -> True
let fadd_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (2, 4, 2, 2, 2)
| M64 -> True
inline_for_extraction
let fadd_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint f1 f2 \/ f1 == f2) /\
fadd_fsub_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fadd_post h1 out /\
feval h1 out == P.fadd (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize]
val fadd: #s:field_spec -> fadd_t s True
let fsub_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (9, 10, 9, 9, 9)
| M64 -> True
inline_for_extraction
let fsub_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint f1 f2 \/ f1 == f2) /\
fadd_fsub_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fsub_post h1 out /\
feval h1 out == P.fsub (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize ]
val fsub: #s:field_spec -> fsub_t s True
let fmul_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:felem s): Type0 =
match s with
| M51 ->
f51_felem_fits h f1 (9, 10, 9, 9, 9) /\
f51_felem_fits h f2 (9, 10, 9, 9, 9)
| M64 -> True
let fmul_disjoint (#s:field_spec) (out f1 f2:felem s) (tmp:felem_wide2 s): Type0 =
match s with
| M51 -> True
| M64 ->
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint out tmp \/ out == tmp) /\
(disjoint f1 f2 \/ f1 == f2) /\
disjoint f1 tmp /\
disjoint f2 tmp
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
h: FStar.Monotonic.HyperStack.mem -> f: Hacl.Impl.Curve25519.Fields.Core.felem s -> Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Hacl.Impl.Curve25519.Fields.Core.f51_mul_inv_t",
"Prims.l_True"
] |
[] | false | false | false | false | true |
let state_inv_t (#s: field_spec) (h: mem) (f: felem s) : Type0 =
|
match s with
| M51 -> f51_mul_inv_t h f
| M64 -> True
| false |
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.fmul1_pre
|
val fmul1_pre (#s: field_spec) (h: mem) (f1: felem s) (f2: uint64) : Type0
|
val fmul1_pre (#s: field_spec) (h: mem) (f1: felem s) (f2: uint64) : Type0
|
let fmul1_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:uint64): Type0 =
match s with
| M51 -> f51_felem_fits h f1 (9, 10, 9, 9, 9) /\ f51_felem_fits1 f2 1
| M64 -> v f2 < pow2 17
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 25,
"end_line": 275,
"start_col": 0,
"start_line": 272
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
unfold noextract
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
unfold noextract
let nwide (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 8ul
inline_for_extraction noextract
let felem (s:field_spec) = lbuffer (limb s) (nlimb s)
inline_for_extraction noextract
let felem2 (s:field_spec) = lbuffer (limb s) (nlimb s +. nlimb s)
inline_for_extraction noextract
let felem_wide (s:field_spec) = lbuffer (wide s) (nwide s)
inline_for_extraction noextract
let felem_wide2 (s:field_spec) = lbuffer (wide s) (nwide s +. nwide s)
/// Introduce representation for each field + helpers to be able to state pre & posts
/// ---------------------------------------------------------------------------------
noextract
let f51_as_felem (h:mem) (f:felem M51) : GTot Hacl.Spec.Curve25519.Field51.Definition.felem5 =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
(s0, s1, s2, s3, s4)
let f51_as_nat h e = Hacl.Spec.Curve25519.Field51.Definition.as_nat5 (f51_as_felem h e)
noextract
let f51_felem_fits (h:mem) (f:felem M51) (m:Hacl.Spec.Curve25519.Field51.Definition.scale64_5): Type0 =
Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 (f51_as_felem h f) m
noextract
let f51_felem_fits1 = Hacl.Spec.Curve25519.Field51.Definition.felem_fits1
noextract
let f51_mul_inv_t (h:mem) (f:felem M51) : GTot Type0 =
let f = f51_as_felem h f in
Hacl.Spec.Curve25519.Field51.mul_inv_t f
noextract
let f64_as_nat (h:mem) (e: felem M64) : GTot nat =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
Hacl.Spec.Curve25519.Field64.Definition.as_nat4 (s0, s1, s2, s3)
noextract
let as_nat (#s:field_spec) (h:mem) (e:felem s): GTot nat =
match s with
| M51 -> f51_as_nat h e
| M64 -> f64_as_nat h e
noextract
let feval (#s:field_spec) (h:mem) (e:felem s): GTot P.elem =
(as_nat h e) % P.prime
/// Start of core combinators
/// -------------------------
let fadd_fsub_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:felem s): Type0 =
match s with
| M51 ->
f51_felem_fits h f1 (1, 2, 1, 1, 1) /\
f51_felem_fits h f2 (1, 2, 1, 1, 1)
| M64 -> True
let fadd_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (2, 4, 2, 2, 2)
| M64 -> True
inline_for_extraction
let fadd_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint f1 f2 \/ f1 == f2) /\
fadd_fsub_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fadd_post h1 out /\
feval h1 out == P.fadd (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize]
val fadd: #s:field_spec -> fadd_t s True
let fsub_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (9, 10, 9, 9, 9)
| M64 -> True
inline_for_extraction
let fsub_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint f1 f2 \/ f1 == f2) /\
fadd_fsub_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fsub_post h1 out /\
feval h1 out == P.fsub (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize ]
val fsub: #s:field_spec -> fsub_t s True
let fmul_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:felem s): Type0 =
match s with
| M51 ->
f51_felem_fits h f1 (9, 10, 9, 9, 9) /\
f51_felem_fits h f2 (9, 10, 9, 9, 9)
| M64 -> True
let fmul_disjoint (#s:field_spec) (out f1 f2:felem s) (tmp:felem_wide2 s): Type0 =
match s with
| M51 -> True
| M64 ->
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint out tmp \/ out == tmp) /\
(disjoint f1 f2 \/ f1 == f2) /\
disjoint f1 tmp /\
disjoint f2 tmp
let state_inv_t (#s:field_spec) (h:mem) (f:felem s): Type0 =
match s with
| M51 -> f51_mul_inv_t h f
| M64 -> True
inline_for_extraction
let fmul_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> tmp:felem_wide2 s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\ live h tmp /\
fmul_disjoint out f1 f2 tmp /\
fmul_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out |+| loc tmp) h0 h1 /\ state_inv_t h1 out /\
feval h1 out == P.fmul (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize ]
val fmul: #s:field_spec -> fmul_t s True
let fmul2_pre (#s:field_spec) (h:mem) (f1:felem2 s) (f2:felem2 s): Type0 =
match s with
| M51 ->
let f10 = gsub f1 0ul 5ul in
let f11 = gsub f1 5ul 5ul in
let f20 = gsub f2 0ul 5ul in
let f21 = gsub f2 5ul 5ul in
f51_felem_fits h f10 (9, 10, 9, 9, 9) /\
f51_felem_fits h f11 (9, 10, 9, 9, 9) /\
f51_felem_fits h f20 (9, 10, 9, 9, 9) /\
f51_felem_fits h f21 (9, 10, 9, 9, 9)
| M64 -> True
let fmul2_fsqr2_post (#s:field_spec) (h:mem) (out:felem2 s): Type0 =
match s with
| M51 ->
let out0 = gsub out 0ul 5ul in
let out1 = gsub out 5ul 5ul in
f51_mul_inv_t h out0 /\
f51_mul_inv_t h out1
| M64 -> True
inline_for_extraction
let fmul2_t (s:field_spec) (p: Type0) =
out:felem2 s
-> f1:felem2 s
-> f2:felem2 s
-> tmp:felem_wide2 s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\ live h tmp /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint out tmp) /\
(disjoint f1 f2 \/ f1 == f2) /\
disjoint f1 tmp /\
disjoint f2 tmp /\
fmul2_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out |+| loc tmp) h0 h1 /\ fmul2_fsqr2_post h1 out /\
(let out0 = gsub out 0ul (nlimb s) in
let out1 = gsub out (nlimb s) (nlimb s) in
let f10 = gsub f1 0ul (nlimb s) in
let f11 = gsub f1 (nlimb s) (nlimb s) in
let f20 = gsub f2 0ul (nlimb s) in
let f21 = gsub f2 (nlimb s) (nlimb s) in
feval h1 out0 == P.fmul (feval h0 f10) (feval h0 f20) /\
feval h1 out1 == P.fmul (feval h0 f11) (feval h0 f21)))
[@ Meta.Attribute.specialize ]
val fmul2: #s:field_spec -> fmul2_t s True
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
h: FStar.Monotonic.HyperStack.mem ->
f1: Hacl.Impl.Curve25519.Fields.Core.felem s ->
f2: Lib.IntTypes.uint64
-> Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Lib.IntTypes.uint64",
"Prims.l_and",
"Hacl.Impl.Curve25519.Fields.Core.f51_felem_fits",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Prims.b2t",
"Hacl.Impl.Curve25519.Fields.Core.f51_felem_fits1",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Prims.pow2"
] |
[] | false | false | false | false | true |
let fmul1_pre (#s: field_spec) (h: mem) (f1: felem s) (f2: uint64) : Type0 =
|
match s with
| M51 -> f51_felem_fits h f1 (9, 10, 9, 9, 9) /\ f51_felem_fits1 f2 1
| M64 -> v f2 < pow2 17
| false |
Pulse.Checker.STApp.fst
|
Pulse.Checker.STApp.apply_impure_function
|
val apply_impure_function
(range: range)
(g0: env)
(uvs: _)
(g: env{extends_with g g0 uvs})
(ctxt: vprop)
(ctxt_typing: tot_typing g0 ctxt tm_vprop)
(post_hint: post_hint_opt g0)
(res_ppname: ppname)
(head: term)
(qual: option qualifier)
(arg ty_head: term)
(eff_head: _)
(dhead: typing g head eff_head ty_head)
(b: (binder & option qualifier & comp){Some b == is_arrow ty_head})
: T.Tac (checker_result_t g0 ctxt post_hint)
|
val apply_impure_function
(range: range)
(g0: env)
(uvs: _)
(g: env{extends_with g g0 uvs})
(ctxt: vprop)
(ctxt_typing: tot_typing g0 ctxt tm_vprop)
(post_hint: post_hint_opt g0)
(res_ppname: ppname)
(head: term)
(qual: option qualifier)
(arg ty_head: term)
(eff_head: _)
(dhead: typing g head eff_head ty_head)
(b: (binder & option qualifier & comp){Some b == is_arrow ty_head})
: T.Tac (checker_result_t g0 ctxt post_hint)
|
let apply_impure_function
(range:range)
(g0:env)
(uvs:_)
(g:env { extends_with g g0 uvs })
(ctxt:vprop)
(ctxt_typing:tot_typing g0 ctxt tm_vprop)
(post_hint:post_hint_opt g0)
(res_ppname:ppname)
(head:term)
(qual:option qualifier)
(arg:term)
(ty_head:term)
(eff_head:_)
(dhead:typing g head eff_head ty_head)
(b:binder & option qualifier & comp { Some b == is_arrow ty_head })
: T.Tac (checker_result_t g0 ctxt post_hint)
= let {binder_ty=formal;binder_ppname=ppname}, bqual, comp_typ = b in
assert (g `env_extends` g0);
let post_hint : post_hint_opt g = post_hint in
is_arrow_tm_arrow ty_head;
debug_log g (fun _ ->
T.print (Printf.sprintf "st_app, head=%s, arg=%s, readback comp as %s\n"
(P.term_to_string head)
(P.term_to_string arg)
(P.comp_to_string comp_typ)));
let allow_ghost = C_STGhost? comp_typ in
if (not allow_ghost) &&
eff_head = T.E_Ghost
then fail g (Some range)
(Printf.sprintf "head term %s is ghost, but the arrow comp is not STGhost"
(P.term_to_string head));
if qual <> bqual
then (
fail g (Some range) (Printf.sprintf "Unexpected qualifier in head type %s of stateful application: head = %s, arg = %s"
(P.term_to_string ty_head)
(P.term_to_string head)
(P.term_to_string arg))
)
else (
let eff_arg = if allow_ghost then T.E_Ghost else T.E_Total in
let (| arg, darg |) = check_term g arg eff_arg formal in
let (| t, c, d |) : (t:st_term & c:comp_st & st_typing g t c) =
match comp_typ with
| C_ST res
| C_STAtomic _ _ res ->
// ST application
let d : st_typing _ _ (open_comp_with comp_typ arg) =
T_STApp g head formal qual comp_typ arg dhead darg in
let d = canonicalize_st_typing d in
let t = { term = Tm_STApp {head; arg_qual=qual; arg}; range; effect_tag=as_effect_hint (ctag_of_comp_st comp_typ) } in
let c = (canon_comp (open_comp_with comp_typ arg)) in
(| t, c, d |)
| C_STGhost res ->
// get the non-informative witness
let x = fresh g in
if x `Set.mem` freevars_comp (comp_typ)
then fail g (Some range)
("Unexpected clash of variable names, please file a bug-report");
//
// This will always succeed, is there a way to avoid this?
//
let d_non_info =
let token =
is_non_informative (push_binding g x ppname_default formal)
(open_comp_with comp_typ (null_var x)) in
match token with
| None ->
fail g (Some range)
(Printf.sprintf "Unexpected non-informative result for %s" (P.comp_to_string comp_typ))
| Some token ->
RT.Non_informative_token _ _
(FStar.Squash.return_squash token) in
let d : st_typing _ _ (open_comp_with comp_typ arg) =
T_STGhostApp g head formal qual comp_typ arg x
(lift_typing_to_ghost_typing dhead)
(E d_non_info)
(lift_typing_to_ghost_typing darg) in
let d = canonicalize_st_typing d in
let t = { term = Tm_STApp {head; arg_qual=qual; arg}; range; effect_tag=as_effect_hint STT_Ghost } in
let c = (canon_comp (open_comp_with comp_typ arg)) in
(| t, c, d |)
| _ ->
fail g (Some range)
"Expected an effectful application; got a pure term (could it be partially applied by mistake?)"
in
let (| st', c', st_typing' |) = match_comp_res_with_post_hint d post_hint in
debug_log g (fun _ -> T.print (Printf.sprintf "st_app: c' = %s\n"
(show #comp c')));
let framed = Prover.try_frame_pre_uvs ctxt_typing uvs (| st', c', st_typing' |) res_ppname in
Prover.prove_post_hint framed post_hint range
)
|
{
"file_name": "lib/steel/pulse/Pulse.Checker.STApp.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
}
|
{
"end_col": 5,
"end_line": 208,
"start_col": 0,
"start_line": 112
}
|
(*
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.Checker.STApp
open Pulse.Syntax
open Pulse.Typing
open Pulse.Checker.Pure
open Pulse.Checker.Base
module T = FStar.Tactics.V2
module RT = FStar.Reflection.Typing
module FV = Pulse.Typing.FV
module RU = Pulse.RuntimeUtils
module P = Pulse.Syntax.Printer
module Prover = Pulse.Checker.Prover
open Pulse.Show
let debug_log (g:env) (f:unit -> T.Tac unit) : T.Tac unit = if RU.debug_at_level (fstar_env g) "st_app" then f () else ()
let canon_comp (c:comp_st) : comp_st =
match readback_comp (elab_comp c) with
| None -> c
| Some (C_Tot _) -> c //should be impossible
| Some c' -> c'
#push-options "--admit_smt_queries true"
let canon_comp_eq_res (g:env) (c:comp_st)
: RT.equiv (elab_env g) (elab_term (comp_res c)) (elab_term (comp_res (canon_comp c)))
= RT.Rel_refl _ _ _
#pop-options
let canonicalize_st_typing (#g:env) (#t:st_term) (#c:comp_st) (d:st_typing g t c)
: st_typing g t (canon_comp c)
= let c' = canon_comp c in
let x = fresh g in
assume ( ~(x `Set.mem` freevars (comp_post c)) /\
~(x `Set.mem` freevars (comp_post c')) );
assume (st_equiv_pre c c');
let st_eq
: st_equiv g c c'
= ST_VPropEquiv g c c' x (RU.magic ()) (RU.magic()) (RU.magic()) (canon_comp_eq_res g c) (RU.magic()) (RU.magic())
in
T_Equiv _ _ _ _ d st_eq
let coerce_eq (#a #b:Type) (x:a) (_:squash (a === b)) : y:b { y == x } = x
let rec intro_uvars_for_logical_implicits (g:env) (uvs:env { disjoint g uvs }) (t:term) (ty:term)
: T.Tac (uvs':env &
g':env { extends_with g' g uvs' } &
t':st_term { Tm_STApp? t'.term }) =
let ropt = is_arrow ty in
match ropt with
| Some (b, Some Implicit, c_rest) ->
let x = fresh (push_env g uvs) in
let uvs' = push_binding uvs x b.binder_ppname b.binder_ty in
let c_rest = open_comp_with c_rest (tm_var {nm_index = x; nm_ppname = b.binder_ppname}) in
begin
match c_rest with
| C_ST _
| C_STAtomic _ _ _
| C_STGhost _ ->
(| uvs', push_env g uvs', {term=Tm_STApp {head=t;arg_qual=Some Implicit;arg=null_var x};
range=t.range;
effect_tag=as_effect_hint (ctag_of_comp_st c_rest) } |)
| C_Tot ty ->
intro_uvars_for_logical_implicits g uvs' (tm_pureapp t (Some Implicit) (null_var x)) ty
end
| _ ->
fail g None
(Printf.sprintf "check_stapp.intro_uvars_for_logical_implicits: expected an arrow type,\
with an implicit parameter, found: %s"
(P.term_to_string ty))
let instantiate_implicits (g:env) (t:st_term { Tm_STApp? t.term })
: T.Tac (uvs : env &
g' : env { extends_with g' g uvs } &
t' : st_term { Tm_STApp? t'.term }) =
let range = t.range in
let Tm_STApp { head; arg_qual=qual; arg } = t.term in
let pure_app = tm_pureapp head qual arg in
let (| uvs, t, ty |) = instantiate_term_implicits_uvs g pure_app in
match is_arrow ty with
| Some (_, Some Implicit, _) ->
//Some implicits to follow
intro_uvars_for_logical_implicits g uvs t ty
| _ ->
match is_pure_app t with
| Some (head, q, arg) ->
(| uvs, push_env g uvs, {term=Tm_STApp {head;arg_qual=q;arg}; range=t.range; effect_tag=default_effect_hint } |)
| _ ->
fail g (Some t.range)
(Printf.sprintf "check_stapp.instantiate_implicits: expected an application term, found: %s"
(show t))
|
{
"checked_file": "/",
"dependencies": [
"Pulse.Typing.FV.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.Show.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Checker.Pure.fsti.checked",
"Pulse.Checker.Prover.fsti.checked",
"Pulse.Checker.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.STApp.fst"
}
|
[
{
"abbrev": false,
"full_module": "Pulse.Show",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover",
"short_module": "Prover"
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.FV",
"short_module": "FV"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 4,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
range: Pulse.Syntax.Base.range ->
g0: Pulse.Typing.Env.env ->
uvs: Pulse.Typing.Env.env ->
g: Pulse.Typing.Env.env{Pulse.Typing.Env.extends_with g g0 uvs} ->
ctxt: Pulse.Syntax.Base.vprop ->
ctxt_typing: Pulse.Typing.tot_typing g0 ctxt Pulse.Syntax.Base.tm_vprop ->
post_hint: Pulse.Typing.post_hint_opt g0 ->
res_ppname: Pulse.Syntax.Base.ppname ->
head: Pulse.Syntax.Base.term ->
qual: FStar.Pervasives.Native.option Pulse.Syntax.Base.qualifier ->
arg: Pulse.Syntax.Base.term ->
ty_head: Pulse.Syntax.Base.term ->
eff_head: FStar.Stubs.TypeChecker.Core.tot_or_ghost ->
dhead: Pulse.Typing.typing g head eff_head ty_head ->
b:
((Pulse.Syntax.Base.binder * FStar.Pervasives.Native.option Pulse.Syntax.Base.qualifier) *
Pulse.Syntax.Base.comp)
{FStar.Pervasives.Native.Some b == Pulse.Syntax.Pure.is_arrow ty_head}
-> FStar.Tactics.Effect.Tac (Pulse.Checker.Base.checker_result_t g0 ctxt post_hint)
|
FStar.Tactics.Effect.Tac
|
[] |
[] |
[
"Pulse.Syntax.Base.range",
"Pulse.Typing.Env.env",
"Pulse.Typing.Env.extends_with",
"Pulse.Syntax.Base.vprop",
"Pulse.Typing.tot_typing",
"Pulse.Syntax.Base.tm_vprop",
"Pulse.Typing.post_hint_opt",
"Pulse.Syntax.Base.ppname",
"Pulse.Syntax.Base.term",
"FStar.Pervasives.Native.option",
"Pulse.Syntax.Base.qualifier",
"FStar.Stubs.TypeChecker.Core.tot_or_ghost",
"Pulse.Typing.typing",
"FStar.Pervasives.Native.tuple3",
"Pulse.Syntax.Base.binder",
"Pulse.Syntax.Base.comp",
"Prims.eq2",
"FStar.Pervasives.Native.Some",
"Pulse.Syntax.Pure.is_arrow",
"FStar.Sealed.Inhabited.sealed",
"Prims.list",
"Prims.Nil",
"Prims.op_disEquality",
"Pulse.Typing.Env.fail",
"Pulse.Checker.Base.checker_result_t",
"Prims.string",
"FStar.Printf.sprintf",
"Pulse.Syntax.Printer.term_to_string",
"Prims.bool",
"Pulse.Syntax.Base.st_term",
"Pulse.Syntax.Base.comp_st",
"Pulse.Typing.st_typing",
"Pulse.Checker.Prover.prove_post_hint",
"FStar.Pervasives.Native.None",
"Pulse.Typing.post_hint_t",
"Pulse.Checker.Prover.try_frame_pre_uvs",
"FStar.Pervasives.Mkdtuple3",
"Pulse.Typing.Env.push_env",
"Prims.unit",
"Pulse.Checker.STApp.debug_log",
"FStar.Stubs.Tactics.V2.Builtins.print",
"Pulse.Show.show",
"Pulse.Show.uu___33",
"FStar.Pervasives.dtuple3",
"Pulse.Checker.Base.match_comp_res_with_post_hint",
"Pulse.Syntax.Base.st_comp",
"Pulse.Checker.STApp.canon_comp",
"Pulse.Syntax.Naming.open_comp_with",
"Pulse.Syntax.Base.Mkst_term",
"Pulse.Syntax.Base.Tm_STApp",
"Pulse.Syntax.Base.Mkst_term'__Tm_STApp__payload",
"Pulse.Syntax.Base.as_effect_hint",
"Pulse.Syntax.Base.ctag_of_comp_st",
"Pulse.Typing.wr",
"Pulse.Checker.STApp.canonicalize_st_typing",
"Pulse.Typing.T_STApp",
"Pulse.Syntax.Base.observability",
"Pulse.Syntax.Base.STT_Ghost",
"Pulse.Typing.T_STGhostApp",
"Pulse.Typing.lift_typing_to_ghost_typing",
"Pulse.Typing.E",
"FStar.Reflection.Typing.non_informative",
"Pulse.Typing.elab_env",
"Pulse.Typing.Env.push_binding",
"Pulse.Syntax.Base.ppname_default",
"Pulse.Elaborate.Pure.elab_comp",
"Pulse.Syntax.Pure.null_var",
"Pulse.Syntax.Printer.comp_to_string",
"FStar.Stubs.Tactics.Types.non_informative_token",
"FStar.Reflection.Typing.Non_informative_token",
"FStar.Squash.return_squash",
"Pulse.Checker.Pure.is_non_informative",
"FStar.Set.mem",
"Pulse.Syntax.Base.var",
"Pulse.Syntax.Naming.freevars_comp",
"Prims.l_not",
"Prims.b2t",
"Pulse.Typing.Env.dom",
"Pulse.Typing.Env.fresh",
"Prims.dtuple2",
"Pulse.Checker.Pure.check_term",
"FStar.Stubs.TypeChecker.Core.E_Ghost",
"FStar.Stubs.TypeChecker.Core.E_Total",
"Prims.op_AmpAmp",
"Prims.op_Negation",
"Prims.op_Equality",
"Pulse.Syntax.Base.uu___is_C_STGhost",
"Pulse.Syntax.Pure.is_arrow_tm_arrow",
"Prims._assert",
"Pulse.Typing.Env.env_extends"
] |
[] | false | true | false | false | false |
let apply_impure_function
(range: range)
(g0: env)
(uvs: _)
(g: env{extends_with g g0 uvs})
(ctxt: vprop)
(ctxt_typing: tot_typing g0 ctxt tm_vprop)
(post_hint: post_hint_opt g0)
(res_ppname: ppname)
(head: term)
(qual: option qualifier)
(arg ty_head: term)
(eff_head: _)
(dhead: typing g head eff_head ty_head)
(b: (binder & option qualifier & comp){Some b == is_arrow ty_head})
: T.Tac (checker_result_t g0 ctxt post_hint) =
|
let { binder_ty = formal ; binder_ppname = ppname }, bqual, comp_typ = b in
assert (g `env_extends` g0);
let post_hint:post_hint_opt g = post_hint in
is_arrow_tm_arrow ty_head;
debug_log g
(fun _ ->
T.print (Printf.sprintf "st_app, head=%s, arg=%s, readback comp as %s\n"
(P.term_to_string head)
(P.term_to_string arg)
(P.comp_to_string comp_typ)));
let allow_ghost = C_STGhost? comp_typ in
if (not allow_ghost) && eff_head = T.E_Ghost
then
fail g
(Some range)
(Printf.sprintf "head term %s is ghost, but the arrow comp is not STGhost"
(P.term_to_string head));
if qual <> bqual
then
(fail g
(Some range)
(Printf.sprintf "Unexpected qualifier in head type %s of stateful application: head = %s, arg = %s"
(P.term_to_string ty_head)
(P.term_to_string head)
(P.term_to_string arg)))
else
(let eff_arg = if allow_ghost then T.E_Ghost else T.E_Total in
let (| arg , darg |) = check_term g arg eff_arg formal in
let (| t , c , d |):(t: st_term & c: comp_st & st_typing g t c) =
match comp_typ with
| C_ST res
| C_STAtomic _ _ res ->
let d:st_typing _ _ (open_comp_with comp_typ arg) =
T_STApp g head formal qual comp_typ arg dhead darg
in
let d = canonicalize_st_typing d in
let t =
{
term = Tm_STApp ({ head = head; arg_qual = qual; arg = arg });
range = range;
effect_tag = as_effect_hint (ctag_of_comp_st comp_typ)
}
in
let c = (canon_comp (open_comp_with comp_typ arg)) in
(| t, c, d |)
| C_STGhost res ->
let x = fresh g in
if x `Set.mem` (freevars_comp (comp_typ))
then fail g (Some range) ("Unexpected clash of variable names, please file a bug-report");
let d_non_info =
let token =
is_non_informative (push_binding g x ppname_default formal)
(open_comp_with comp_typ (null_var x))
in
match token with
| None ->
fail g
(Some range)
(Printf.sprintf "Unexpected non-informative result for %s" (P.comp_to_string comp_typ)
)
| Some token -> RT.Non_informative_token _ _ (FStar.Squash.return_squash token)
in
let d:st_typing _ _ (open_comp_with comp_typ arg) =
T_STGhostApp g
head
formal
qual
comp_typ
arg
x
(lift_typing_to_ghost_typing dhead)
(E d_non_info)
(lift_typing_to_ghost_typing darg)
in
let d = canonicalize_st_typing d in
let t =
{
term = Tm_STApp ({ head = head; arg_qual = qual; arg = arg });
range = range;
effect_tag = as_effect_hint STT_Ghost
}
in
let c = (canon_comp (open_comp_with comp_typ arg)) in
(| t, c, d |)
| _ ->
fail g
(Some range)
"Expected an effectful application; got a pure term (could it be partially applied by mistake?)"
in
let (| st' , c' , st_typing' |) = match_comp_res_with_post_hint d post_hint in
debug_log g (fun _ -> T.print (Printf.sprintf "st_app: c' = %s\n" (show #comp c')));
let framed = Prover.try_frame_pre_uvs ctxt_typing uvs (| st', c', st_typing' |) res_ppname in
Prover.prove_post_hint framed post_hint range)
| false |
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.f64_as_nat
|
val f64_as_nat (h: mem) (e: felem M64) : GTot nat
|
val f64_as_nat (h: mem) (e: felem M64) : GTot nat
|
let f64_as_nat (h:mem) (e: felem M64) : GTot nat =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
Hacl.Spec.Curve25519.Field64.Definition.as_nat4 (s0, s1, s2, s3)
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 66,
"end_line": 106,
"start_col": 0,
"start_line": 100
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
unfold noextract
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
unfold noextract
let nwide (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 8ul
inline_for_extraction noextract
let felem (s:field_spec) = lbuffer (limb s) (nlimb s)
inline_for_extraction noextract
let felem2 (s:field_spec) = lbuffer (limb s) (nlimb s +. nlimb s)
inline_for_extraction noextract
let felem_wide (s:field_spec) = lbuffer (wide s) (nwide s)
inline_for_extraction noextract
let felem_wide2 (s:field_spec) = lbuffer (wide s) (nwide s +. nwide s)
/// Introduce representation for each field + helpers to be able to state pre & posts
/// ---------------------------------------------------------------------------------
noextract
let f51_as_felem (h:mem) (f:felem M51) : GTot Hacl.Spec.Curve25519.Field51.Definition.felem5 =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
(s0, s1, s2, s3, s4)
let f51_as_nat h e = Hacl.Spec.Curve25519.Field51.Definition.as_nat5 (f51_as_felem h e)
noextract
let f51_felem_fits (h:mem) (f:felem M51) (m:Hacl.Spec.Curve25519.Field51.Definition.scale64_5): Type0 =
Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 (f51_as_felem h f) m
noextract
let f51_felem_fits1 = Hacl.Spec.Curve25519.Field51.Definition.felem_fits1
noextract
let f51_mul_inv_t (h:mem) (f:felem M51) : GTot Type0 =
let f = f51_as_felem h f in
Hacl.Spec.Curve25519.Field51.mul_inv_t f
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
h: FStar.Monotonic.HyperStack.mem ->
e: Hacl.Impl.Curve25519.Fields.Core.felem Hacl.Impl.Curve25519.Fields.Core.M64
-> Prims.GTot Prims.nat
|
Prims.GTot
|
[
"sometrivial"
] |
[] |
[
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Hacl.Impl.Curve25519.Fields.Core.M64",
"Hacl.Spec.Curve25519.Field64.Definition.as_nat4",
"FStar.Pervasives.Native.Mktuple4",
"Lib.IntTypes.uint64",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Prims.eq2",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Sequence.op_String_Access",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Hacl.Impl.Curve25519.Fields.Core.nlimb",
"Lib.Sequence.lseq",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.nat"
] |
[] | false | false | false | false | false |
let f64_as_nat (h: mem) (e: felem M64) : GTot nat =
|
let s = as_seq h e in
let s0 = s.[ 0 ] in
let s1 = s.[ 1 ] in
let s2 = s.[ 2 ] in
let s3 = s.[ 3 ] in
Hacl.Spec.Curve25519.Field64.Definition.as_nat4 (s0, s1, s2, s3)
| false |
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.fsqr_disjoint
|
val fsqr_disjoint (#s: field_spec) (out f1: felem s) (tmp: felem_wide s) : Type0
|
val fsqr_disjoint (#s: field_spec) (out f1: felem s) (tmp: felem_wide s) : Type0
|
let fsqr_disjoint (#s:field_spec) (out f1:felem s) (tmp:felem_wide s): Type0 =
match s with
| M51 -> True
| M64 ->
(disjoint out f1 \/ out == f1) /\
(disjoint out tmp \/ out == tmp) /\
disjoint tmp f1
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 21,
"end_line": 307,
"start_col": 0,
"start_line": 301
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
unfold noextract
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
unfold noextract
let nwide (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 8ul
inline_for_extraction noextract
let felem (s:field_spec) = lbuffer (limb s) (nlimb s)
inline_for_extraction noextract
let felem2 (s:field_spec) = lbuffer (limb s) (nlimb s +. nlimb s)
inline_for_extraction noextract
let felem_wide (s:field_spec) = lbuffer (wide s) (nwide s)
inline_for_extraction noextract
let felem_wide2 (s:field_spec) = lbuffer (wide s) (nwide s +. nwide s)
/// Introduce representation for each field + helpers to be able to state pre & posts
/// ---------------------------------------------------------------------------------
noextract
let f51_as_felem (h:mem) (f:felem M51) : GTot Hacl.Spec.Curve25519.Field51.Definition.felem5 =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
(s0, s1, s2, s3, s4)
let f51_as_nat h e = Hacl.Spec.Curve25519.Field51.Definition.as_nat5 (f51_as_felem h e)
noextract
let f51_felem_fits (h:mem) (f:felem M51) (m:Hacl.Spec.Curve25519.Field51.Definition.scale64_5): Type0 =
Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 (f51_as_felem h f) m
noextract
let f51_felem_fits1 = Hacl.Spec.Curve25519.Field51.Definition.felem_fits1
noextract
let f51_mul_inv_t (h:mem) (f:felem M51) : GTot Type0 =
let f = f51_as_felem h f in
Hacl.Spec.Curve25519.Field51.mul_inv_t f
noextract
let f64_as_nat (h:mem) (e: felem M64) : GTot nat =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
Hacl.Spec.Curve25519.Field64.Definition.as_nat4 (s0, s1, s2, s3)
noextract
let as_nat (#s:field_spec) (h:mem) (e:felem s): GTot nat =
match s with
| M51 -> f51_as_nat h e
| M64 -> f64_as_nat h e
noextract
let feval (#s:field_spec) (h:mem) (e:felem s): GTot P.elem =
(as_nat h e) % P.prime
/// Start of core combinators
/// -------------------------
let fadd_fsub_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:felem s): Type0 =
match s with
| M51 ->
f51_felem_fits h f1 (1, 2, 1, 1, 1) /\
f51_felem_fits h f2 (1, 2, 1, 1, 1)
| M64 -> True
let fadd_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (2, 4, 2, 2, 2)
| M64 -> True
inline_for_extraction
let fadd_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint f1 f2 \/ f1 == f2) /\
fadd_fsub_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fadd_post h1 out /\
feval h1 out == P.fadd (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize]
val fadd: #s:field_spec -> fadd_t s True
let fsub_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (9, 10, 9, 9, 9)
| M64 -> True
inline_for_extraction
let fsub_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint f1 f2 \/ f1 == f2) /\
fadd_fsub_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fsub_post h1 out /\
feval h1 out == P.fsub (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize ]
val fsub: #s:field_spec -> fsub_t s True
let fmul_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:felem s): Type0 =
match s with
| M51 ->
f51_felem_fits h f1 (9, 10, 9, 9, 9) /\
f51_felem_fits h f2 (9, 10, 9, 9, 9)
| M64 -> True
let fmul_disjoint (#s:field_spec) (out f1 f2:felem s) (tmp:felem_wide2 s): Type0 =
match s with
| M51 -> True
| M64 ->
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint out tmp \/ out == tmp) /\
(disjoint f1 f2 \/ f1 == f2) /\
disjoint f1 tmp /\
disjoint f2 tmp
let state_inv_t (#s:field_spec) (h:mem) (f:felem s): Type0 =
match s with
| M51 -> f51_mul_inv_t h f
| M64 -> True
inline_for_extraction
let fmul_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> tmp:felem_wide2 s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\ live h tmp /\
fmul_disjoint out f1 f2 tmp /\
fmul_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out |+| loc tmp) h0 h1 /\ state_inv_t h1 out /\
feval h1 out == P.fmul (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize ]
val fmul: #s:field_spec -> fmul_t s True
let fmul2_pre (#s:field_spec) (h:mem) (f1:felem2 s) (f2:felem2 s): Type0 =
match s with
| M51 ->
let f10 = gsub f1 0ul 5ul in
let f11 = gsub f1 5ul 5ul in
let f20 = gsub f2 0ul 5ul in
let f21 = gsub f2 5ul 5ul in
f51_felem_fits h f10 (9, 10, 9, 9, 9) /\
f51_felem_fits h f11 (9, 10, 9, 9, 9) /\
f51_felem_fits h f20 (9, 10, 9, 9, 9) /\
f51_felem_fits h f21 (9, 10, 9, 9, 9)
| M64 -> True
let fmul2_fsqr2_post (#s:field_spec) (h:mem) (out:felem2 s): Type0 =
match s with
| M51 ->
let out0 = gsub out 0ul 5ul in
let out1 = gsub out 5ul 5ul in
f51_mul_inv_t h out0 /\
f51_mul_inv_t h out1
| M64 -> True
inline_for_extraction
let fmul2_t (s:field_spec) (p: Type0) =
out:felem2 s
-> f1:felem2 s
-> f2:felem2 s
-> tmp:felem_wide2 s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\ live h tmp /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint out tmp) /\
(disjoint f1 f2 \/ f1 == f2) /\
disjoint f1 tmp /\
disjoint f2 tmp /\
fmul2_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out |+| loc tmp) h0 h1 /\ fmul2_fsqr2_post h1 out /\
(let out0 = gsub out 0ul (nlimb s) in
let out1 = gsub out (nlimb s) (nlimb s) in
let f10 = gsub f1 0ul (nlimb s) in
let f11 = gsub f1 (nlimb s) (nlimb s) in
let f20 = gsub f2 0ul (nlimb s) in
let f21 = gsub f2 (nlimb s) (nlimb s) in
feval h1 out0 == P.fmul (feval h0 f10) (feval h0 f20) /\
feval h1 out1 == P.fmul (feval h0 f11) (feval h0 f21)))
[@ Meta.Attribute.specialize ]
val fmul2: #s:field_spec -> fmul2_t s True
let fmul1_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:uint64): Type0 =
match s with
| M51 -> f51_felem_fits h f1 (9, 10, 9, 9, 9) /\ f51_felem_fits1 f2 1
| M64 -> v f2 < pow2 17
inline_for_extraction
let fmul1_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:uint64
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\
(disjoint out f1 \/ out == f1) /\
fmul1_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ state_inv_t h1 out /\
feval h1 out == P.fmul (feval h0 f1) (v f2))
// feval h1 out == (feval h0 f1 * v f2) % P.prime)
[@ Meta.Attribute.specialize ]
val fmul1: #s:field_spec -> fmul1_t s True
let fsqr_pre (#s:field_spec) (h:mem) (f:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h f (9, 10, 9, 9, 9)
| M64 -> True
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
out: Hacl.Impl.Curve25519.Fields.Core.felem s ->
f1: Hacl.Impl.Curve25519.Fields.Core.felem s ->
tmp: Hacl.Impl.Curve25519.Fields.Core.felem_wide s
-> Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Hacl.Impl.Curve25519.Fields.Core.felem_wide",
"Prims.l_True",
"Prims.l_and",
"Prims.l_or",
"Lib.Buffer.disjoint",
"Lib.Buffer.MUT",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Prims.eq2",
"Hacl.Impl.Curve25519.Fields.Core.wide",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Buffer.trivial_preorder",
"Prims.int",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Lib.IntTypes.range",
"Lib.IntTypes.U32",
"Lib.Buffer.length",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"Hacl.Impl.Curve25519.Fields.Core.nwide",
"Hacl.Impl.Curve25519.Fields.Core.nlimb"
] |
[] | false | false | false | false | true |
let fsqr_disjoint (#s: field_spec) (out f1: felem s) (tmp: felem_wide s) : Type0 =
|
match s with
| M51 -> True
| M64 -> (disjoint out f1 \/ out == f1) /\ (disjoint out tmp \/ out == tmp) /\ disjoint tmp f1
| false |
UnionFind.Forest.fst
|
UnionFind.Forest.live
|
val live (#n: nat) (uf: uf_forest n) (h: heap) : Type0
|
val live (#n: nat) (uf: uf_forest n) (h: heap) : Type0
|
let live (#n:nat) (uf:uf_forest n) (h:heap) :Type0 =
(forall (i:id n).{:pattern addr_of (index uf i)} forall (j:id n).{:pattern addr_of (index uf j)}
i <> j ==> addr_of (index uf i) <> addr_of (index uf j)) /\ //all the refs in the forest are distinct
(forall (i:id n).{:pattern (h `contains_a_well_typed` (index uf i))}
h `contains_a_well_typed` (index uf i))
|
{
"file_name": "examples/rel/UnionFind.Forest.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
}
|
{
"end_col": 54,
"end_line": 47,
"start_col": 0,
"start_line": 43
}
|
(*
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 UnionFind.Forest
open FStar.Seq
open FStar.Ghost
open FStar.OrdSet
open FStar.DM4F.Heap
open FStar.DM4F.Heap.ST
module ST = FStar.DM4F.Heap.ST
type subtree_t = ordset nat (fun x y -> x <= y)
let rec set_n (n:nat) :subtree_t =
if n = 0 then empty
else union (singleton n) (set_n (n - 1))
type id (n:nat) = i:nat{i < n}
(*
* each node maintains its parent id, height, and (ghost) subtree nodes (including itself)
* the subtree is used as the decreasing metric in recursive calls
*)
type elt (n:nat) = id n * nat * erased (subtree_t)
type uf_forest (n:nat) = s:seq (ref (elt n)){length s = n}
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.OrdSet.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.DM4F.Heap.ST.fsti.checked",
"FStar.DM4F.Heap.fsti.checked"
],
"interface_file": false,
"source_file": "UnionFind.Forest.fst"
}
|
[
{
"abbrev": true,
"full_module": "FStar.DM4F.Heap.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "UnionFind",
"short_module": null
},
{
"abbrev": false,
"full_module": "UnionFind",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 |
uf: UnionFind.Forest.uf_forest n -> h: FStar.DM4F.Heap.heap -> Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Prims.nat",
"UnionFind.Forest.uf_forest",
"FStar.DM4F.Heap.heap",
"Prims.l_and",
"Prims.l_Forall",
"UnionFind.Forest.id",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_disEquality",
"FStar.DM4F.Heap.addr_of",
"UnionFind.Forest.elt",
"FStar.Seq.Base.index",
"FStar.DM4F.Heap.ref",
"FStar.DM4F.Heap.contains_a_well_typed"
] |
[] | false | false | false | false | true |
let live (#n: nat) (uf: uf_forest n) (h: heap) : Type0 =
|
(forall (i: id n). {:pattern addr_of (index uf i)}
forall (j: id n). {:pattern addr_of (index uf j)}
i <> j ==> addr_of (index uf i) <> addr_of (index uf j)) /\
(forall (i: id n). {:pattern (h `contains_a_well_typed` (index uf i))}
h `contains_a_well_typed` (index uf i))
| false |
UnionFind.Forest.fst
|
UnionFind.Forest.set_n
|
val set_n (n: nat) : subtree_t
|
val set_n (n: nat) : subtree_t
|
let rec set_n (n:nat) :subtree_t =
if n = 0 then empty
else union (singleton n) (set_n (n - 1))
|
{
"file_name": "examples/rel/UnionFind.Forest.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
}
|
{
"end_col": 42,
"end_line": 30,
"start_col": 0,
"start_line": 28
}
|
(*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module UnionFind.Forest
open FStar.Seq
open FStar.Ghost
open FStar.OrdSet
open FStar.DM4F.Heap
open FStar.DM4F.Heap.ST
module ST = FStar.DM4F.Heap.ST
type subtree_t = ordset nat (fun x y -> x <= y)
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.OrdSet.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.DM4F.Heap.ST.fsti.checked",
"FStar.DM4F.Heap.fsti.checked"
],
"interface_file": false,
"source_file": "UnionFind.Forest.fst"
}
|
[
{
"abbrev": true,
"full_module": "FStar.DM4F.Heap.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "UnionFind",
"short_module": null
},
{
"abbrev": false,
"full_module": "UnionFind",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
n: Prims.nat -> UnionFind.Forest.subtree_t
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Prims.nat",
"Prims.op_Equality",
"Prims.int",
"FStar.OrdSet.empty",
"Prims.op_LessThanOrEqual",
"Prims.bool",
"FStar.OrdSet.union",
"FStar.OrdSet.singleton",
"UnionFind.Forest.set_n",
"Prims.op_Subtraction",
"UnionFind.Forest.subtree_t"
] |
[
"recursion"
] | false | false | false | true | false |
let rec set_n (n: nat) : subtree_t =
|
if n = 0 then empty else union (singleton n) (set_n (n - 1))
| false |
UnionFind.Forest.fst
|
UnionFind.Forest.get
|
val get (#n: nat) (uf: uf_forest n) (i: id n)
: ST (elt n)
(requires (fun h0 -> live uf h0))
(ensures (fun h0 r h1 -> r == sel h0 (index uf i) /\ h0 == h1))
|
val get (#n: nat) (uf: uf_forest n) (i: id n)
: ST (elt n)
(requires (fun h0 -> live uf h0))
(ensures (fun h0 r h1 -> r == sel h0 (index uf i) /\ h0 == h1))
|
let get (#n:nat) (uf:uf_forest n) (i:id n)
:ST (elt n) (requires (fun h0 -> live uf h0))
(ensures (fun h0 r h1 -> r == sel h0 (index uf i) /\ h0 == h1))
= let h = ST.get () in
sel_tot h (index uf i)
|
{
"file_name": "examples/rel/UnionFind.Forest.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
}
|
{
"end_col": 26,
"end_line": 53,
"start_col": 1,
"start_line": 49
}
|
(*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module UnionFind.Forest
open FStar.Seq
open FStar.Ghost
open FStar.OrdSet
open FStar.DM4F.Heap
open FStar.DM4F.Heap.ST
module ST = FStar.DM4F.Heap.ST
type subtree_t = ordset nat (fun x y -> x <= y)
let rec set_n (n:nat) :subtree_t =
if n = 0 then empty
else union (singleton n) (set_n (n - 1))
type id (n:nat) = i:nat{i < n}
(*
* each node maintains its parent id, height, and (ghost) subtree nodes (including itself)
* the subtree is used as the decreasing metric in recursive calls
*)
type elt (n:nat) = id n * nat * erased (subtree_t)
type uf_forest (n:nat) = s:seq (ref (elt n)){length s = n}
(* liveness and separation condition for the unionfind forest *)
let live (#n:nat) (uf:uf_forest n) (h:heap) :Type0 =
(forall (i:id n).{:pattern addr_of (index uf i)} forall (j:id n).{:pattern addr_of (index uf j)}
i <> j ==> addr_of (index uf i) <> addr_of (index uf j)) /\ //all the refs in the forest are distinct
(forall (i:id n).{:pattern (h `contains_a_well_typed` (index uf i))}
h `contains_a_well_typed` (index uf i)) //all the refs in the forest are well typed
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.OrdSet.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.DM4F.Heap.ST.fsti.checked",
"FStar.DM4F.Heap.fsti.checked"
],
"interface_file": false,
"source_file": "UnionFind.Forest.fst"
}
|
[
{
"abbrev": true,
"full_module": "FStar.DM4F.Heap.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "UnionFind",
"short_module": null
},
{
"abbrev": false,
"full_module": "UnionFind",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 |
uf: UnionFind.Forest.uf_forest n -> i: UnionFind.Forest.id n
-> FStar.DM4F.Heap.ST.ST (UnionFind.Forest.elt n)
|
FStar.DM4F.Heap.ST.ST
|
[] |
[] |
[
"Prims.nat",
"UnionFind.Forest.uf_forest",
"UnionFind.Forest.id",
"FStar.DM4F.Heap.sel_tot",
"UnionFind.Forest.elt",
"FStar.Seq.Base.index",
"FStar.DM4F.Heap.ref",
"FStar.DM4F.Heap.heap",
"FStar.DM4F.Heap.ST.get",
"UnionFind.Forest.live",
"Prims.l_and",
"Prims.eq2",
"FStar.DM4F.Heap.sel"
] |
[] | false | true | false | false | false |
let get (#n: nat) (uf: uf_forest n) (i: id n)
: ST (elt n)
(requires (fun h0 -> live uf h0))
(ensures (fun h0 r h1 -> r == sel h0 (index uf i) /\ h0 == h1)) =
|
let h = ST.get () in
sel_tot h (index uf i)
| false |
UnionFind.Forest.fst
|
UnionFind.Forest.set
|
val set (#n: nat) (uf: uf_forest n) (i: id n) (elt: elt n)
: ST unit
(requires (fun h0 -> live uf h0))
(ensures (fun h0 _ h1 -> h1 == upd h0 (index uf i) elt))
|
val set (#n: nat) (uf: uf_forest n) (i: id n) (elt: elt n)
: ST unit
(requires (fun h0 -> live uf h0))
(ensures (fun h0 _ h1 -> h1 == upd h0 (index uf i) elt))
|
let set (#n:nat) (uf:uf_forest n) (i:id n) (elt:elt n)
:ST unit (requires (fun h0 -> live uf h0))
(ensures (fun h0 _ h1 -> h1 == upd h0 (index uf i) elt))
= let h0 = ST.get () in
ST.put (upd_tot h0 (index uf i) elt)
|
{
"file_name": "examples/rel/UnionFind.Forest.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
}
|
{
"end_col": 40,
"end_line": 59,
"start_col": 1,
"start_line": 55
}
|
(*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module UnionFind.Forest
open FStar.Seq
open FStar.Ghost
open FStar.OrdSet
open FStar.DM4F.Heap
open FStar.DM4F.Heap.ST
module ST = FStar.DM4F.Heap.ST
type subtree_t = ordset nat (fun x y -> x <= y)
let rec set_n (n:nat) :subtree_t =
if n = 0 then empty
else union (singleton n) (set_n (n - 1))
type id (n:nat) = i:nat{i < n}
(*
* each node maintains its parent id, height, and (ghost) subtree nodes (including itself)
* the subtree is used as the decreasing metric in recursive calls
*)
type elt (n:nat) = id n * nat * erased (subtree_t)
type uf_forest (n:nat) = s:seq (ref (elt n)){length s = n}
(* liveness and separation condition for the unionfind forest *)
let live (#n:nat) (uf:uf_forest n) (h:heap) :Type0 =
(forall (i:id n).{:pattern addr_of (index uf i)} forall (j:id n).{:pattern addr_of (index uf j)}
i <> j ==> addr_of (index uf i) <> addr_of (index uf j)) /\ //all the refs in the forest are distinct
(forall (i:id n).{:pattern (h `contains_a_well_typed` (index uf i))}
h `contains_a_well_typed` (index uf i)) //all the refs in the forest are well typed
let get (#n:nat) (uf:uf_forest n) (i:id n)
:ST (elt n) (requires (fun h0 -> live uf h0))
(ensures (fun h0 r h1 -> r == sel h0 (index uf i) /\ h0 == h1))
= let h = ST.get () in
sel_tot h (index uf i)
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.OrdSet.fsti.checked",
"FStar.Ghost.fsti.checked",
"FStar.DM4F.Heap.ST.fsti.checked",
"FStar.DM4F.Heap.fsti.checked"
],
"interface_file": false,
"source_file": "UnionFind.Forest.fst"
}
|
[
{
"abbrev": true,
"full_module": "FStar.DM4F.Heap.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.OrdSet",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "UnionFind",
"short_module": null
},
{
"abbrev": false,
"full_module": "UnionFind",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 |
uf: UnionFind.Forest.uf_forest n -> i: UnionFind.Forest.id n -> elt: UnionFind.Forest.elt n
-> FStar.DM4F.Heap.ST.ST Prims.unit
|
FStar.DM4F.Heap.ST.ST
|
[] |
[] |
[
"Prims.nat",
"UnionFind.Forest.uf_forest",
"UnionFind.Forest.id",
"UnionFind.Forest.elt",
"FStar.DM4F.Heap.ST.put",
"FStar.DM4F.Heap.upd_tot",
"FStar.Seq.Base.index",
"FStar.DM4F.Heap.ref",
"Prims.unit",
"FStar.DM4F.Heap.heap",
"FStar.DM4F.Heap.ST.get",
"UnionFind.Forest.live",
"Prims.eq2",
"FStar.DM4F.Heap.upd"
] |
[] | false | true | false | false | false |
let set (#n: nat) (uf: uf_forest n) (i: id n) (elt: elt n)
: ST unit
(requires (fun h0 -> live uf h0))
(ensures (fun h0 _ h1 -> h1 == upd h0 (index uf i) elt)) =
|
let h0 = ST.get () in
ST.put (upd_tot h0 (index uf i) elt)
| false |
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.f51_as_felem
|
val f51_as_felem (h: mem) (f: felem M51) : GTot Hacl.Spec.Curve25519.Field51.Definition.felem5
|
val f51_as_felem (h: mem) (f: felem M51) : GTot Hacl.Spec.Curve25519.Field51.Definition.felem5
|
let f51_as_felem (h:mem) (f:felem M51) : GTot Hacl.Spec.Curve25519.Field51.Definition.felem5 =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
(s0, s1, s2, s3, s4)
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 22,
"end_line": 83,
"start_col": 0,
"start_line": 76
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
unfold noextract
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
unfold noextract
let nwide (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 8ul
inline_for_extraction noextract
let felem (s:field_spec) = lbuffer (limb s) (nlimb s)
inline_for_extraction noextract
let felem2 (s:field_spec) = lbuffer (limb s) (nlimb s +. nlimb s)
inline_for_extraction noextract
let felem_wide (s:field_spec) = lbuffer (wide s) (nwide s)
inline_for_extraction noextract
let felem_wide2 (s:field_spec) = lbuffer (wide s) (nwide s +. nwide s)
/// Introduce representation for each field + helpers to be able to state pre & posts
/// ---------------------------------------------------------------------------------
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
h: FStar.Monotonic.HyperStack.mem ->
f: Hacl.Impl.Curve25519.Fields.Core.felem Hacl.Impl.Curve25519.Fields.Core.M51
-> Prims.GTot Hacl.Spec.Curve25519.Field51.Definition.felem5
|
Prims.GTot
|
[
"sometrivial"
] |
[] |
[
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Hacl.Impl.Curve25519.Fields.Core.M51",
"FStar.Pervasives.Native.Mktuple5",
"Lib.IntTypes.uint64",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Prims.eq2",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Sequence.op_String_Access",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Hacl.Impl.Curve25519.Fields.Core.nlimb",
"Lib.Sequence.lseq",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Hacl.Spec.Curve25519.Field51.Definition.felem5"
] |
[] | false | false | false | false | false |
let f51_as_felem (h: mem) (f: felem M51) : GTot Hacl.Spec.Curve25519.Field51.Definition.felem5 =
|
let s = as_seq h f in
let s0 = s.[ 0 ] in
let s1 = s.[ 1 ] in
let s2 = s.[ 2 ] in
let s3 = s.[ 3 ] in
let s4 = s.[ 4 ] in
(s0, s1, s2, s3, s4)
| false |
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.fmul2_pre
|
val fmul2_pre (#s: field_spec) (h: mem) (f1 f2: felem2 s) : Type0
|
val fmul2_pre (#s: field_spec) (h: mem) (f1 f2: felem2 s) : Type0
|
let fmul2_pre (#s:field_spec) (h:mem) (f1:felem2 s) (f2:felem2 s): Type0 =
match s with
| M51 ->
let f10 = gsub f1 0ul 5ul in
let f11 = gsub f1 5ul 5ul in
let f20 = gsub f2 0ul 5ul in
let f21 = gsub f2 5ul 5ul in
f51_felem_fits h f10 (9, 10, 9, 9, 9) /\
f51_felem_fits h f11 (9, 10, 9, 9, 9) /\
f51_felem_fits h f20 (9, 10, 9, 9, 9) /\
f51_felem_fits h f21 (9, 10, 9, 9, 9)
| M64 -> True
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 15,
"end_line": 230,
"start_col": 0,
"start_line": 219
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
unfold noextract
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
unfold noextract
let nwide (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 8ul
inline_for_extraction noextract
let felem (s:field_spec) = lbuffer (limb s) (nlimb s)
inline_for_extraction noextract
let felem2 (s:field_spec) = lbuffer (limb s) (nlimb s +. nlimb s)
inline_for_extraction noextract
let felem_wide (s:field_spec) = lbuffer (wide s) (nwide s)
inline_for_extraction noextract
let felem_wide2 (s:field_spec) = lbuffer (wide s) (nwide s +. nwide s)
/// Introduce representation for each field + helpers to be able to state pre & posts
/// ---------------------------------------------------------------------------------
noextract
let f51_as_felem (h:mem) (f:felem M51) : GTot Hacl.Spec.Curve25519.Field51.Definition.felem5 =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
(s0, s1, s2, s3, s4)
let f51_as_nat h e = Hacl.Spec.Curve25519.Field51.Definition.as_nat5 (f51_as_felem h e)
noextract
let f51_felem_fits (h:mem) (f:felem M51) (m:Hacl.Spec.Curve25519.Field51.Definition.scale64_5): Type0 =
Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 (f51_as_felem h f) m
noextract
let f51_felem_fits1 = Hacl.Spec.Curve25519.Field51.Definition.felem_fits1
noextract
let f51_mul_inv_t (h:mem) (f:felem M51) : GTot Type0 =
let f = f51_as_felem h f in
Hacl.Spec.Curve25519.Field51.mul_inv_t f
noextract
let f64_as_nat (h:mem) (e: felem M64) : GTot nat =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
Hacl.Spec.Curve25519.Field64.Definition.as_nat4 (s0, s1, s2, s3)
noextract
let as_nat (#s:field_spec) (h:mem) (e:felem s): GTot nat =
match s with
| M51 -> f51_as_nat h e
| M64 -> f64_as_nat h e
noextract
let feval (#s:field_spec) (h:mem) (e:felem s): GTot P.elem =
(as_nat h e) % P.prime
/// Start of core combinators
/// -------------------------
let fadd_fsub_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:felem s): Type0 =
match s with
| M51 ->
f51_felem_fits h f1 (1, 2, 1, 1, 1) /\
f51_felem_fits h f2 (1, 2, 1, 1, 1)
| M64 -> True
let fadd_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (2, 4, 2, 2, 2)
| M64 -> True
inline_for_extraction
let fadd_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint f1 f2 \/ f1 == f2) /\
fadd_fsub_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fadd_post h1 out /\
feval h1 out == P.fadd (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize]
val fadd: #s:field_spec -> fadd_t s True
let fsub_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (9, 10, 9, 9, 9)
| M64 -> True
inline_for_extraction
let fsub_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint f1 f2 \/ f1 == f2) /\
fadd_fsub_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fsub_post h1 out /\
feval h1 out == P.fsub (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize ]
val fsub: #s:field_spec -> fsub_t s True
let fmul_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:felem s): Type0 =
match s with
| M51 ->
f51_felem_fits h f1 (9, 10, 9, 9, 9) /\
f51_felem_fits h f2 (9, 10, 9, 9, 9)
| M64 -> True
let fmul_disjoint (#s:field_spec) (out f1 f2:felem s) (tmp:felem_wide2 s): Type0 =
match s with
| M51 -> True
| M64 ->
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint out tmp \/ out == tmp) /\
(disjoint f1 f2 \/ f1 == f2) /\
disjoint f1 tmp /\
disjoint f2 tmp
let state_inv_t (#s:field_spec) (h:mem) (f:felem s): Type0 =
match s with
| M51 -> f51_mul_inv_t h f
| M64 -> True
inline_for_extraction
let fmul_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> tmp:felem_wide2 s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\ live h tmp /\
fmul_disjoint out f1 f2 tmp /\
fmul_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out |+| loc tmp) h0 h1 /\ state_inv_t h1 out /\
feval h1 out == P.fmul (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize ]
val fmul: #s:field_spec -> fmul_t s True
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
h: FStar.Monotonic.HyperStack.mem ->
f1: Hacl.Impl.Curve25519.Fields.Core.felem2 s ->
f2: Hacl.Impl.Curve25519.Fields.Core.felem2 s
-> Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Curve25519.Fields.Core.felem2",
"Prims.l_and",
"Hacl.Impl.Curve25519.Fields.Core.f51_felem_fits",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.gsub",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Lib.IntTypes.op_Plus_Dot",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Curve25519.Fields.Core.nlimb",
"FStar.UInt32.__uint_to_t",
"Prims.l_True"
] |
[] | false | false | false | false | true |
let fmul2_pre (#s: field_spec) (h: mem) (f1 f2: felem2 s) : Type0 =
|
match s with
| M51 ->
let f10 = gsub f1 0ul 5ul in
let f11 = gsub f1 5ul 5ul in
let f20 = gsub f2 0ul 5ul in
let f21 = gsub f2 5ul 5ul in
f51_felem_fits h f10 (9, 10, 9, 9, 9) /\ f51_felem_fits h f11 (9, 10, 9, 9, 9) /\
f51_felem_fits h f20 (9, 10, 9, 9, 9) /\ f51_felem_fits h f21 (9, 10, 9, 9, 9)
| M64 -> True
| false |
DependentTuples.fst
|
DependentTuples.exists_n
|
val exists_n (r: ref nat) : vprop
|
val exists_n (r: ref nat) : vprop
|
let exists_n (r:ref nat) : vprop = exists* n. pts_to r n
|
{
"file_name": "share/steel/examples/pulse/bug-reports/DependentTuples.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
}
|
{
"end_col": 56,
"end_line": 22,
"start_col": 0,
"start_line": 22
}
|
(*
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 DependentTuples
open Pulse.Lib.Pervasives
open Pulse.Lib.Reference
open Pulse.Lib.SpinLock
|
{
"checked_file": "/",
"dependencies": [
"Pulse.Lib.SpinLock.fsti.checked",
"Pulse.Lib.Reference.fsti.checked",
"Pulse.Lib.Pervasives.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "DependentTuples.fst"
}
|
[
{
"abbrev": false,
"full_module": "Pulse.Lib.SpinLock",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
r: Pulse.Lib.Reference.ref Prims.nat -> Pulse.Lib.Core.vprop
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Pulse.Lib.Reference.ref",
"Prims.nat",
"Pulse.Lib.Core.op_exists_Star",
"Pulse.Lib.Reference.pts_to",
"PulseCore.FractionalPermission.full_perm",
"Pulse.Lib.Core.vprop"
] |
[] | false | false | false | true | false |
let exists_n (r: ref nat) : vprop =
|
exists* n. pts_to r n
| false |
Lib.IntVector.Transpose.fst
|
Lib.IntVector.Transpose.transpose4x4_uint64
|
val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
|
val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
|
let transpose4x4_uint64 #t vs = transpose4x4_0 #t vs
|
{
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 52,
"end_line": 36,
"start_col": 0,
"start_line": 36
}
|
module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction
val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'')
inline_for_extraction
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
}
|
[
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"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": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 |
vs: Lib.IntVector.Transpose.vec_t4 t -> Lib.IntVector.Transpose.vec_t4 t
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Lib.IntVector.v_inttype",
"Prims.eq2",
"Lib.IntTypes.inttype",
"Lib.IntTypes.U64",
"Lib.IntVector.Transpose.vec_t4",
"Lib.IntVector.Transpose.transpose4x4_0"
] |
[] | false | false | false | false | false |
let transpose4x4_uint64 #t vs =
|
transpose4x4_0 #t vs
| false |
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.fsqr_pre
|
val fsqr_pre (#s: field_spec) (h: mem) (f: felem s) : Type0
|
val fsqr_pre (#s: field_spec) (h: mem) (f: felem s) : Type0
|
let fsqr_pre (#s:field_spec) (h:mem) (f:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h f (9, 10, 9, 9, 9)
| M64 -> True
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 15,
"end_line": 299,
"start_col": 0,
"start_line": 296
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
unfold noextract
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
unfold noextract
let nwide (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 8ul
inline_for_extraction noextract
let felem (s:field_spec) = lbuffer (limb s) (nlimb s)
inline_for_extraction noextract
let felem2 (s:field_spec) = lbuffer (limb s) (nlimb s +. nlimb s)
inline_for_extraction noextract
let felem_wide (s:field_spec) = lbuffer (wide s) (nwide s)
inline_for_extraction noextract
let felem_wide2 (s:field_spec) = lbuffer (wide s) (nwide s +. nwide s)
/// Introduce representation for each field + helpers to be able to state pre & posts
/// ---------------------------------------------------------------------------------
noextract
let f51_as_felem (h:mem) (f:felem M51) : GTot Hacl.Spec.Curve25519.Field51.Definition.felem5 =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
(s0, s1, s2, s3, s4)
let f51_as_nat h e = Hacl.Spec.Curve25519.Field51.Definition.as_nat5 (f51_as_felem h e)
noextract
let f51_felem_fits (h:mem) (f:felem M51) (m:Hacl.Spec.Curve25519.Field51.Definition.scale64_5): Type0 =
Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 (f51_as_felem h f) m
noextract
let f51_felem_fits1 = Hacl.Spec.Curve25519.Field51.Definition.felem_fits1
noextract
let f51_mul_inv_t (h:mem) (f:felem M51) : GTot Type0 =
let f = f51_as_felem h f in
Hacl.Spec.Curve25519.Field51.mul_inv_t f
noextract
let f64_as_nat (h:mem) (e: felem M64) : GTot nat =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
Hacl.Spec.Curve25519.Field64.Definition.as_nat4 (s0, s1, s2, s3)
noextract
let as_nat (#s:field_spec) (h:mem) (e:felem s): GTot nat =
match s with
| M51 -> f51_as_nat h e
| M64 -> f64_as_nat h e
noextract
let feval (#s:field_spec) (h:mem) (e:felem s): GTot P.elem =
(as_nat h e) % P.prime
/// Start of core combinators
/// -------------------------
let fadd_fsub_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:felem s): Type0 =
match s with
| M51 ->
f51_felem_fits h f1 (1, 2, 1, 1, 1) /\
f51_felem_fits h f2 (1, 2, 1, 1, 1)
| M64 -> True
let fadd_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (2, 4, 2, 2, 2)
| M64 -> True
inline_for_extraction
let fadd_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint f1 f2 \/ f1 == f2) /\
fadd_fsub_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fadd_post h1 out /\
feval h1 out == P.fadd (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize]
val fadd: #s:field_spec -> fadd_t s True
let fsub_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (9, 10, 9, 9, 9)
| M64 -> True
inline_for_extraction
let fsub_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint f1 f2 \/ f1 == f2) /\
fadd_fsub_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fsub_post h1 out /\
feval h1 out == P.fsub (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize ]
val fsub: #s:field_spec -> fsub_t s True
let fmul_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:felem s): Type0 =
match s with
| M51 ->
f51_felem_fits h f1 (9, 10, 9, 9, 9) /\
f51_felem_fits h f2 (9, 10, 9, 9, 9)
| M64 -> True
let fmul_disjoint (#s:field_spec) (out f1 f2:felem s) (tmp:felem_wide2 s): Type0 =
match s with
| M51 -> True
| M64 ->
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint out tmp \/ out == tmp) /\
(disjoint f1 f2 \/ f1 == f2) /\
disjoint f1 tmp /\
disjoint f2 tmp
let state_inv_t (#s:field_spec) (h:mem) (f:felem s): Type0 =
match s with
| M51 -> f51_mul_inv_t h f
| M64 -> True
inline_for_extraction
let fmul_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> tmp:felem_wide2 s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\ live h tmp /\
fmul_disjoint out f1 f2 tmp /\
fmul_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out |+| loc tmp) h0 h1 /\ state_inv_t h1 out /\
feval h1 out == P.fmul (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize ]
val fmul: #s:field_spec -> fmul_t s True
let fmul2_pre (#s:field_spec) (h:mem) (f1:felem2 s) (f2:felem2 s): Type0 =
match s with
| M51 ->
let f10 = gsub f1 0ul 5ul in
let f11 = gsub f1 5ul 5ul in
let f20 = gsub f2 0ul 5ul in
let f21 = gsub f2 5ul 5ul in
f51_felem_fits h f10 (9, 10, 9, 9, 9) /\
f51_felem_fits h f11 (9, 10, 9, 9, 9) /\
f51_felem_fits h f20 (9, 10, 9, 9, 9) /\
f51_felem_fits h f21 (9, 10, 9, 9, 9)
| M64 -> True
let fmul2_fsqr2_post (#s:field_spec) (h:mem) (out:felem2 s): Type0 =
match s with
| M51 ->
let out0 = gsub out 0ul 5ul in
let out1 = gsub out 5ul 5ul in
f51_mul_inv_t h out0 /\
f51_mul_inv_t h out1
| M64 -> True
inline_for_extraction
let fmul2_t (s:field_spec) (p: Type0) =
out:felem2 s
-> f1:felem2 s
-> f2:felem2 s
-> tmp:felem_wide2 s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\ live h tmp /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint out tmp) /\
(disjoint f1 f2 \/ f1 == f2) /\
disjoint f1 tmp /\
disjoint f2 tmp /\
fmul2_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out |+| loc tmp) h0 h1 /\ fmul2_fsqr2_post h1 out /\
(let out0 = gsub out 0ul (nlimb s) in
let out1 = gsub out (nlimb s) (nlimb s) in
let f10 = gsub f1 0ul (nlimb s) in
let f11 = gsub f1 (nlimb s) (nlimb s) in
let f20 = gsub f2 0ul (nlimb s) in
let f21 = gsub f2 (nlimb s) (nlimb s) in
feval h1 out0 == P.fmul (feval h0 f10) (feval h0 f20) /\
feval h1 out1 == P.fmul (feval h0 f11) (feval h0 f21)))
[@ Meta.Attribute.specialize ]
val fmul2: #s:field_spec -> fmul2_t s True
let fmul1_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:uint64): Type0 =
match s with
| M51 -> f51_felem_fits h f1 (9, 10, 9, 9, 9) /\ f51_felem_fits1 f2 1
| M64 -> v f2 < pow2 17
inline_for_extraction
let fmul1_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:uint64
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\
(disjoint out f1 \/ out == f1) /\
fmul1_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ state_inv_t h1 out /\
feval h1 out == P.fmul (feval h0 f1) (v f2))
// feval h1 out == (feval h0 f1 * v f2) % P.prime)
[@ Meta.Attribute.specialize ]
val fmul1: #s:field_spec -> fmul1_t s True
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
h: FStar.Monotonic.HyperStack.mem -> f: Hacl.Impl.Curve25519.Fields.Core.felem s -> Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Curve25519.Fields.Core.felem",
"Hacl.Impl.Curve25519.Fields.Core.f51_felem_fits",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Prims.l_True"
] |
[] | false | false | false | false | true |
let fsqr_pre (#s: field_spec) (h: mem) (f: felem s) : Type0 =
|
match s with
| M51 -> f51_felem_fits h f (9, 10, 9, 9, 9)
| M64 -> True
| false |
Hacl.Spec.K256.Field52.Definitions.Lemmas.fst
|
Hacl.Spec.K256.Field52.Definitions.Lemmas.lemma_as_nat_bound_f4_lt_powa
|
val lemma_as_nat_bound_f4_lt_powa: f:felem5 -> a:nat -> Lemma
(requires (let (f0,f1,f2,f3,f4) = f in
felem_fits5 f (1,1,1,1,1) /\ v f4 < pow2 a))
(ensures as_nat5 f <= pow2 (208 + a) - 1)
|
val lemma_as_nat_bound_f4_lt_powa: f:felem5 -> a:nat -> Lemma
(requires (let (f0,f1,f2,f3,f4) = f in
felem_fits5 f (1,1,1,1,1) /\ v f4 < pow2 a))
(ensures as_nat5 f <= pow2 (208 + a) - 1)
|
let lemma_as_nat_bound_f4_lt_powa f a =
let (f0,f1,f2,f3,f4) = f in
calc (<=) { //as_nat5 f ==
v f0 + v f1 * pow52 + v f2 * pow104 + v f3 * pow156 + v f4 * pow208;
(<=) { }
pow2 52 - 1 + v f1 * pow52 + v f2 * pow104 + v f3 * pow156 + v f4 * pow208;
(<=) {
Math.Lemmas.lemma_mult_le_right pow52 (v f1) (pow2 52 - 1);
Math.Lemmas.distributivity_sub_left (pow2 52) 1 pow52 }
pow2 52 * pow52 + v f2 * pow104 + v f3 * pow156 + v f4 * pow208 - 1;
(<=) {
Math.Lemmas.lemma_mult_le_right pow104 (v f2) (pow2 52 - 1);
Math.Lemmas.distributivity_sub_left (pow2 52) 1 pow104;
Math.Lemmas.pow2_plus 52 52 }
pow2 52 * pow104 + v f3 * pow156 + v f4 * pow208 - 1;
(<=) {
Math.Lemmas.lemma_mult_le_right pow156 (v f3) (pow2 52 - 1);
Math.Lemmas.distributivity_sub_left (pow2 52) 1 pow156;
Math.Lemmas.pow2_plus 52 104 }
pow2 52 * pow156 + v f4 * pow208 - 1;
(<=) {
Math.Lemmas.lemma_mult_le_right pow208 (v f4) (pow2 a - 1);
Math.Lemmas.distributivity_sub_left (pow2 a) 1 pow208;
Math.Lemmas.pow2_plus 52 156;
Math.Lemmas.pow2_plus a 208 }
pow2 (208 + a) - 1;
}
|
{
"file_name": "code/k256/Hacl.Spec.K256.Field52.Definitions.Lemmas.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 5,
"end_line": 123,
"start_col": 0,
"start_line": 97
}
|
module Hacl.Spec.K256.Field52.Definitions.Lemmas
open FStar.Mul
open Lib.IntTypes
open Hacl.Spec.K256.Field52.Definitions
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
module S = Spec.K256
module ML = Hacl.Spec.K256.MathLemmas
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
val lemma_as_nat_mod2: x:felem5 ->
Lemma (let (x0,x1,x2,x3,x4) = x in as_nat5 x % 2 = v x0 % 2)
let lemma_as_nat_mod2 x =
let (x0,x1,x2,x3,x4) = x in
assert (as_nat5 x = v x0 + v x1 * pow52 + v x2 * pow104 + v x3 * pow156 + v x4 * pow208);
assert (as_nat5 x % 2 = (v x0 + v x1 * pow52 + v x2 * pow104 + v x3 * pow156 + v x4 * pow208) % 2);
ML.lemma_a_plus_b_pow2_mod2 (v x0 + v x1 * pow52 + v x2 * pow104 + v x3 * pow156) (v x4) 208;
ML.lemma_a_plus_b_pow2_mod2 (v x0 + v x1 * pow52 + v x2 * pow104) (v x3) 156;
ML.lemma_a_plus_b_pow2_mod2 (v x0 + v x1 * pow52) (v x2) 104;
ML.lemma_a_plus_b_pow2_mod2 (v x0) (v x1) 52;
assert (as_nat5 x % 2 = v x0 % 2)
val lemma_nat_from_bytes_be_mod2: f:LSeq.lseq uint8 32 ->
Lemma (BSeq.nat_from_bytes_be f % 2 = v (LSeq.index f 31) % 2)
let lemma_nat_from_bytes_be_mod2 f =
let x0 = LSeq.index f 31 in
BSeq.nat_from_intseq_be_slice_lemma f 31;
BSeq.nat_from_intseq_be_lemma0 (LSeq.slice f 31 32);
assert (BSeq.nat_from_intseq_be f == v x0 + pow2 8 * BSeq.nat_from_intseq_be (LSeq.slice f 0 31));
ML.lemma_a_plus_b_pow2_mod2 (v x0) (BSeq.nat_from_intseq_be (LSeq.slice f 0 31)) 8
val unfold_nat_from_uint64_four: b:LSeq.lseq uint64 4 ->
Lemma (BSeq.nat_from_intseq_be b ==
v (LSeq.index b 3) + v (LSeq.index b 2) * pow2 64 +
v (LSeq.index b 1) * pow2 128 + v (LSeq.index b 0) * pow2 192)
let unfold_nat_from_uint64_four b =
let b0 = v (LSeq.index b 0) in
let b1 = v (LSeq.index b 1) in
let b2 = v (LSeq.index b 2) in
let b3 = v (LSeq.index b 3) in
let res = BSeq.nat_from_intseq_be b in
BSeq.nat_from_intseq_be_slice_lemma b 3;
BSeq.nat_from_intseq_be_lemma0 (Seq.slice b 3 4);
assert (res == b3 + pow2 64 * (BSeq.nat_from_intseq_be (Seq.slice b 0 3)));
BSeq.nat_from_intseq_be_slice_lemma #U64 #SEC #3 (Seq.slice b 0 3) 2;
BSeq.nat_from_intseq_be_lemma0 (Seq.slice b 2 3);
assert (BSeq.nat_from_intseq_be (Seq.slice b 0 3) == b2 + pow2 64 * (BSeq.nat_from_intseq_be (Seq.slice b 0 2)));
BSeq.nat_from_intseq_be_slice_lemma #U64 #SEC #2 (Seq.slice b 0 2) 1;
BSeq.nat_from_intseq_be_lemma0 (Seq.slice b 1 2);
assert (BSeq.nat_from_intseq_be (Seq.slice b 0 2) == b1 + pow2 64 * (BSeq.nat_from_intseq_be (Seq.slice b 0 1)));
BSeq.nat_from_intseq_be_lemma0 (Seq.slice b 0 1);
assert (res == b3 + pow2 64 * (b2 + pow2 64 * (b1 + pow2 64 * b0)));
ML.lemma_as_nat64_horner b3 b2 b1 b0
val lemma_prime : unit -> Lemma (pow2 256 % S.prime = 0x1000003D1)
let lemma_prime () = ()
val lemma_pow2_256_minus_prime : unit -> Lemma (pow2 256 - S.prime = 0x1000003D1)
let lemma_pow2_256_minus_prime () = ()
val lemma_pow2_260_mod_prime: unit -> Lemma (pow2 260 % S.prime = 0x1000003D10)
let lemma_pow2_260_mod_prime () =
calc (==) {
pow2 260 % S.prime;
(==) { Math.Lemmas.pow2_plus 256 4 }
pow2 256 * pow2 4 % S.prime;
(==) { Math.Lemmas.lemma_mod_mul_distr_l (pow2 256) (pow2 4) S.prime }
(pow2 256 % S.prime) * pow2 4 % S.prime;
(==) { lemma_prime () }
0x1000003D1 * pow2 4 % S.prime;
(==) { assert_norm (0x1000003D1 * pow2 4 = 0x1000003D10) }
0x1000003D10 % S.prime;
(==) { Math.Lemmas.small_mod 0x1000003D10 S.prime }
0x1000003D10;
}
val lemma_as_nat_bound_f4_lt_powa: f:felem5 -> a:nat -> Lemma
(requires (let (f0,f1,f2,f3,f4) = f in
felem_fits5 f (1,1,1,1,1) /\ v f4 < pow2 a))
(ensures as_nat5 f <= pow2 (208 + a) - 1)
|
{
"checked_file": "/",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Hacl.Spec.K256.MathLemmas.fst.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.Field52.Definitions.Lemmas.fst"
}
|
[
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.MathLemmas",
"short_module": "ML"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
f: Hacl.Spec.K256.Field52.Definitions.felem5 -> a: Prims.nat
-> FStar.Pervasives.Lemma
(requires
(let _ = f in
(let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ _ _ _ _ f4 = _ in
Hacl.Spec.K256.Field52.Definitions.felem_fits5 f (1, 1, 1, 1, 1) /\
Lib.IntTypes.v f4 < Prims.pow2 a)
<:
Type0)) (ensures Hacl.Spec.K256.Field52.Definitions.as_nat5 f <= Prims.pow2 (208 + a) - 1)
|
FStar.Pervasives.Lemma
|
[
"lemma"
] |
[] |
[
"Hacl.Spec.K256.Field52.Definitions.felem5",
"Prims.nat",
"Lib.IntTypes.uint64",
"FStar.Calc.calc_finish",
"Prims.int",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.Mul.op_Star",
"Hacl.Spec.K256.Field52.Definitions.pow52",
"Hacl.Spec.K256.Field52.Definitions.pow104",
"Hacl.Spec.K256.Field52.Definitions.pow156",
"Hacl.Spec.K256.Field52.Definitions.pow208",
"Prims.op_Subtraction",
"Prims.pow2",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Prims.squash",
"FStar.Math.Lemmas.distributivity_sub_left",
"FStar.Math.Lemmas.lemma_mult_le_right",
"FStar.Math.Lemmas.pow2_plus"
] |
[] | false | false | true | false | false |
let lemma_as_nat_bound_f4_lt_powa f a =
|
let f0, f1, f2, f3, f4 = f in
calc ( <= ) {
v f0 + v f1 * pow52 + v f2 * pow104 + v f3 * pow156 + v f4 * pow208;
( <= ) { () }
pow2 52 - 1 + v f1 * pow52 + v f2 * pow104 + v f3 * pow156 + v f4 * pow208;
( <= ) { (Math.Lemmas.lemma_mult_le_right pow52 (v f1) (pow2 52 - 1);
Math.Lemmas.distributivity_sub_left (pow2 52) 1 pow52) }
pow2 52 * pow52 + v f2 * pow104 + v f3 * pow156 + v f4 * pow208 - 1;
( <= ) { (Math.Lemmas.lemma_mult_le_right pow104 (v f2) (pow2 52 - 1);
Math.Lemmas.distributivity_sub_left (pow2 52) 1 pow104;
Math.Lemmas.pow2_plus 52 52) }
pow2 52 * pow104 + v f3 * pow156 + v f4 * pow208 - 1;
( <= ) { (Math.Lemmas.lemma_mult_le_right pow156 (v f3) (pow2 52 - 1);
Math.Lemmas.distributivity_sub_left (pow2 52) 1 pow156;
Math.Lemmas.pow2_plus 52 104) }
pow2 52 * pow156 + v f4 * pow208 - 1;
( <= ) { (Math.Lemmas.lemma_mult_le_right pow208 (v f4) (pow2 a - 1);
Math.Lemmas.distributivity_sub_left (pow2 a) 1 pow208;
Math.Lemmas.pow2_plus 52 156;
Math.Lemmas.pow2_plus a 208) }
pow2 (208 + a) - 1;
}
| false |
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.fmul2_fsqr2_post
|
val fmul2_fsqr2_post (#s: field_spec) (h: mem) (out: felem2 s) : Type0
|
val fmul2_fsqr2_post (#s: field_spec) (h: mem) (out: felem2 s) : Type0
|
let fmul2_fsqr2_post (#s:field_spec) (h:mem) (out:felem2 s): Type0 =
match s with
| M51 ->
let out0 = gsub out 0ul 5ul in
let out1 = gsub out 5ul 5ul in
f51_mul_inv_t h out0 /\
f51_mul_inv_t h out1
| M64 -> True
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 15,
"end_line": 239,
"start_col": 0,
"start_line": 232
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
unfold noextract
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
unfold noextract
let nwide (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 8ul
inline_for_extraction noextract
let felem (s:field_spec) = lbuffer (limb s) (nlimb s)
inline_for_extraction noextract
let felem2 (s:field_spec) = lbuffer (limb s) (nlimb s +. nlimb s)
inline_for_extraction noextract
let felem_wide (s:field_spec) = lbuffer (wide s) (nwide s)
inline_for_extraction noextract
let felem_wide2 (s:field_spec) = lbuffer (wide s) (nwide s +. nwide s)
/// Introduce representation for each field + helpers to be able to state pre & posts
/// ---------------------------------------------------------------------------------
noextract
let f51_as_felem (h:mem) (f:felem M51) : GTot Hacl.Spec.Curve25519.Field51.Definition.felem5 =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
(s0, s1, s2, s3, s4)
let f51_as_nat h e = Hacl.Spec.Curve25519.Field51.Definition.as_nat5 (f51_as_felem h e)
noextract
let f51_felem_fits (h:mem) (f:felem M51) (m:Hacl.Spec.Curve25519.Field51.Definition.scale64_5): Type0 =
Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 (f51_as_felem h f) m
noextract
let f51_felem_fits1 = Hacl.Spec.Curve25519.Field51.Definition.felem_fits1
noextract
let f51_mul_inv_t (h:mem) (f:felem M51) : GTot Type0 =
let f = f51_as_felem h f in
Hacl.Spec.Curve25519.Field51.mul_inv_t f
noextract
let f64_as_nat (h:mem) (e: felem M64) : GTot nat =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
Hacl.Spec.Curve25519.Field64.Definition.as_nat4 (s0, s1, s2, s3)
noextract
let as_nat (#s:field_spec) (h:mem) (e:felem s): GTot nat =
match s with
| M51 -> f51_as_nat h e
| M64 -> f64_as_nat h e
noextract
let feval (#s:field_spec) (h:mem) (e:felem s): GTot P.elem =
(as_nat h e) % P.prime
/// Start of core combinators
/// -------------------------
let fadd_fsub_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:felem s): Type0 =
match s with
| M51 ->
f51_felem_fits h f1 (1, 2, 1, 1, 1) /\
f51_felem_fits h f2 (1, 2, 1, 1, 1)
| M64 -> True
let fadd_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (2, 4, 2, 2, 2)
| M64 -> True
inline_for_extraction
let fadd_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint f1 f2 \/ f1 == f2) /\
fadd_fsub_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fadd_post h1 out /\
feval h1 out == P.fadd (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize]
val fadd: #s:field_spec -> fadd_t s True
let fsub_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (9, 10, 9, 9, 9)
| M64 -> True
inline_for_extraction
let fsub_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint f1 f2 \/ f1 == f2) /\
fadd_fsub_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fsub_post h1 out /\
feval h1 out == P.fsub (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize ]
val fsub: #s:field_spec -> fsub_t s True
let fmul_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:felem s): Type0 =
match s with
| M51 ->
f51_felem_fits h f1 (9, 10, 9, 9, 9) /\
f51_felem_fits h f2 (9, 10, 9, 9, 9)
| M64 -> True
let fmul_disjoint (#s:field_spec) (out f1 f2:felem s) (tmp:felem_wide2 s): Type0 =
match s with
| M51 -> True
| M64 ->
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint out tmp \/ out == tmp) /\
(disjoint f1 f2 \/ f1 == f2) /\
disjoint f1 tmp /\
disjoint f2 tmp
let state_inv_t (#s:field_spec) (h:mem) (f:felem s): Type0 =
match s with
| M51 -> f51_mul_inv_t h f
| M64 -> True
inline_for_extraction
let fmul_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> tmp:felem_wide2 s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\ live h tmp /\
fmul_disjoint out f1 f2 tmp /\
fmul_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out |+| loc tmp) h0 h1 /\ state_inv_t h1 out /\
feval h1 out == P.fmul (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize ]
val fmul: #s:field_spec -> fmul_t s True
let fmul2_pre (#s:field_spec) (h:mem) (f1:felem2 s) (f2:felem2 s): Type0 =
match s with
| M51 ->
let f10 = gsub f1 0ul 5ul in
let f11 = gsub f1 5ul 5ul in
let f20 = gsub f2 0ul 5ul in
let f21 = gsub f2 5ul 5ul in
f51_felem_fits h f10 (9, 10, 9, 9, 9) /\
f51_felem_fits h f11 (9, 10, 9, 9, 9) /\
f51_felem_fits h f20 (9, 10, 9, 9, 9) /\
f51_felem_fits h f21 (9, 10, 9, 9, 9)
| M64 -> True
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
h: FStar.Monotonic.HyperStack.mem -> out: Hacl.Impl.Curve25519.Fields.Core.felem2 s -> Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Curve25519.Fields.Core.felem2",
"Prims.l_and",
"Hacl.Impl.Curve25519.Fields.Core.f51_mul_inv_t",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.gsub",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Lib.IntTypes.op_Plus_Dot",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Curve25519.Fields.Core.nlimb",
"FStar.UInt32.__uint_to_t",
"Prims.l_True"
] |
[] | false | false | false | false | true |
let fmul2_fsqr2_post (#s: field_spec) (h: mem) (out: felem2 s) : Type0 =
|
match s with
| M51 ->
let out0 = gsub out 0ul 5ul in
let out1 = gsub out 5ul 5ul in
f51_mul_inv_t h out0 /\ f51_mul_inv_t h out1
| M64 -> True
| false |
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.fsqr2_pre
|
val fsqr2_pre (#s: field_spec) (h: mem) (f: felem2 s) : Type0
|
val fsqr2_pre (#s: field_spec) (h: mem) (f: felem2 s) : Type0
|
let fsqr2_pre (#s:field_spec) (h:mem) (f:felem2 s): Type0 =
match s with
| M51 ->
let f1 = gsub f 0ul 5ul in
let f2 = gsub f 5ul 5ul in
f51_felem_fits h f1 (9, 10, 9, 9, 9) /\
f51_felem_fits h f2 (9, 10, 9, 9, 9)
| M64 -> True
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 15,
"end_line": 335,
"start_col": 0,
"start_line": 328
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
unfold noextract
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
unfold noextract
let nwide (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 8ul
inline_for_extraction noextract
let felem (s:field_spec) = lbuffer (limb s) (nlimb s)
inline_for_extraction noextract
let felem2 (s:field_spec) = lbuffer (limb s) (nlimb s +. nlimb s)
inline_for_extraction noextract
let felem_wide (s:field_spec) = lbuffer (wide s) (nwide s)
inline_for_extraction noextract
let felem_wide2 (s:field_spec) = lbuffer (wide s) (nwide s +. nwide s)
/// Introduce representation for each field + helpers to be able to state pre & posts
/// ---------------------------------------------------------------------------------
noextract
let f51_as_felem (h:mem) (f:felem M51) : GTot Hacl.Spec.Curve25519.Field51.Definition.felem5 =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
(s0, s1, s2, s3, s4)
let f51_as_nat h e = Hacl.Spec.Curve25519.Field51.Definition.as_nat5 (f51_as_felem h e)
noextract
let f51_felem_fits (h:mem) (f:felem M51) (m:Hacl.Spec.Curve25519.Field51.Definition.scale64_5): Type0 =
Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 (f51_as_felem h f) m
noextract
let f51_felem_fits1 = Hacl.Spec.Curve25519.Field51.Definition.felem_fits1
noextract
let f51_mul_inv_t (h:mem) (f:felem M51) : GTot Type0 =
let f = f51_as_felem h f in
Hacl.Spec.Curve25519.Field51.mul_inv_t f
noextract
let f64_as_nat (h:mem) (e: felem M64) : GTot nat =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
Hacl.Spec.Curve25519.Field64.Definition.as_nat4 (s0, s1, s2, s3)
noextract
let as_nat (#s:field_spec) (h:mem) (e:felem s): GTot nat =
match s with
| M51 -> f51_as_nat h e
| M64 -> f64_as_nat h e
noextract
let feval (#s:field_spec) (h:mem) (e:felem s): GTot P.elem =
(as_nat h e) % P.prime
/// Start of core combinators
/// -------------------------
let fadd_fsub_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:felem s): Type0 =
match s with
| M51 ->
f51_felem_fits h f1 (1, 2, 1, 1, 1) /\
f51_felem_fits h f2 (1, 2, 1, 1, 1)
| M64 -> True
let fadd_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (2, 4, 2, 2, 2)
| M64 -> True
inline_for_extraction
let fadd_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint f1 f2 \/ f1 == f2) /\
fadd_fsub_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fadd_post h1 out /\
feval h1 out == P.fadd (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize]
val fadd: #s:field_spec -> fadd_t s True
let fsub_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (9, 10, 9, 9, 9)
| M64 -> True
inline_for_extraction
let fsub_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint f1 f2 \/ f1 == f2) /\
fadd_fsub_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fsub_post h1 out /\
feval h1 out == P.fsub (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize ]
val fsub: #s:field_spec -> fsub_t s True
let fmul_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:felem s): Type0 =
match s with
| M51 ->
f51_felem_fits h f1 (9, 10, 9, 9, 9) /\
f51_felem_fits h f2 (9, 10, 9, 9, 9)
| M64 -> True
let fmul_disjoint (#s:field_spec) (out f1 f2:felem s) (tmp:felem_wide2 s): Type0 =
match s with
| M51 -> True
| M64 ->
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint out tmp \/ out == tmp) /\
(disjoint f1 f2 \/ f1 == f2) /\
disjoint f1 tmp /\
disjoint f2 tmp
let state_inv_t (#s:field_spec) (h:mem) (f:felem s): Type0 =
match s with
| M51 -> f51_mul_inv_t h f
| M64 -> True
inline_for_extraction
let fmul_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> tmp:felem_wide2 s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\ live h tmp /\
fmul_disjoint out f1 f2 tmp /\
fmul_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out |+| loc tmp) h0 h1 /\ state_inv_t h1 out /\
feval h1 out == P.fmul (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize ]
val fmul: #s:field_spec -> fmul_t s True
let fmul2_pre (#s:field_spec) (h:mem) (f1:felem2 s) (f2:felem2 s): Type0 =
match s with
| M51 ->
let f10 = gsub f1 0ul 5ul in
let f11 = gsub f1 5ul 5ul in
let f20 = gsub f2 0ul 5ul in
let f21 = gsub f2 5ul 5ul in
f51_felem_fits h f10 (9, 10, 9, 9, 9) /\
f51_felem_fits h f11 (9, 10, 9, 9, 9) /\
f51_felem_fits h f20 (9, 10, 9, 9, 9) /\
f51_felem_fits h f21 (9, 10, 9, 9, 9)
| M64 -> True
let fmul2_fsqr2_post (#s:field_spec) (h:mem) (out:felem2 s): Type0 =
match s with
| M51 ->
let out0 = gsub out 0ul 5ul in
let out1 = gsub out 5ul 5ul in
f51_mul_inv_t h out0 /\
f51_mul_inv_t h out1
| M64 -> True
inline_for_extraction
let fmul2_t (s:field_spec) (p: Type0) =
out:felem2 s
-> f1:felem2 s
-> f2:felem2 s
-> tmp:felem_wide2 s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\ live h tmp /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint out tmp) /\
(disjoint f1 f2 \/ f1 == f2) /\
disjoint f1 tmp /\
disjoint f2 tmp /\
fmul2_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out |+| loc tmp) h0 h1 /\ fmul2_fsqr2_post h1 out /\
(let out0 = gsub out 0ul (nlimb s) in
let out1 = gsub out (nlimb s) (nlimb s) in
let f10 = gsub f1 0ul (nlimb s) in
let f11 = gsub f1 (nlimb s) (nlimb s) in
let f20 = gsub f2 0ul (nlimb s) in
let f21 = gsub f2 (nlimb s) (nlimb s) in
feval h1 out0 == P.fmul (feval h0 f10) (feval h0 f20) /\
feval h1 out1 == P.fmul (feval h0 f11) (feval h0 f21)))
[@ Meta.Attribute.specialize ]
val fmul2: #s:field_spec -> fmul2_t s True
let fmul1_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:uint64): Type0 =
match s with
| M51 -> f51_felem_fits h f1 (9, 10, 9, 9, 9) /\ f51_felem_fits1 f2 1
| M64 -> v f2 < pow2 17
inline_for_extraction
let fmul1_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:uint64
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\
(disjoint out f1 \/ out == f1) /\
fmul1_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ state_inv_t h1 out /\
feval h1 out == P.fmul (feval h0 f1) (v f2))
// feval h1 out == (feval h0 f1 * v f2) % P.prime)
[@ Meta.Attribute.specialize ]
val fmul1: #s:field_spec -> fmul1_t s True
let fsqr_pre (#s:field_spec) (h:mem) (f:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h f (9, 10, 9, 9, 9)
| M64 -> True
let fsqr_disjoint (#s:field_spec) (out f1:felem s) (tmp:felem_wide s): Type0 =
match s with
| M51 -> True
| M64 ->
(disjoint out f1 \/ out == f1) /\
(disjoint out tmp \/ out == tmp) /\
disjoint tmp f1
inline_for_extraction
let fsqr_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> tmp:felem_wide s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h tmp /\
fsqr_disjoint out f1 tmp /\
fsqr_pre h f1)
(ensures fun h0 _ h1 ->
modifies (loc out |+| loc tmp) h0 h1 /\
state_inv_t h1 out /\
feval h1 out == P.fmul (feval h0 f1) (feval h0 f1))
[@ Meta.Attribute.specialize ]
val fsqr: #s:field_spec -> fsqr_t s True
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
h: FStar.Monotonic.HyperStack.mem -> f: Hacl.Impl.Curve25519.Fields.Core.felem2 s -> Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"FStar.Monotonic.HyperStack.mem",
"Hacl.Impl.Curve25519.Fields.Core.felem2",
"Prims.l_and",
"Hacl.Impl.Curve25519.Fields.Core.f51_felem_fits",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.gsub",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Lib.IntTypes.op_Plus_Dot",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Curve25519.Fields.Core.nlimb",
"FStar.UInt32.__uint_to_t",
"Prims.l_True"
] |
[] | false | false | false | false | true |
let fsqr2_pre (#s: field_spec) (h: mem) (f: felem2 s) : Type0 =
|
match s with
| M51 ->
let f1 = gsub f 0ul 5ul in
let f2 = gsub f 5ul 5ul in
f51_felem_fits h f1 (9, 10, 9, 9, 9) /\ f51_felem_fits h f2 (9, 10, 9, 9, 9)
| M64 -> True
| false |
Steel.ST.GhostPCMReference.fst
|
Steel.ST.GhostPCMReference.share
|
val share (#o:inames)
(#a:Type)
(#p:pcm a)
(r:ref a p)
(v:a)
(v0:a)
(v1:a)
: STGhost unit o
(pts_to r v)
(fun _ -> pts_to r v0 `star` pts_to r v1)
(requires
composable p v0 v1 /\
v == op p v0 v1)
(ensures fun _ -> True)
|
val share (#o:inames)
(#a:Type)
(#p:pcm a)
(r:ref a p)
(v:a)
(v0:a)
(v1:a)
: STGhost unit o
(pts_to r v)
(fun _ -> pts_to r v0 `star` pts_to r v1)
(requires
composable p v0 v1 /\
v == op p v0 v1)
(ensures fun _ -> True)
|
let share (#o:inames)
(#a:Type)
(#p:pcm a)
(r:ref a p)
(v:a)
(v0:a)
(v1:a)
: STGhost unit o
(pts_to r v)
(fun _ -> pts_to r v0 `star` pts_to r v1)
(requires
composable p v0 v1 /\
v == op p v0 v1)
(ensures fun _ -> True)
= coerce_ghost (fun _ -> G.share r (raise_val v) (raise_val v0) (raise_val v1))
|
{
"file_name": "lib/steel/Steel.ST.GhostPCMReference.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
}
|
{
"end_col": 81,
"end_line": 97,
"start_col": 0,
"start_line": 83
}
|
(*
Copyright 2021 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.ST.GhostPCMReference
open FStar.Ghost
open Steel.ST.Util
open Steel.ST.Coercions
open FStar.PCM
open FStar.Universe
module UP = FStar.Universe.PCM
module G = Steel.GhostPCMReference
let ref (a:Type u#0) (p:pcm a) : Type u#0 =
G.ref (raise_t u#0 u#1 a) (UP.raise p)
/// pts_to is fixed to ref contents in u#0
let pts_to (#a:Type u#0) (#pcm:pcm a) (r:ref a pcm) ([@@@smt_fallback] v:a)
= G.pts_to #(raise_t a) #(UP.raise pcm) r (raise_val v)
/// Allocates a new reference, initially storing value [x].
let alloc (#o:inames)
(#a:Type)
(#pcm:pcm a)
(x:a)
: STGhost (ref a pcm) o
emp
(fun r -> pts_to r x)
(requires pcm.refine x)
(ensures fun _ -> True)
= coerce_ghost (fun _ -> G.alloc (raise_val x))
let read (#o:inames)
(#a:Type)
(#pcm:pcm a)
(#v0:a)
(r:ref a pcm)
: STGhost a o
(pts_to r v0)
(fun _ -> pts_to r v0)
(requires True)
(ensures fun v -> compatible pcm v0 v)
= let v = coerce_ghost (fun _ -> G.read r) in
downgrade_val v
let write (#o:inames)
(#a:Type)
(#pcm:pcm a)
(r:ref a pcm)
(v0:a)
(v1:a)
: STGhost unit o
(pts_to r v0)
(fun _ -> pts_to r v1)
(requires frame_preserving pcm v0 v1 /\ pcm.refine v1)
(ensures fun _ -> True)
= coerce_ghost (fun _ -> G.write r (raise_val v0) (raise_val v1))
let upd_gen (#o:inames)
(#a:Type)
(#p:pcm a)
(r:ref a p)
(x y:a)
(f:frame_preserving_upd p x y)
: STGhostT unit o
(pts_to r x)
(fun _ -> pts_to r y)
= coerce_ghost (fun _ -> G.upd_gen r (raise_val x) (raise_val y) (UP.raise_frame_preserving_upd f))
|
{
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.ST.Coercions.fsti.checked",
"Steel.GhostPCMReference.fsti.checked",
"prims.fst.checked",
"FStar.Universe.PCM.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.ST.GhostPCMReference.fst"
}
|
[
{
"abbrev": true,
"full_module": "Steel.GhostPCMReference",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.Universe.PCM",
"short_module": "UP"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Coercions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
r: Steel.ST.GhostPCMReference.ref a p -> v: a -> v0: a -> v1: a
-> Steel.ST.Effect.Ghost.STGhost Prims.unit
|
Steel.ST.Effect.Ghost.STGhost
|
[] |
[] |
[
"Steel.Memory.inames",
"FStar.PCM.pcm",
"Steel.ST.GhostPCMReference.ref",
"Steel.ST.Coercions.coerce_ghost",
"Prims.unit",
"Steel.GhostPCMReference.pts_to",
"FStar.Universe.raise_t",
"FStar.Universe.PCM.raise",
"FStar.Universe.raise_val",
"Steel.Effect.Common.star",
"Steel.Effect.Common.vprop",
"Prims.l_and",
"FStar.PCM.composable",
"Prims.eq2",
"FStar.PCM.op",
"Prims.l_True",
"Steel.GhostPCMReference.share",
"Steel.ST.GhostPCMReference.pts_to"
] |
[] | false | true | false | false | false |
let share (#o: inames) (#a: Type) (#p: pcm a) (r: ref a p) (v v0 v1: a)
: STGhost unit
o
(pts_to r v)
(fun _ -> (pts_to r v0) `star` (pts_to r v1))
(requires composable p v0 v1 /\ v == op p v0 v1)
(ensures fun _ -> True) =
|
coerce_ghost (fun _ -> G.share r (raise_val v) (raise_val v0) (raise_val v1))
| false |
Hacl.Impl.Curve25519.Fields.Core.fsti
|
Hacl.Impl.Curve25519.Fields.Core.cswap2_t
|
val cswap2_t : s: Hacl.Impl.Curve25519.Fields.Core.field_spec -> p: Type0 -> Type0
|
let cswap2_t (s:field_spec) (p: Type0) =
bit:uint64{v bit <= 1}
-> p1:felem2 s
-> p2:felem2 s
-> Stack unit
(requires fun h0 ->
p /\
live h0 p1 /\ live h0 p2 /\
(disjoint p1 p2 \/ p1 == p2))
(ensures fun h0 _ h1 ->
modifies (loc p1 |+| loc p2) h0 h1 /\
(v bit == 1 ==> as_seq h1 p1 == as_seq h0 p2 /\ as_seq h1 p2 == as_seq h0 p1) /\
(v bit == 0 ==> as_seq h1 p1 == as_seq h0 p1 /\ as_seq h1 p2 == as_seq h0 p2))
|
{
"file_name": "code/curve25519/Hacl.Impl.Curve25519.Fields.Core.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 84,
"end_line": 375,
"start_col": 0,
"start_line": 363
}
|
module Hacl.Impl.Curve25519.Fields.Core
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
open Lib.Buffer
module P = Spec.Curve25519
/// This module defines the core functions for which we will want to swap out
/// implementations. They are marked as assume val's since we strictly have more
/// than one implementation per index value.
#set-options "--z3rlimit 50 --fuel 0 --ifuel 1 --record_options"
/// Shared definitions for agility of the field type
/// ------------------------------------------------
type field_spec =
| M51
| M64
unfold noextract
let limb (s:field_spec) =
match s with
| M51 -> uint64
| M64 -> uint64
unfold noextract
let limb_zero (s:field_spec) : limb s=
match s with
| M51 -> u64 0
| M64 -> u64 0
unfold noextract
let nlimb (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 4ul
unfold noextract
let wide (s:field_spec) =
match s with
| M51 -> uint128
| M64 -> uint64
unfold noextract
let wide_zero (s:field_spec) : wide s=
match s with
| M51 -> u128 0
| M64 -> u64 0
unfold noextract
let nwide (s:field_spec) : size_t =
match s with
| M51 -> 5ul
| M64 -> 8ul
inline_for_extraction noextract
let felem (s:field_spec) = lbuffer (limb s) (nlimb s)
inline_for_extraction noextract
let felem2 (s:field_spec) = lbuffer (limb s) (nlimb s +. nlimb s)
inline_for_extraction noextract
let felem_wide (s:field_spec) = lbuffer (wide s) (nwide s)
inline_for_extraction noextract
let felem_wide2 (s:field_spec) = lbuffer (wide s) (nwide s +. nwide s)
/// Introduce representation for each field + helpers to be able to state pre & posts
/// ---------------------------------------------------------------------------------
noextract
let f51_as_felem (h:mem) (f:felem M51) : GTot Hacl.Spec.Curve25519.Field51.Definition.felem5 =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
(s0, s1, s2, s3, s4)
let f51_as_nat h e = Hacl.Spec.Curve25519.Field51.Definition.as_nat5 (f51_as_felem h e)
noextract
let f51_felem_fits (h:mem) (f:felem M51) (m:Hacl.Spec.Curve25519.Field51.Definition.scale64_5): Type0 =
Hacl.Spec.Curve25519.Field51.Definition.felem_fits5 (f51_as_felem h f) m
noextract
let f51_felem_fits1 = Hacl.Spec.Curve25519.Field51.Definition.felem_fits1
noextract
let f51_mul_inv_t (h:mem) (f:felem M51) : GTot Type0 =
let f = f51_as_felem h f in
Hacl.Spec.Curve25519.Field51.mul_inv_t f
noextract
let f64_as_nat (h:mem) (e: felem M64) : GTot nat =
let s = as_seq h e in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
Hacl.Spec.Curve25519.Field64.Definition.as_nat4 (s0, s1, s2, s3)
noextract
let as_nat (#s:field_spec) (h:mem) (e:felem s): GTot nat =
match s with
| M51 -> f51_as_nat h e
| M64 -> f64_as_nat h e
noextract
let feval (#s:field_spec) (h:mem) (e:felem s): GTot P.elem =
(as_nat h e) % P.prime
/// Start of core combinators
/// -------------------------
let fadd_fsub_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:felem s): Type0 =
match s with
| M51 ->
f51_felem_fits h f1 (1, 2, 1, 1, 1) /\
f51_felem_fits h f2 (1, 2, 1, 1, 1)
| M64 -> True
let fadd_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (2, 4, 2, 2, 2)
| M64 -> True
inline_for_extraction
let fadd_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint f1 f2 \/ f1 == f2) /\
fadd_fsub_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fadd_post h1 out /\
feval h1 out == P.fadd (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize]
val fadd: #s:field_spec -> fadd_t s True
let fsub_post (#s:field_spec) (h:mem) (out:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h out (9, 10, 9, 9, 9)
| M64 -> True
inline_for_extraction
let fsub_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint f1 f2 \/ f1 == f2) /\
fadd_fsub_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ fsub_post h1 out /\
feval h1 out == P.fsub (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize ]
val fsub: #s:field_spec -> fsub_t s True
let fmul_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:felem s): Type0 =
match s with
| M51 ->
f51_felem_fits h f1 (9, 10, 9, 9, 9) /\
f51_felem_fits h f2 (9, 10, 9, 9, 9)
| M64 -> True
let fmul_disjoint (#s:field_spec) (out f1 f2:felem s) (tmp:felem_wide2 s): Type0 =
match s with
| M51 -> True
| M64 ->
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint out tmp \/ out == tmp) /\
(disjoint f1 f2 \/ f1 == f2) /\
disjoint f1 tmp /\
disjoint f2 tmp
let state_inv_t (#s:field_spec) (h:mem) (f:felem s): Type0 =
match s with
| M51 -> f51_mul_inv_t h f
| M64 -> True
inline_for_extraction
let fmul_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:felem s
-> tmp:felem_wide2 s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\ live h tmp /\
fmul_disjoint out f1 f2 tmp /\
fmul_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out |+| loc tmp) h0 h1 /\ state_inv_t h1 out /\
feval h1 out == P.fmul (feval h0 f1) (feval h0 f2))
[@ Meta.Attribute.specialize ]
val fmul: #s:field_spec -> fmul_t s True
let fmul2_pre (#s:field_spec) (h:mem) (f1:felem2 s) (f2:felem2 s): Type0 =
match s with
| M51 ->
let f10 = gsub f1 0ul 5ul in
let f11 = gsub f1 5ul 5ul in
let f20 = gsub f2 0ul 5ul in
let f21 = gsub f2 5ul 5ul in
f51_felem_fits h f10 (9, 10, 9, 9, 9) /\
f51_felem_fits h f11 (9, 10, 9, 9, 9) /\
f51_felem_fits h f20 (9, 10, 9, 9, 9) /\
f51_felem_fits h f21 (9, 10, 9, 9, 9)
| M64 -> True
let fmul2_fsqr2_post (#s:field_spec) (h:mem) (out:felem2 s): Type0 =
match s with
| M51 ->
let out0 = gsub out 0ul 5ul in
let out1 = gsub out 5ul 5ul in
f51_mul_inv_t h out0 /\
f51_mul_inv_t h out1
| M64 -> True
inline_for_extraction
let fmul2_t (s:field_spec) (p: Type0) =
out:felem2 s
-> f1:felem2 s
-> f2:felem2 s
-> tmp:felem_wide2 s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h f2 /\ live h tmp /\
(disjoint out f1 \/ out == f1) /\
(disjoint out f2 \/ out == f2) /\
(disjoint out tmp) /\
(disjoint f1 f2 \/ f1 == f2) /\
disjoint f1 tmp /\
disjoint f2 tmp /\
fmul2_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out |+| loc tmp) h0 h1 /\ fmul2_fsqr2_post h1 out /\
(let out0 = gsub out 0ul (nlimb s) in
let out1 = gsub out (nlimb s) (nlimb s) in
let f10 = gsub f1 0ul (nlimb s) in
let f11 = gsub f1 (nlimb s) (nlimb s) in
let f20 = gsub f2 0ul (nlimb s) in
let f21 = gsub f2 (nlimb s) (nlimb s) in
feval h1 out0 == P.fmul (feval h0 f10) (feval h0 f20) /\
feval h1 out1 == P.fmul (feval h0 f11) (feval h0 f21)))
[@ Meta.Attribute.specialize ]
val fmul2: #s:field_spec -> fmul2_t s True
let fmul1_pre (#s:field_spec) (h:mem) (f1:felem s) (f2:uint64): Type0 =
match s with
| M51 -> f51_felem_fits h f1 (9, 10, 9, 9, 9) /\ f51_felem_fits1 f2 1
| M64 -> v f2 < pow2 17
inline_for_extraction
let fmul1_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> f2:uint64
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\
(disjoint out f1 \/ out == f1) /\
fmul1_pre h f1 f2)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\ state_inv_t h1 out /\
feval h1 out == P.fmul (feval h0 f1) (v f2))
// feval h1 out == (feval h0 f1 * v f2) % P.prime)
[@ Meta.Attribute.specialize ]
val fmul1: #s:field_spec -> fmul1_t s True
let fsqr_pre (#s:field_spec) (h:mem) (f:felem s): Type0 =
match s with
| M51 -> f51_felem_fits h f (9, 10, 9, 9, 9)
| M64 -> True
let fsqr_disjoint (#s:field_spec) (out f1:felem s) (tmp:felem_wide s): Type0 =
match s with
| M51 -> True
| M64 ->
(disjoint out f1 \/ out == f1) /\
(disjoint out tmp \/ out == tmp) /\
disjoint tmp f1
inline_for_extraction
let fsqr_t (s:field_spec) (p: Type0) =
out:felem s
-> f1:felem s
-> tmp:felem_wide s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f1 /\ live h tmp /\
fsqr_disjoint out f1 tmp /\
fsqr_pre h f1)
(ensures fun h0 _ h1 ->
modifies (loc out |+| loc tmp) h0 h1 /\
state_inv_t h1 out /\
feval h1 out == P.fmul (feval h0 f1) (feval h0 f1))
[@ Meta.Attribute.specialize ]
val fsqr: #s:field_spec -> fsqr_t s True
let fsqr2_pre (#s:field_spec) (h:mem) (f:felem2 s): Type0 =
match s with
| M51 ->
let f1 = gsub f 0ul 5ul in
let f2 = gsub f 5ul 5ul in
f51_felem_fits h f1 (9, 10, 9, 9, 9) /\
f51_felem_fits h f2 (9, 10, 9, 9, 9)
| M64 -> True
inline_for_extraction
let fsqr2_t (s:field_spec) (p: Type0) =
out:felem2 s
-> f:felem2 s
-> tmp:felem_wide2 s
-> Stack unit
(requires fun h ->
p /\
live h out /\ live h f /\ live h tmp /\
(disjoint out f \/ out == f) /\
(disjoint out tmp) /\
disjoint tmp f /\
fsqr2_pre h f)
(ensures fun h0 _ h1 ->
modifies (loc out |+| loc tmp) h0 h1 /\ fmul2_fsqr2_post h1 out /\
(let out1 = gsub out 0ul (nlimb s) in
let out2 = gsub out (nlimb s) (nlimb s) in
let f1 = gsub f 0ul (nlimb s) in
let f2 = gsub f (nlimb s) (nlimb s) in
feval h1 out1 == P.fmul (feval h0 f1) (feval h0 f1) /\
feval h1 out2 == P.fmul (feval h0 f2) (feval h0 f2)))
[@ Meta.Attribute.specialize ]
val fsqr2: #s:field_spec -> fsqr2_t s True
|
{
"checked_file": "/",
"dependencies": [
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Meta.Attribute.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Field64.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Spec.Curve25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Curve25519.Fields.Core.fsti"
}
|
[
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Curve25519.Fields",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
s: Hacl.Impl.Curve25519.Fields.Core.field_spec -> p: Type0 -> Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Hacl.Impl.Curve25519.Fields.Core.field_spec",
"Lib.IntTypes.uint64",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Hacl.Impl.Curve25519.Fields.Core.felem2",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Impl.Curve25519.Fields.Core.limb",
"Prims.l_or",
"Lib.Buffer.disjoint",
"Prims.eq2",
"Lib.Buffer.modifies",
"Lib.Buffer.op_Bar_Plus_Bar",
"Lib.Buffer.loc",
"Prims.l_imp",
"Prims.int",
"Lib.Sequence.lseq",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.op_Plus_Dot",
"Hacl.Impl.Curve25519.Fields.Core.nlimb",
"Lib.Buffer.as_seq"
] |
[] | false | false | false | true | true |
let cswap2_t (s: field_spec) (p: Type0) =
|
bit: uint64{v bit <= 1} -> p1: felem2 s -> p2: felem2 s
-> Stack unit
(requires fun h0 -> p /\ live h0 p1 /\ live h0 p2 /\ (disjoint p1 p2 \/ p1 == p2))
(ensures
fun h0 _ h1 ->
modifies (loc p1 |+| loc p2) h0 h1 /\
(v bit == 1 ==> as_seq h1 p1 == as_seq h0 p2 /\ as_seq h1 p2 == as_seq h0 p1) /\
(v bit == 0 ==> as_seq h1 p1 == as_seq h0 p1 /\ as_seq h1 p2 == as_seq h0 p2))
| false |
|
Lib.IntVector.Transpose.fst
|
Lib.IntVector.Transpose.transpose4x4
|
val transpose4x4: #t:v_inttype{t = U32 \/ t = U64} -> vec_t4 t -> vec_t4 t
|
val transpose4x4: #t:v_inttype{t = U32 \/ t = U64} -> vec_t4 t -> vec_t4 t
|
let transpose4x4 #t vs =
match t with
| U32 -> transpose4x4_uint32 #t vs
| U64 -> transpose4x4_uint64 #t vs
|
{
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 36,
"end_line": 42,
"start_col": 0,
"start_line": 39
}
|
module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction
val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'')
inline_for_extraction
val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint64 #t vs = transpose4x4_0 #t vs
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
}
|
[
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"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": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 |
vs: Lib.IntVector.Transpose.vec_t4 t -> Lib.IntVector.Transpose.vec_t4 t
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Lib.IntVector.v_inttype",
"Prims.l_or",
"Prims.b2t",
"Prims.op_Equality",
"Lib.IntTypes.inttype",
"Lib.IntTypes.U32",
"Lib.IntTypes.U64",
"Lib.IntVector.Transpose.vec_t4",
"Lib.IntVector.Transpose.transpose4x4_uint32",
"Lib.IntVector.Transpose.transpose4x4_uint64"
] |
[] | false | false | false | false | false |
let transpose4x4 #t vs =
|
match t with
| U32 -> transpose4x4_uint32 #t vs
| U64 -> transpose4x4_uint64 #t vs
| false |
Lib.IntVector.Transpose.fst
|
Lib.IntVector.Transpose.transposewxw_f
|
val transposewxw_f: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> i:nat{i < n} -> lseq (vec_t t w) w -> lseq (vec_t t w) w
|
val transposewxw_f: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> i:nat{i < n} -> lseq (vec_t t w) w -> lseq (vec_t t w) w
|
let transposewxw_f #w #t n i vs =
createi w (transposewxw_f_l #w n i vs)
|
{
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 40,
"end_line": 164,
"start_col": 0,
"start_line": 163
}
|
module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction
val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'')
inline_for_extraction
val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint64 #t vs = transpose4x4_0 #t vs
let transpose4x4 #t vs =
match t with
| U32 -> transpose4x4_uint32 #t vs
| U64 -> transpose4x4_uint64 #t vs
///
/// transpose8x8
///
inline_for_extraction
val transpose8x8_0: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v4' = vec_interleave_low v4 v5 in
let v5' = vec_interleave_high v4 v5 in
let v6' = vec_interleave_low v6 v7 in
let v7' = vec_interleave_high v6 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_1: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_1 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 2 v0 v2 in
let v2' = vec_interleave_high_n 2 v0 v2 in
let v1' = vec_interleave_low_n 2 v1 v3 in
let v3' = vec_interleave_high_n 2 v1 v3 in
let v4' = vec_interleave_low_n 2 v4 v6 in
let v6' = vec_interleave_high_n 2 v4 v6 in
let v5' = vec_interleave_low_n 2 v5 v7 in
let v7' = vec_interleave_high_n 2 v5 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_2: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_2 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 4 v0 v4 in
let v4' = vec_interleave_high_n 4 v0 v4 in
let v1' = vec_interleave_low_n 4 v1 v5 in
let v5' = vec_interleave_high_n 4 v1 v5 in
let v2' = vec_interleave_low_n 4 v2 v6 in
let v6' = vec_interleave_high_n 4 v2 v6 in
let v3' = vec_interleave_low_n 4 v3 v7 in
let v7' = vec_interleave_high_n 4 v3 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_012: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_012 #t vs0 =
let (v0,v1,v2,v3,v4,v5,v6,v7) = vs0 in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_1 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_2 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_uint32: #t:v_inttype{t == U32} -> vec_t8 t -> vec_t8 t
let transpose8x8_uint32 #t vs0 =
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_012 #t vs0 in
(v0',v2',v1',v3',v4',v6',v5',v7')
let transpose8x8 #t vs =
match t with
| U32 -> transpose8x8_uint32 #t vs
///
/// generic transpose
///
val lemma_l_plus_pow2i_lt: #w:pos -> n:nat{pow2 n == w} -> i:nat{i < n} -> l:nat{l < w} -> Lemma
(requires l % (2 * pow2 i) < pow2 i)
(ensures l + pow2 i < w)
let lemma_l_plus_pow2i_lt #w n i l =
let pow2i1 = pow2 (i + 1) in
calc (<) {
l + pow2 i;
(==) { Math.Lemmas.euclidean_division_definition l pow2i1 }
l / pow2i1 * pow2i1 + l % pow2i1 + pow2 i;
(==) { Math.Lemmas.pow2_plus 1 i }
l / pow2i1 * pow2i1 + l % (2 * pow2 i) + pow2 i;
(<) { assert (l % (2 * pow2 i) < pow2 i) }
l / pow2i1 * pow2i1 + pow2 i + pow2 i;
(==) { Math.Lemmas.pow2_double_sum i }
l / pow2i1 * pow2i1 + pow2i1;
(==) { Math.Lemmas.distributivity_add_left (l / pow2i1) 1 pow2i1 }
(l / pow2i1 + 1) * pow2i1;
(<=) { Math.Lemmas.lemma_div_lt_nat l n (i + 1) }
pow2 (n - i - 1) * pow2 (i + 1);
(==) { Math.Lemmas.pow2_plus (n - i - 1) (i + 1) }
pow2 n;
}
inline_for_extraction
val transposewxw_f_l:
#w:width
-> #t:v_inttype
-> n:nat{pow2 n == w}
-> i:nat{i < n}
-> lseq (vec_t t w) w
-> l:nat{l < w} ->
vec_t t w
let transposewxw_f_l #w #t n i vs l =
Math.Lemmas.pow2_multiplication_modulo_lemma_1 1 i n;
if l % (2 * pow2 i) < pow2 i
then begin
lemma_l_plus_pow2i_lt #w n i l;
vec_interleave_low_n (pow2 i) vs.[l] vs.[l + pow2 i] end
else
vec_interleave_high_n (pow2 i) vs.[l - pow2 i] vs.[l]
inline_for_extraction
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
}
|
[
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"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": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 |
n: Prims.nat{Prims.pow2 n == w} ->
i: Prims.nat{i < n} ->
vs: Lib.Sequence.lseq (Lib.IntVector.vec_t t w) w
-> Lib.Sequence.lseq (Lib.IntVector.vec_t t w) w
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Lib.IntVector.width",
"Lib.IntVector.v_inttype",
"Prims.nat",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Prims.b2t",
"Prims.op_GreaterThan",
"Prims.l_and",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.max_size_t",
"Prims.pow2",
"Prims.op_LessThan",
"Lib.Sequence.lseq",
"Lib.IntVector.vec_t",
"Lib.Sequence.createi",
"Lib.IntVector.Transpose.transposewxw_f_l"
] |
[] | false | false | false | false | false |
let transposewxw_f #w #t n i vs =
|
createi w (transposewxw_f_l #w n i vs)
| false |
SelectorsLList3Example.fst
|
SelectorsLList3Example.cell
|
val cell : Type0
|
let cell = LL.cell a
|
{
"file_name": "share/steel/examples/steel/llist3/SelectorsLList3Example.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
}
|
{
"end_col": 20,
"end_line": 15,
"start_col": 0,
"start_line": 15
}
|
module SelectorsLList3Example
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
open Steel.ArrayRef
module L = FStar.List.Tot
module LL = Selectors.LList3
module U32 = FStar.UInt32
module MB = LowStar.Monotonic.Buffer // for is_null
|
{
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"Steel.ArrayRef.fsti.checked",
"Selectors.LList3.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "SelectorsLList3Example.fst"
}
|
[
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer // for is_null",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "Selectors.LList3",
"short_module": "LL"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.ArrayRef",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Selectors.LList3.cell",
"SelectorsLList3Example.a"
] |
[] | false | false | false | true | true |
let cell =
|
LL.cell a
| false |
|
Steel.LockCoupling.fsti
|
Steel.LockCoupling.half
|
val half : Steel.FractionalPermission.perm
|
let half = half_perm full_perm
|
{
"file_name": "lib/steel/Steel.LockCoupling.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
}
|
{
"end_col": 30,
"end_line": 51,
"start_col": 0,
"start_line": 51
}
|
(*
Copyright 2020 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 Steel.LockCoupling
open Steel.ST.Util
open Steel.ST.Reference
open Steel.FractionalPermission
(*
This example sketches how an invariant for lock-coupling list
(a list that stores a lock at each cell protecting its tail pointer)
might work.
It relies on strictly positive version of the exists and pts_to
separation logic predicates, although the libraries are not
currently annotated with such positivity annotations.=
*)
(* It is relatively easy to show that h_exists is strictly positive *)
val h_exists (#[@@@strictly_positive] a:Type)
([@@@strictly_positive] p:(a -> vprop))
: vprop
(* the pts_to predicate is a bit more subtle. It is an instance
of a more general form that involves assertions about a PCM,
and it is possible to construct PCMs that are not strictly
positive. However, the basic pts_to predicate that this refers to,
for the fractional permission PCM, is strictly positive.
Revising the library to enable decorating pts_to predicates derived
from positive PCMs remains to be done. *)
val pts_to (#[@@@strictly_positive] a:Type)
(r:ref a)
(f:perm)
(v:a) : vprop
val lock ([@@@strictly_positive] p:vprop) : Type0
|
{
"checked_file": "/",
"dependencies": [
"Steel.ST.Util.fsti.checked",
"Steel.ST.Reference.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.LockCoupling.fsti"
}
|
[
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.ST.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 |
Steel.FractionalPermission.perm
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Steel.FractionalPermission.half_perm",
"Steel.FractionalPermission.full_perm"
] |
[] | false | false | false | true | false |
let half =
|
half_perm full_perm
| false |
|
SelectorsLList3Example.fst
|
SelectorsLList3Example.next
|
val next (c: cell) : t
|
val next (c: cell) : t
|
let next (c:cell) : t = LL.next c
|
{
"file_name": "share/steel/examples/steel/llist3/SelectorsLList3Example.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
}
|
{
"end_col": 33,
"end_line": 19,
"start_col": 0,
"start_line": 19
}
|
module SelectorsLList3Example
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
open Steel.ArrayRef
module L = FStar.List.Tot
module LL = Selectors.LList3
module U32 = FStar.UInt32
module MB = LowStar.Monotonic.Buffer // for is_null
inline_for_extraction noextract let a = U32.t
let cell = LL.cell a
/// The type of a list: A reference to a cell
let t = LL.t a
|
{
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"Steel.ArrayRef.fsti.checked",
"Selectors.LList3.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "SelectorsLList3Example.fst"
}
|
[
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer // for is_null",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "Selectors.LList3",
"short_module": "LL"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.ArrayRef",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
c: SelectorsLList3Example.cell -> SelectorsLList3Example.t
|
Prims.Tot
|
[
"total"
] |
[] |
[
"SelectorsLList3Example.cell",
"Selectors.LList3.next",
"SelectorsLList3Example.a",
"SelectorsLList3Example.t"
] |
[] | false | false | false | true | false |
let next (c: cell) : t =
|
LL.next c
| false |
Lib.IntVector.Transpose.fst
|
Lib.IntVector.Transpose.transpose8x8_2
|
val transpose8x8_2: #t:v_inttype -> vec_t8 t -> vec_t8 t
|
val transpose8x8_2: #t:v_inttype -> vec_t8 t -> vec_t8 t
|
let transpose8x8_2 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 4 v0 v4 in
let v4' = vec_interleave_high_n 4 v0 v4 in
let v1' = vec_interleave_low_n 4 v1 v5 in
let v5' = vec_interleave_high_n 4 v1 v5 in
let v2' = vec_interleave_low_n 4 v2 v6 in
let v6' = vec_interleave_high_n 4 v2 v6 in
let v3' = vec_interleave_low_n 4 v3 v7 in
let v7' = vec_interleave_high_n 4 v3 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
|
{
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 35,
"end_line": 87,
"start_col": 0,
"start_line": 78
}
|
module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction
val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'')
inline_for_extraction
val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint64 #t vs = transpose4x4_0 #t vs
let transpose4x4 #t vs =
match t with
| U32 -> transpose4x4_uint32 #t vs
| U64 -> transpose4x4_uint64 #t vs
///
/// transpose8x8
///
inline_for_extraction
val transpose8x8_0: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v4' = vec_interleave_low v4 v5 in
let v5' = vec_interleave_high v4 v5 in
let v6' = vec_interleave_low v6 v7 in
let v7' = vec_interleave_high v6 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_1: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_1 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 2 v0 v2 in
let v2' = vec_interleave_high_n 2 v0 v2 in
let v1' = vec_interleave_low_n 2 v1 v3 in
let v3' = vec_interleave_high_n 2 v1 v3 in
let v4' = vec_interleave_low_n 2 v4 v6 in
let v6' = vec_interleave_high_n 2 v4 v6 in
let v5' = vec_interleave_low_n 2 v5 v7 in
let v7' = vec_interleave_high_n 2 v5 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
}
|
[
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"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": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 |
_: Lib.IntVector.Transpose.vec_t8 t -> Lib.IntVector.Transpose.vec_t8 t
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Lib.IntVector.v_inttype",
"Lib.IntVector.Transpose.vec_t8",
"Lib.IntVector.vec_t",
"FStar.Pervasives.Native.Mktuple8",
"Lib.IntVector.vec_interleave_high_n",
"Lib.IntVector.vec_interleave_low_n"
] |
[] | false | false | false | false | false |
let transpose8x8_2 #t (v0, v1, v2, v3, v4, v5, v6, v7) =
|
let v0' = vec_interleave_low_n 4 v0 v4 in
let v4' = vec_interleave_high_n 4 v0 v4 in
let v1' = vec_interleave_low_n 4 v1 v5 in
let v5' = vec_interleave_high_n 4 v1 v5 in
let v2' = vec_interleave_low_n 4 v2 v6 in
let v6' = vec_interleave_high_n 4 v2 v6 in
let v3' = vec_interleave_low_n 4 v3 v7 in
let v7' = vec_interleave_high_n 4 v3 v7 in
(v0', v1', v2', v3', v4', v5', v6', v7')
| false |
Lib.IntVector.Transpose.fst
|
Lib.IntVector.Transpose.transpose8x8
|
val transpose8x8: #t:v_inttype{t = U32} -> vec_t8 t -> vec_t8 t
|
val transpose8x8: #t:v_inttype{t = U32} -> vec_t8 t -> vec_t8 t
|
let transpose8x8 #t vs =
match t with
| U32 -> transpose8x8_uint32 #t vs
|
{
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 36,
"end_line": 109,
"start_col": 0,
"start_line": 107
}
|
module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction
val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'')
inline_for_extraction
val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint64 #t vs = transpose4x4_0 #t vs
let transpose4x4 #t vs =
match t with
| U32 -> transpose4x4_uint32 #t vs
| U64 -> transpose4x4_uint64 #t vs
///
/// transpose8x8
///
inline_for_extraction
val transpose8x8_0: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v4' = vec_interleave_low v4 v5 in
let v5' = vec_interleave_high v4 v5 in
let v6' = vec_interleave_low v6 v7 in
let v7' = vec_interleave_high v6 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_1: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_1 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 2 v0 v2 in
let v2' = vec_interleave_high_n 2 v0 v2 in
let v1' = vec_interleave_low_n 2 v1 v3 in
let v3' = vec_interleave_high_n 2 v1 v3 in
let v4' = vec_interleave_low_n 2 v4 v6 in
let v6' = vec_interleave_high_n 2 v4 v6 in
let v5' = vec_interleave_low_n 2 v5 v7 in
let v7' = vec_interleave_high_n 2 v5 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_2: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_2 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 4 v0 v4 in
let v4' = vec_interleave_high_n 4 v0 v4 in
let v1' = vec_interleave_low_n 4 v1 v5 in
let v5' = vec_interleave_high_n 4 v1 v5 in
let v2' = vec_interleave_low_n 4 v2 v6 in
let v6' = vec_interleave_high_n 4 v2 v6 in
let v3' = vec_interleave_low_n 4 v3 v7 in
let v7' = vec_interleave_high_n 4 v3 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_012: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_012 #t vs0 =
let (v0,v1,v2,v3,v4,v5,v6,v7) = vs0 in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_1 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_2 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_uint32: #t:v_inttype{t == U32} -> vec_t8 t -> vec_t8 t
let transpose8x8_uint32 #t vs0 =
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_012 #t vs0 in
(v0',v2',v1',v3',v4',v6',v5',v7')
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
}
|
[
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"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": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 |
vs: Lib.IntVector.Transpose.vec_t8 t -> Lib.IntVector.Transpose.vec_t8 t
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Lib.IntVector.v_inttype",
"Prims.b2t",
"Prims.op_Equality",
"Lib.IntTypes.inttype",
"Lib.IntTypes.U32",
"Lib.IntVector.Transpose.vec_t8",
"Lib.IntVector.Transpose.transpose8x8_uint32"
] |
[] | false | false | false | false | false |
let transpose8x8 #t vs =
|
match t with | U32 -> transpose8x8_uint32 #t vs
| false |
Lib.IntVector.Transpose.fst
|
Lib.IntVector.Transpose.transpose4x4_0
|
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
|
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
|
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
|
{
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 23,
"end_line": 24,
"start_col": 0,
"start_line": 14
}
|
module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
}
|
[
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"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": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 |
_: Lib.IntVector.Transpose.vec_t4 t -> Lib.IntVector.Transpose.vec_t4 t
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Lib.IntVector.v_inttype",
"Lib.IntVector.Transpose.vec_t4",
"Lib.IntVector.vec_t",
"FStar.Pervasives.Native.Mktuple4",
"Lib.IntVector.vec_interleave_high_n",
"Lib.IntVector.vec_interleave_low_n",
"Lib.IntVector.vec_interleave_high",
"Lib.IntVector.vec_interleave_low"
] |
[] | false | false | false | false | false |
let transpose4x4_0 #t (v0, v1, v2, v3) =
|
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'', v2'', v1'', v3'')
| false |
Lib.IntVector.Transpose.fst
|
Lib.IntVector.Transpose.transpose8x8_0
|
val transpose8x8_0: #t:v_inttype -> vec_t8 t -> vec_t8 t
|
val transpose8x8_0: #t:v_inttype -> vec_t8 t -> vec_t8 t
|
let transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v4' = vec_interleave_low v4 v5 in
let v5' = vec_interleave_high v4 v5 in
let v6' = vec_interleave_low v6 v7 in
let v7' = vec_interleave_high v6 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
|
{
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 35,
"end_line": 59,
"start_col": 0,
"start_line": 50
}
|
module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction
val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'')
inline_for_extraction
val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint64 #t vs = transpose4x4_0 #t vs
let transpose4x4 #t vs =
match t with
| U32 -> transpose4x4_uint32 #t vs
| U64 -> transpose4x4_uint64 #t vs
///
/// transpose8x8
///
inline_for_extraction
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
}
|
[
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"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": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 |
_: Lib.IntVector.Transpose.vec_t8 t -> Lib.IntVector.Transpose.vec_t8 t
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Lib.IntVector.v_inttype",
"Lib.IntVector.Transpose.vec_t8",
"Lib.IntVector.vec_t",
"FStar.Pervasives.Native.Mktuple8",
"Lib.IntVector.vec_interleave_high",
"Lib.IntVector.vec_interleave_low"
] |
[] | false | false | false | false | false |
let transpose8x8_0 #t (v0, v1, v2, v3, v4, v5, v6, v7) =
|
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v4' = vec_interleave_low v4 v5 in
let v5' = vec_interleave_high v4 v5 in
let v6' = vec_interleave_low v6 v7 in
let v7' = vec_interleave_high v6 v7 in
(v0', v1', v2', v3', v4', v5', v6', v7')
| false |
Lib.IntVector.Transpose.fst
|
Lib.IntVector.Transpose.transpose8x8_uint32
|
val transpose8x8_uint32: #t:v_inttype{t == U32} -> vec_t8 t -> vec_t8 t
|
val transpose8x8_uint32: #t:v_inttype{t == U32} -> vec_t8 t -> vec_t8 t
|
let transpose8x8_uint32 #t vs0 =
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_012 #t vs0 in
(v0',v2',v1',v3',v4',v6',v5',v7')
|
{
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 35,
"end_line": 104,
"start_col": 0,
"start_line": 102
}
|
module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction
val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'')
inline_for_extraction
val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint64 #t vs = transpose4x4_0 #t vs
let transpose4x4 #t vs =
match t with
| U32 -> transpose4x4_uint32 #t vs
| U64 -> transpose4x4_uint64 #t vs
///
/// transpose8x8
///
inline_for_extraction
val transpose8x8_0: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v4' = vec_interleave_low v4 v5 in
let v5' = vec_interleave_high v4 v5 in
let v6' = vec_interleave_low v6 v7 in
let v7' = vec_interleave_high v6 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_1: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_1 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 2 v0 v2 in
let v2' = vec_interleave_high_n 2 v0 v2 in
let v1' = vec_interleave_low_n 2 v1 v3 in
let v3' = vec_interleave_high_n 2 v1 v3 in
let v4' = vec_interleave_low_n 2 v4 v6 in
let v6' = vec_interleave_high_n 2 v4 v6 in
let v5' = vec_interleave_low_n 2 v5 v7 in
let v7' = vec_interleave_high_n 2 v5 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_2: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_2 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 4 v0 v4 in
let v4' = vec_interleave_high_n 4 v0 v4 in
let v1' = vec_interleave_low_n 4 v1 v5 in
let v5' = vec_interleave_high_n 4 v1 v5 in
let v2' = vec_interleave_low_n 4 v2 v6 in
let v6' = vec_interleave_high_n 4 v2 v6 in
let v3' = vec_interleave_low_n 4 v3 v7 in
let v7' = vec_interleave_high_n 4 v3 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_012: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_012 #t vs0 =
let (v0,v1,v2,v3,v4,v5,v6,v7) = vs0 in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_1 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_2 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
}
|
[
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"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": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 |
vs0: Lib.IntVector.Transpose.vec_t8 t -> Lib.IntVector.Transpose.vec_t8 t
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Lib.IntVector.v_inttype",
"Prims.eq2",
"Lib.IntTypes.inttype",
"Lib.IntTypes.U32",
"Lib.IntVector.Transpose.vec_t8",
"Lib.IntVector.vec_t",
"FStar.Pervasives.Native.Mktuple8",
"Lib.IntVector.Transpose.transpose8x8_012"
] |
[] | false | false | false | false | false |
let transpose8x8_uint32 #t vs0 =
|
let v0', v1', v2', v3', v4', v5', v6', v7' = transpose8x8_012 #t vs0 in
(v0', v2', v1', v3', v4', v6', v5', v7')
| false |
Lib.IntVector.Transpose.fst
|
Lib.IntVector.Transpose.transposewxw_lseq
|
val transposewxw_lseq: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> vs:lseq (vec_t t w) w -> lseq (vec_t t w) w
|
val transposewxw_lseq: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> vs:lseq (vec_t t w) w -> lseq (vec_t t w) w
|
let transposewxw_lseq #w #t n vs =
Loops.repeati n (transposewxw_f #w n) vs
|
{
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 42,
"end_line": 168,
"start_col": 0,
"start_line": 167
}
|
module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction
val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'')
inline_for_extraction
val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint64 #t vs = transpose4x4_0 #t vs
let transpose4x4 #t vs =
match t with
| U32 -> transpose4x4_uint32 #t vs
| U64 -> transpose4x4_uint64 #t vs
///
/// transpose8x8
///
inline_for_extraction
val transpose8x8_0: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v4' = vec_interleave_low v4 v5 in
let v5' = vec_interleave_high v4 v5 in
let v6' = vec_interleave_low v6 v7 in
let v7' = vec_interleave_high v6 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_1: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_1 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 2 v0 v2 in
let v2' = vec_interleave_high_n 2 v0 v2 in
let v1' = vec_interleave_low_n 2 v1 v3 in
let v3' = vec_interleave_high_n 2 v1 v3 in
let v4' = vec_interleave_low_n 2 v4 v6 in
let v6' = vec_interleave_high_n 2 v4 v6 in
let v5' = vec_interleave_low_n 2 v5 v7 in
let v7' = vec_interleave_high_n 2 v5 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_2: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_2 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 4 v0 v4 in
let v4' = vec_interleave_high_n 4 v0 v4 in
let v1' = vec_interleave_low_n 4 v1 v5 in
let v5' = vec_interleave_high_n 4 v1 v5 in
let v2' = vec_interleave_low_n 4 v2 v6 in
let v6' = vec_interleave_high_n 4 v2 v6 in
let v3' = vec_interleave_low_n 4 v3 v7 in
let v7' = vec_interleave_high_n 4 v3 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_012: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_012 #t vs0 =
let (v0,v1,v2,v3,v4,v5,v6,v7) = vs0 in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_1 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_2 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_uint32: #t:v_inttype{t == U32} -> vec_t8 t -> vec_t8 t
let transpose8x8_uint32 #t vs0 =
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_012 #t vs0 in
(v0',v2',v1',v3',v4',v6',v5',v7')
let transpose8x8 #t vs =
match t with
| U32 -> transpose8x8_uint32 #t vs
///
/// generic transpose
///
val lemma_l_plus_pow2i_lt: #w:pos -> n:nat{pow2 n == w} -> i:nat{i < n} -> l:nat{l < w} -> Lemma
(requires l % (2 * pow2 i) < pow2 i)
(ensures l + pow2 i < w)
let lemma_l_plus_pow2i_lt #w n i l =
let pow2i1 = pow2 (i + 1) in
calc (<) {
l + pow2 i;
(==) { Math.Lemmas.euclidean_division_definition l pow2i1 }
l / pow2i1 * pow2i1 + l % pow2i1 + pow2 i;
(==) { Math.Lemmas.pow2_plus 1 i }
l / pow2i1 * pow2i1 + l % (2 * pow2 i) + pow2 i;
(<) { assert (l % (2 * pow2 i) < pow2 i) }
l / pow2i1 * pow2i1 + pow2 i + pow2 i;
(==) { Math.Lemmas.pow2_double_sum i }
l / pow2i1 * pow2i1 + pow2i1;
(==) { Math.Lemmas.distributivity_add_left (l / pow2i1) 1 pow2i1 }
(l / pow2i1 + 1) * pow2i1;
(<=) { Math.Lemmas.lemma_div_lt_nat l n (i + 1) }
pow2 (n - i - 1) * pow2 (i + 1);
(==) { Math.Lemmas.pow2_plus (n - i - 1) (i + 1) }
pow2 n;
}
inline_for_extraction
val transposewxw_f_l:
#w:width
-> #t:v_inttype
-> n:nat{pow2 n == w}
-> i:nat{i < n}
-> lseq (vec_t t w) w
-> l:nat{l < w} ->
vec_t t w
let transposewxw_f_l #w #t n i vs l =
Math.Lemmas.pow2_multiplication_modulo_lemma_1 1 i n;
if l % (2 * pow2 i) < pow2 i
then begin
lemma_l_plus_pow2i_lt #w n i l;
vec_interleave_low_n (pow2 i) vs.[l] vs.[l + pow2 i] end
else
vec_interleave_high_n (pow2 i) vs.[l - pow2 i] vs.[l]
inline_for_extraction
val transposewxw_f: #w:width -> #t:v_inttype -> n:nat{pow2 n == w} -> i:nat{i < n} -> lseq (vec_t t w) w -> lseq (vec_t t w) w
let transposewxw_f #w #t n i vs =
createi w (transposewxw_f_l #w n i vs)
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
}
|
[
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"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": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 |
n: Prims.nat{Prims.pow2 n == w} -> vs: Lib.Sequence.lseq (Lib.IntVector.vec_t t w) w
-> Lib.Sequence.lseq (Lib.IntVector.vec_t t w) w
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Lib.IntVector.width",
"Lib.IntVector.v_inttype",
"Prims.nat",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Prims.b2t",
"Prims.op_GreaterThan",
"Prims.l_and",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.max_size_t",
"Prims.pow2",
"Lib.Sequence.lseq",
"Lib.IntVector.vec_t",
"Lib.LoopCombinators.repeati",
"Lib.IntVector.Transpose.transposewxw_f"
] |
[] | false | false | false | false | false |
let transposewxw_lseq #w #t n vs =
|
Loops.repeati n (transposewxw_f #w n) vs
| false |
SelectorsLList3Example.fst
|
SelectorsLList3Example.t
|
val t : Type0
|
let t = LL.t a
|
{
"file_name": "share/steel/examples/steel/llist3/SelectorsLList3Example.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
}
|
{
"end_col": 14,
"end_line": 17,
"start_col": 0,
"start_line": 17
}
|
module SelectorsLList3Example
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
open Steel.ArrayRef
module L = FStar.List.Tot
module LL = Selectors.LList3
module U32 = FStar.UInt32
module MB = LowStar.Monotonic.Buffer // for is_null
inline_for_extraction noextract let a = U32.t
let cell = LL.cell a
|
{
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"Steel.ArrayRef.fsti.checked",
"Selectors.LList3.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "SelectorsLList3Example.fst"
}
|
[
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer // for is_null",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "Selectors.LList3",
"short_module": "LL"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.ArrayRef",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
Type0
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Selectors.LList3.t",
"SelectorsLList3Example.a"
] |
[] | false | false | false | true | true |
let t =
|
LL.t a
| false |
|
SelectorsLList3Example.fst
|
SelectorsLList3Example.null_llist
|
val null_llist: Prims.unit -> t
|
val null_llist: Prims.unit -> t
|
let null_llist () : t = LL.null_llist
|
{
"file_name": "share/steel/examples/steel/llist3/SelectorsLList3Example.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
}
|
{
"end_col": 37,
"end_line": 30,
"start_col": 0,
"start_line": 30
}
|
module SelectorsLList3Example
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
open Steel.ArrayRef
module L = FStar.List.Tot
module LL = Selectors.LList3
module U32 = FStar.UInt32
module MB = LowStar.Monotonic.Buffer // for is_null
inline_for_extraction noextract let a = U32.t
let cell = LL.cell a
/// The type of a list: A reference to a cell
let t = LL.t a
let next (c:cell) : t = LL.next c
let data (c:cell) : a = LL.data c
let mk_cell (n: t) (d:a)
: Pure cell
(requires True)
(ensures fun c ->
next c == n /\
data c == d)
= LL.mk_cell n d
|
{
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"Steel.ArrayRef.fsti.checked",
"Selectors.LList3.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "SelectorsLList3Example.fst"
}
|
[
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer // for is_null",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "Selectors.LList3",
"short_module": "LL"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.ArrayRef",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
_: Prims.unit -> SelectorsLList3Example.t
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Prims.unit",
"Selectors.LList3.null_llist",
"SelectorsLList3Example.a",
"SelectorsLList3Example.t"
] |
[] | false | false | false | true | false |
let null_llist () : t =
|
LL.null_llist
| false |
SelectorsLList3Example.fst
|
SelectorsLList3Example.a
|
val a : Prims.eqtype
|
let a = U32.t
|
{
"file_name": "share/steel/examples/steel/llist3/SelectorsLList3Example.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
}
|
{
"end_col": 45,
"end_line": 14,
"start_col": 32,
"start_line": 14
}
|
module SelectorsLList3Example
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
open Steel.ArrayRef
module L = FStar.List.Tot
module LL = Selectors.LList3
module U32 = FStar.UInt32
module MB = LowStar.Monotonic.Buffer // for is_null
|
{
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"Steel.ArrayRef.fsti.checked",
"Selectors.LList3.fsti.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "SelectorsLList3Example.fst"
}
|
[
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer // for is_null",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "Selectors.LList3",
"short_module": "LL"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Steel.ArrayRef",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] |
{
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
}
| false |
Prims.eqtype
|
Prims.Tot
|
[
"total"
] |
[] |
[
"FStar.UInt32.t"
] |
[] | false | false | false | true | false |
let a =
|
U32.t
| false |
|
Lib.IntVector.Transpose.fst
|
Lib.IntVector.Transpose.transpose8x8_012
|
val transpose8x8_012: #t:v_inttype -> vec_t8 t -> vec_t8 t
|
val transpose8x8_012: #t:v_inttype -> vec_t8 t -> vec_t8 t
|
let transpose8x8_012 #t vs0 =
let (v0,v1,v2,v3,v4,v5,v6,v7) = vs0 in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_1 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
let (v0',v1',v2',v3',v4',v5',v6',v7') = transpose8x8_2 #t (v0',v1',v2',v3',v4',v5',v6',v7') in
(v0',v1',v2',v3',v4',v5',v6',v7')
|
{
"file_name": "lib/Lib.IntVector.Transpose.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
}
|
{
"end_col": 35,
"end_line": 97,
"start_col": 0,
"start_line": 92
}
|
module Lib.IntVector.Transpose
module Loops = Lib.LoopCombinators
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
///
/// transpose4x4
///
inline_for_extraction
val transpose4x4_0: #t:v_inttype -> vec_t4 t -> vec_t4 t
let transpose4x4_0 #t (v0,v1,v2,v3) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v0'' = vec_interleave_low_n 2 v0' v2' in
let v1'' = vec_interleave_high_n 2 v0' v2' in
let v2'' = vec_interleave_low_n 2 v1' v3' in
let v3'' = vec_interleave_high_n 2 v1' v3' in
(v0'',v2'',v1'',v3'')
inline_for_extraction
val transpose4x4_uint32: #t:v_inttype{t == U32} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint32 #t vs =
let (v0'',v2'',v1'',v3'') = transpose4x4_0 #t vs in
(v0'',v1'',v2'',v3'')
inline_for_extraction
val transpose4x4_uint64: #t:v_inttype{t == U64} -> vec_t4 t -> vec_t4 t
let transpose4x4_uint64 #t vs = transpose4x4_0 #t vs
let transpose4x4 #t vs =
match t with
| U32 -> transpose4x4_uint32 #t vs
| U64 -> transpose4x4_uint64 #t vs
///
/// transpose8x8
///
inline_for_extraction
val transpose8x8_0: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_0 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low v0 v1 in
let v1' = vec_interleave_high v0 v1 in
let v2' = vec_interleave_low v2 v3 in
let v3' = vec_interleave_high v2 v3 in
let v4' = vec_interleave_low v4 v5 in
let v5' = vec_interleave_high v4 v5 in
let v6' = vec_interleave_low v6 v7 in
let v7' = vec_interleave_high v6 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_1: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_1 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 2 v0 v2 in
let v2' = vec_interleave_high_n 2 v0 v2 in
let v1' = vec_interleave_low_n 2 v1 v3 in
let v3' = vec_interleave_high_n 2 v1 v3 in
let v4' = vec_interleave_low_n 2 v4 v6 in
let v6' = vec_interleave_high_n 2 v4 v6 in
let v5' = vec_interleave_low_n 2 v5 v7 in
let v7' = vec_interleave_high_n 2 v5 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
val transpose8x8_2: #t:v_inttype -> vec_t8 t -> vec_t8 t
let transpose8x8_2 #t (v0,v1,v2,v3,v4,v5,v6,v7) =
let v0' = vec_interleave_low_n 4 v0 v4 in
let v4' = vec_interleave_high_n 4 v0 v4 in
let v1' = vec_interleave_low_n 4 v1 v5 in
let v5' = vec_interleave_high_n 4 v1 v5 in
let v2' = vec_interleave_low_n 4 v2 v6 in
let v6' = vec_interleave_high_n 4 v2 v6 in
let v3' = vec_interleave_low_n 4 v3 v7 in
let v7' = vec_interleave_high_n 4 v3 v7 in
(v0',v1',v2',v3',v4',v5',v6',v7')
inline_for_extraction
|
{
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Transpose.fst"
}
|
[
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"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": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": 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 |
vs0: Lib.IntVector.Transpose.vec_t8 t -> Lib.IntVector.Transpose.vec_t8 t
|
Prims.Tot
|
[
"total"
] |
[] |
[
"Lib.IntVector.v_inttype",
"Lib.IntVector.Transpose.vec_t8",
"Lib.IntVector.vec_t",
"FStar.Pervasives.Native.Mktuple8",
"Lib.IntVector.Transpose.transpose8x8_2",
"Lib.IntVector.Transpose.transpose8x8_1",
"Lib.IntVector.Transpose.transpose8x8_0"
] |
[] | false | false | false | false | false |
let transpose8x8_012 #t vs0 =
|
let v0, v1, v2, v3, v4, v5, v6, v7 = vs0 in
let v0', v1', v2', v3', v4', v5', v6', v7' = transpose8x8_0 #t (v0, v1, v2, v3, v4, v5, v6, v7) in
let v0', v1', v2', v3', v4', v5', v6', v7' =
transpose8x8_1 #t (v0', v1', v2', v3', v4', v5', v6', v7')
in
let v0', v1', v2', v3', v4', v5', v6', v7' =
transpose8x8_2 #t (v0', v1', v2', v3', v4', v5', v6', v7')
in
(v0', v1', v2', v3', v4', v5', v6', v7')
| false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.