effect
stringclasses
48 values
original_source_type
stringlengths
0
23k
opens_and_abbrevs
listlengths
2
92
isa_cross_project_example
bool
1 class
source_definition
stringlengths
9
57.9k
partial_definition
stringlengths
7
23.3k
is_div
bool
2 classes
is_type
null
is_proof
bool
2 classes
completed_definiton
stringlengths
1
250k
dependencies
dict
effect_flags
sequencelengths
0
2
ideal_premises
sequencelengths
0
236
mutual_with
sequencelengths
0
11
file_context
stringlengths
0
407k
interleaved
bool
1 class
is_simply_typed
bool
2 classes
file_name
stringlengths
5
48
vconfig
dict
is_simple_lemma
null
source_type
stringlengths
10
23k
proof_features
sequencelengths
0
1
name
stringlengths
8
95
source
dict
verbose_type
stringlengths
1
7.42k
source_range
dict
FStar.HyperStack.ST.Stack
val get_bp_c_matrices: a:FP.frodo_alg -> ct:lbytes (crypto_ciphertextbytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h ct /\ live h bp_matrix /\ live h c_matrix /\ disjoint bp_matrix ct /\ disjoint c_matrix ct /\ disjoint bp_matrix c_matrix) (ensures fun h0 _ h1 -> modifies (loc bp_matrix |+| loc c_matrix) h0 h1 /\ (as_matrix h1 bp_matrix, as_matrix h1 c_matrix) == S.get_bp_c_matrices a (as_seq h0 ct))
[ { "abbrev": true, "full_module": "Spec.Matrix", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Frodo.KEM.Decaps", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Impl.Frodo.KEM.KeyGen", "short_module": "KG" }, { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "FP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Frodo.Random", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Sample", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Pack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Encode", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM.Encaps", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Params", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let get_bp_c_matrices a ct bp_matrix c_matrix = let c1 = sub ct 0ul (ct1bytes_len a) in let c2 = sub ct (ct1bytes_len a) (ct2bytes_len a) in frodo_unpack params_nbar (params_n a) (params_logq a) c1 bp_matrix; frodo_unpack params_nbar params_nbar (params_logq a) c2 c_matrix
val get_bp_c_matrices: a:FP.frodo_alg -> ct:lbytes (crypto_ciphertextbytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h ct /\ live h bp_matrix /\ live h c_matrix /\ disjoint bp_matrix ct /\ disjoint c_matrix ct /\ disjoint bp_matrix c_matrix) (ensures fun h0 _ h1 -> modifies (loc bp_matrix |+| loc c_matrix) h0 h1 /\ (as_matrix h1 bp_matrix, as_matrix h1 c_matrix) == S.get_bp_c_matrices a (as_seq h0 ct)) let get_bp_c_matrices a ct bp_matrix c_matrix =
true
null
false
let c1 = sub ct 0ul (ct1bytes_len a) in let c2 = sub ct (ct1bytes_len a) (ct2bytes_len a) in frodo_unpack params_nbar (params_n a) (params_logq a) c1 bp_matrix; frodo_unpack params_nbar params_nbar (params_logq a) c2 c_matrix
{ "checked_file": "Hacl.Impl.Frodo.KEM.Decaps.fst.checked", "dependencies": [ "Spec.Matrix.fst.checked", "Spec.Frodo.Params.fst.checked", "Spec.Frodo.KEM.Decaps.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Sample.fst.checked", "Hacl.Impl.Frodo.Params.fst.checked", "Hacl.Impl.Frodo.Pack.fst.checked", "Hacl.Impl.Frodo.KEM.KeyGen.fst.checked", "Hacl.Impl.Frodo.KEM.Encaps.fst.checked", "Hacl.Impl.Frodo.KEM.fst.checked", "Hacl.Impl.Frodo.Encode.fst.checked", "Hacl.Frodo.Random.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.KEM.Decaps.fst" }
[]
[ "Spec.Frodo.Params.frodo_alg", "Hacl.Impl.Matrix.lbytes", "Hacl.Impl.Frodo.Params.crypto_ciphertextbytes", "Hacl.Impl.Matrix.matrix_t", "Hacl.Impl.Frodo.Params.params_nbar", "Hacl.Impl.Frodo.Params.params_n", "Hacl.Impl.Frodo.Pack.frodo_unpack", "Hacl.Impl.Frodo.Params.params_logq", "Prims.unit", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Hacl.Impl.Frodo.Params.ct2bytes_len", "Lib.Buffer.sub", "Lib.IntTypes.uint8", "Hacl.Impl.Frodo.Params.ct1bytes_len", "FStar.UInt32.__uint_to_t" ]
[]
module Hacl.Impl.Frodo.KEM.Decaps open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix open Hacl.Impl.Frodo.Params open Hacl.Impl.Frodo.KEM open Hacl.Impl.Frodo.KEM.Encaps open Hacl.Impl.Frodo.Encode open Hacl.Impl.Frodo.Pack open Hacl.Impl.Frodo.Sample open Hacl.Frodo.Random module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module FP = Spec.Frodo.Params module KG = Hacl.Impl.Frodo.KEM.KeyGen module S = Spec.Frodo.KEM.Decaps module M = Spec.Matrix #set-options "--z3rlimit 100 --fuel 0 --ifuel 0" inline_for_extraction noextract val get_bp_c_matrices: a:FP.frodo_alg -> ct:lbytes (crypto_ciphertextbytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h ct /\ live h bp_matrix /\ live h c_matrix /\ disjoint bp_matrix ct /\ disjoint c_matrix ct /\ disjoint bp_matrix c_matrix) (ensures fun h0 _ h1 -> modifies (loc bp_matrix |+| loc c_matrix) h0 h1 /\ (as_matrix h1 bp_matrix, as_matrix h1 c_matrix) == S.get_bp_c_matrices a (as_seq h0 ct))
false
false
Hacl.Impl.Frodo.KEM.Decaps.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val get_bp_c_matrices: a:FP.frodo_alg -> ct:lbytes (crypto_ciphertextbytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h ct /\ live h bp_matrix /\ live h c_matrix /\ disjoint bp_matrix ct /\ disjoint c_matrix ct /\ disjoint bp_matrix c_matrix) (ensures fun h0 _ h1 -> modifies (loc bp_matrix |+| loc c_matrix) h0 h1 /\ (as_matrix h1 bp_matrix, as_matrix h1 c_matrix) == S.get_bp_c_matrices a (as_seq h0 ct))
[]
Hacl.Impl.Frodo.KEM.Decaps.get_bp_c_matrices
{ "file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Decaps.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_alg -> ct: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_ciphertextbytes a) -> bp_matrix: Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar (Hacl.Impl.Frodo.Params.params_n a) -> c_matrix: Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar Hacl.Impl.Frodo.Params.params_nbar -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 66, "end_line": 48, "start_col": 47, "start_line": 44 }
FStar.HyperStack.ST.Stack
val crypto_kem_dec_ss0: a:FP.frodo_alg -> ct:lbytes (crypto_ciphertextbytes a) -> mask:uint16{v mask == 0 \/ v mask == v (ones U16 SEC)} -> kp:lbytes (crypto_bytes a) -> s:lbytes (crypto_bytes a) -> ss:lbytes (crypto_bytes a) -> Stack unit (requires fun h -> live h ct /\ live h kp /\ live h s /\ live h ss /\ disjoint ss ct /\ disjoint ss kp /\ disjoint ss s /\ disjoint kp s) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ss0 a (as_seq h0 ct) mask (as_seq h0 kp) (as_seq h0 s))
[ { "abbrev": true, "full_module": "Spec.Matrix", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Frodo.KEM.Decaps", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Impl.Frodo.KEM.KeyGen", "short_module": "KG" }, { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "FP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Frodo.Random", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Sample", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Pack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Encode", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM.Encaps", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Params", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let crypto_kem_dec_ss0 a ct mask kp s ss = push_frame (); let kp_s = create (crypto_bytes a) (u8 0) in Lib.ByteBuffer.buf_mask_select kp s (to_u8 mask) kp_s; let ss_init_len = crypto_ciphertextbytes a +! crypto_bytes a in let ss_init = create ss_init_len (u8 0) in concat2 (crypto_ciphertextbytes a) ct (crypto_bytes a) kp_s ss_init; frodo_shake a ss_init_len ss_init (crypto_bytes a) ss; clear_words_u8 ss_init; clear_words_u8 kp_s; pop_frame ()
val crypto_kem_dec_ss0: a:FP.frodo_alg -> ct:lbytes (crypto_ciphertextbytes a) -> mask:uint16{v mask == 0 \/ v mask == v (ones U16 SEC)} -> kp:lbytes (crypto_bytes a) -> s:lbytes (crypto_bytes a) -> ss:lbytes (crypto_bytes a) -> Stack unit (requires fun h -> live h ct /\ live h kp /\ live h s /\ live h ss /\ disjoint ss ct /\ disjoint ss kp /\ disjoint ss s /\ disjoint kp s) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ss0 a (as_seq h0 ct) mask (as_seq h0 kp) (as_seq h0 s)) let crypto_kem_dec_ss0 a ct mask kp s ss =
true
null
false
push_frame (); let kp_s = create (crypto_bytes a) (u8 0) in Lib.ByteBuffer.buf_mask_select kp s (to_u8 mask) kp_s; let ss_init_len = crypto_ciphertextbytes a +! crypto_bytes a in let ss_init = create ss_init_len (u8 0) in concat2 (crypto_ciphertextbytes a) ct (crypto_bytes a) kp_s ss_init; frodo_shake a ss_init_len ss_init (crypto_bytes a) ss; clear_words_u8 ss_init; clear_words_u8 kp_s; pop_frame ()
{ "checked_file": "Hacl.Impl.Frodo.KEM.Decaps.fst.checked", "dependencies": [ "Spec.Matrix.fst.checked", "Spec.Frodo.Params.fst.checked", "Spec.Frodo.KEM.Decaps.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Sample.fst.checked", "Hacl.Impl.Frodo.Params.fst.checked", "Hacl.Impl.Frodo.Pack.fst.checked", "Hacl.Impl.Frodo.KEM.KeyGen.fst.checked", "Hacl.Impl.Frodo.KEM.Encaps.fst.checked", "Hacl.Impl.Frodo.KEM.fst.checked", "Hacl.Impl.Frodo.Encode.fst.checked", "Hacl.Frodo.Random.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.KEM.Decaps.fst" }
[]
[ "Spec.Frodo.Params.frodo_alg", "Hacl.Impl.Matrix.lbytes", "Hacl.Impl.Frodo.Params.crypto_ciphertextbytes", "Lib.IntTypes.uint16", "Prims.l_or", "Prims.eq2", "Prims.int", "Lib.IntTypes.v", "Lib.IntTypes.U16", "Lib.IntTypes.SEC", "Lib.IntTypes.range_t", "Lib.IntTypes.ones", "Hacl.Impl.Frodo.Params.crypto_bytes", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Impl.Frodo.KEM.clear_words_u8", "Hacl.Impl.Frodo.Params.frodo_shake", "Lib.Buffer.concat2", "Lib.Buffer.MUT", "Lib.IntTypes.uint8", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.Buffer.create", "Lib.IntTypes.u8", "Lib.Buffer.lbuffer", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.IntTypes.op_Plus_Bang", "Lib.ByteBuffer.buf_mask_select", "Lib.IntTypes.to_u8", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Impl.Frodo.KEM.Decaps open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix open Hacl.Impl.Frodo.Params open Hacl.Impl.Frodo.KEM open Hacl.Impl.Frodo.KEM.Encaps open Hacl.Impl.Frodo.Encode open Hacl.Impl.Frodo.Pack open Hacl.Impl.Frodo.Sample open Hacl.Frodo.Random module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module FP = Spec.Frodo.Params module KG = Hacl.Impl.Frodo.KEM.KeyGen module S = Spec.Frodo.KEM.Decaps module M = Spec.Matrix #set-options "--z3rlimit 100 --fuel 0 --ifuel 0" inline_for_extraction noextract val get_bp_c_matrices: a:FP.frodo_alg -> ct:lbytes (crypto_ciphertextbytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h ct /\ live h bp_matrix /\ live h c_matrix /\ disjoint bp_matrix ct /\ disjoint c_matrix ct /\ disjoint bp_matrix c_matrix) (ensures fun h0 _ h1 -> modifies (loc bp_matrix |+| loc c_matrix) h0 h1 /\ (as_matrix h1 bp_matrix, as_matrix h1 c_matrix) == S.get_bp_c_matrices a (as_seq h0 ct)) let get_bp_c_matrices a ct bp_matrix c_matrix = let c1 = sub ct 0ul (ct1bytes_len a) in let c2 = sub ct (ct1bytes_len a) (ct2bytes_len a) in frodo_unpack params_nbar (params_n a) (params_logq a) c1 bp_matrix; frodo_unpack params_nbar params_nbar (params_logq a) c2 c_matrix inline_for_extraction noextract val frodo_mu_decode: a:FP.frodo_alg -> s_bytes:lbytes (secretmatrixbytes_len a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> mu_decode:lbytes (bytes_mu a) -> Stack unit (requires fun h -> live h s_bytes /\ live h bp_matrix /\ live h c_matrix /\ live h mu_decode /\ disjoint mu_decode s_bytes /\ as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc mu_decode) h0 h1 /\ as_seq h1 mu_decode == S.frodo_mu_decode a (as_seq h0 s_bytes) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let frodo_mu_decode a s_bytes bp_matrix c_matrix mu_decode = push_frame(); let s_matrix = matrix_create (params_n a) params_nbar in let m_matrix = matrix_create params_nbar params_nbar in matrix_from_lbytes s_bytes s_matrix; matrix_mul_s bp_matrix s_matrix m_matrix; matrix_sub c_matrix m_matrix; frodo_key_decode (params_logq a) (params_extracted_bits a) params_nbar m_matrix mu_decode; clear_matrix s_matrix; clear_matrix m_matrix; pop_frame() inline_for_extraction noextract val get_bpp_cp_matrices_: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> sk:lbytes (crypto_secretkeybytes a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> cp_matrix:matrix_t params_nbar params_nbar -> sp_matrix:matrix_t params_nbar (params_n a) -> ep_matrix:matrix_t params_nbar (params_n a) -> epp_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h mu_decode /\ live h sk /\ live h bpp_matrix /\ live h cp_matrix /\ live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\ loc_pairwise_disjoint [loc mu_decode; loc sk; loc bpp_matrix; loc cp_matrix; loc sp_matrix; loc ep_matrix; loc epp_matrix]) (ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\ (as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) == S.get_bpp_cp_matrices_ a gen_a (as_seq h0 mu_decode) (as_seq h0 sk) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix) (as_matrix h0 epp_matrix)) let get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix = FP.expand_crypto_secretkeybytes a; FP.expand_crypto_publickeybytes a; let pk = sub sk (crypto_bytes a) (crypto_publickeybytes a) in let seed_a = sub pk 0ul bytes_seed_a in let b = sub pk bytes_seed_a (crypto_publickeybytes a -! bytes_seed_a) in frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bpp_matrix; frodo_mul_add_sb_plus_e_plus_mu a mu_decode b sp_matrix epp_matrix cp_matrix; mod_pow2 (params_logq a) bpp_matrix; mod_pow2 (params_logq a) cp_matrix #push-options "--z3rlimit 150" inline_for_extraction noextract val get_bpp_cp_matrices: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> seed_se:lbytes (crypto_bytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> cp_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h seed_se /\ live h mu_decode /\ live h sk /\ live h bpp_matrix /\ live h cp_matrix /\ loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk; loc bpp_matrix; loc cp_matrix]) (ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\ (as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) == S.get_bpp_cp_matrices a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se) (as_seq h0 sk)) let get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix = push_frame (); let sp_matrix = matrix_create params_nbar (params_n a) in let ep_matrix = matrix_create params_nbar (params_n a) in let epp_matrix = matrix_create params_nbar params_nbar in get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix; get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix; clear_matrix3 a sp_matrix ep_matrix epp_matrix; pop_frame () #pop-options inline_for_extraction noextract val crypto_kem_dec_kp_s_cond: a:FP.frodo_alg -> bp_matrix:matrix_t params_nbar (params_n a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> cp_matrix:matrix_t params_nbar params_nbar -> Stack uint16 (requires fun h -> live h bp_matrix /\ live h bpp_matrix /\ live h c_matrix /\ live h cp_matrix) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.crypto_kem_dec_kp_s_cond a (as_matrix h0 bp_matrix) (as_matrix h0 bpp_matrix) (as_matrix h0 c_matrix) (as_matrix h0 cp_matrix)) let crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix = let b1 = matrix_eq bp_matrix bpp_matrix in let b2 = matrix_eq c_matrix cp_matrix in b1 &. b2 inline_for_extraction noextract val crypto_kem_dec_kp_s: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> seed_se:lbytes (crypto_bytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack uint16 (requires fun h -> live h mu_decode /\ live h bp_matrix /\ live h seed_se /\ live h c_matrix /\ live h sk /\ loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk]) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.crypto_kem_dec_kp_s a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se) (as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let crypto_kem_dec_kp_s a gen_a mu_decode seed_se sk bp_matrix c_matrix = push_frame (); let bpp_matrix = matrix_create params_nbar (params_n a) in let cp_matrix = matrix_create params_nbar params_nbar in get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix; let mask = crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix in pop_frame (); mask inline_for_extraction noextract val crypto_kem_dec_ss0: a:FP.frodo_alg -> ct:lbytes (crypto_ciphertextbytes a) -> mask:uint16{v mask == 0 \/ v mask == v (ones U16 SEC)} -> kp:lbytes (crypto_bytes a) -> s:lbytes (crypto_bytes a) -> ss:lbytes (crypto_bytes a) -> Stack unit (requires fun h -> live h ct /\ live h kp /\ live h s /\ live h ss /\ disjoint ss ct /\ disjoint ss kp /\ disjoint ss s /\ disjoint kp s) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ss0 a (as_seq h0 ct) mask (as_seq h0 kp) (as_seq h0 s))
false
false
Hacl.Impl.Frodo.KEM.Decaps.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val crypto_kem_dec_ss0: a:FP.frodo_alg -> ct:lbytes (crypto_ciphertextbytes a) -> mask:uint16{v mask == 0 \/ v mask == v (ones U16 SEC)} -> kp:lbytes (crypto_bytes a) -> s:lbytes (crypto_bytes a) -> ss:lbytes (crypto_bytes a) -> Stack unit (requires fun h -> live h ct /\ live h kp /\ live h s /\ live h ss /\ disjoint ss ct /\ disjoint ss kp /\ disjoint ss s /\ disjoint kp s) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ss0 a (as_seq h0 ct) mask (as_seq h0 kp) (as_seq h0 s))
[]
Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec_ss0
{ "file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Decaps.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_alg -> ct: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_ciphertextbytes a) -> mask: Lib.IntTypes.uint16 { Lib.IntTypes.v mask == 0 \/ Lib.IntTypes.v mask == Lib.IntTypes.v (Lib.IntTypes.ones Lib.IntTypes.U16 Lib.IntTypes.SEC) } -> kp: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_bytes a) -> s: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_bytes a) -> ss: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_bytes a) -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 14, "end_line": 224, "start_col": 2, "start_line": 214 }
FStar.HyperStack.ST.Stack
val crypto_kem_dec_seed_se_k: a:FP.frodo_alg -> mu_decode:lbytes (bytes_mu a) -> sk:lbytes (crypto_secretkeybytes a) -> seed_se_k:lbytes (2ul *! crypto_bytes a) -> Stack unit (requires fun h -> live h mu_decode /\ live h sk /\ live h seed_se_k /\ disjoint mu_decode seed_se_k /\ disjoint sk seed_se_k) (ensures fun h0 _ h1 -> modifies (loc seed_se_k) h0 h1 /\ as_seq h1 seed_se_k == S.crypto_kem_dec_seed_se_k a (as_seq h0 mu_decode) (as_seq h0 sk))
[ { "abbrev": true, "full_module": "Spec.Matrix", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Frodo.KEM.Decaps", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Impl.Frodo.KEM.KeyGen", "short_module": "KG" }, { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "FP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Frodo.Random", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Sample", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Pack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Encode", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM.Encaps", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Params", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let crypto_kem_dec_seed_se_k a mu_decode sk seed_se_k = push_frame (); let pkh_mu_decode_len = bytes_pkhash a +! bytes_mu a in let pkh_mu_decode = create pkh_mu_decode_len (u8 0) in let pkh = sub sk (crypto_secretkeybytes a -! bytes_pkhash a) (bytes_pkhash a) in concat2 (bytes_pkhash a) pkh (bytes_mu a) mu_decode pkh_mu_decode; frodo_shake a pkh_mu_decode_len pkh_mu_decode (2ul *! crypto_bytes a) seed_se_k; pop_frame ()
val crypto_kem_dec_seed_se_k: a:FP.frodo_alg -> mu_decode:lbytes (bytes_mu a) -> sk:lbytes (crypto_secretkeybytes a) -> seed_se_k:lbytes (2ul *! crypto_bytes a) -> Stack unit (requires fun h -> live h mu_decode /\ live h sk /\ live h seed_se_k /\ disjoint mu_decode seed_se_k /\ disjoint sk seed_se_k) (ensures fun h0 _ h1 -> modifies (loc seed_se_k) h0 h1 /\ as_seq h1 seed_se_k == S.crypto_kem_dec_seed_se_k a (as_seq h0 mu_decode) (as_seq h0 sk)) let crypto_kem_dec_seed_se_k a mu_decode sk seed_se_k =
true
null
false
push_frame (); let pkh_mu_decode_len = bytes_pkhash a +! bytes_mu a in let pkh_mu_decode = create pkh_mu_decode_len (u8 0) in let pkh = sub sk (crypto_secretkeybytes a -! bytes_pkhash a) (bytes_pkhash a) in concat2 (bytes_pkhash a) pkh (bytes_mu a) mu_decode pkh_mu_decode; frodo_shake a pkh_mu_decode_len pkh_mu_decode (2ul *! crypto_bytes a) seed_se_k; pop_frame ()
{ "checked_file": "Hacl.Impl.Frodo.KEM.Decaps.fst.checked", "dependencies": [ "Spec.Matrix.fst.checked", "Spec.Frodo.Params.fst.checked", "Spec.Frodo.KEM.Decaps.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Sample.fst.checked", "Hacl.Impl.Frodo.Params.fst.checked", "Hacl.Impl.Frodo.Pack.fst.checked", "Hacl.Impl.Frodo.KEM.KeyGen.fst.checked", "Hacl.Impl.Frodo.KEM.Encaps.fst.checked", "Hacl.Impl.Frodo.KEM.fst.checked", "Hacl.Impl.Frodo.Encode.fst.checked", "Hacl.Frodo.Random.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.KEM.Decaps.fst" }
[]
[ "Spec.Frodo.Params.frodo_alg", "Hacl.Impl.Matrix.lbytes", "Hacl.Impl.Frodo.Params.bytes_mu", "Hacl.Impl.Frodo.Params.crypto_secretkeybytes", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Frodo.Params.crypto_bytes", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Impl.Frodo.Params.frodo_shake", "Lib.Buffer.concat2", "Lib.Buffer.MUT", "Lib.IntTypes.uint8", "Hacl.Impl.Frodo.Params.bytes_pkhash", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.sub", "Lib.IntTypes.op_Subtraction_Bang", "Lib.Buffer.create", "Lib.IntTypes.u8", "Lib.Buffer.lbuffer", "Lib.IntTypes.op_Plus_Bang", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Impl.Frodo.KEM.Decaps open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix open Hacl.Impl.Frodo.Params open Hacl.Impl.Frodo.KEM open Hacl.Impl.Frodo.KEM.Encaps open Hacl.Impl.Frodo.Encode open Hacl.Impl.Frodo.Pack open Hacl.Impl.Frodo.Sample open Hacl.Frodo.Random module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module FP = Spec.Frodo.Params module KG = Hacl.Impl.Frodo.KEM.KeyGen module S = Spec.Frodo.KEM.Decaps module M = Spec.Matrix #set-options "--z3rlimit 100 --fuel 0 --ifuel 0" inline_for_extraction noextract val get_bp_c_matrices: a:FP.frodo_alg -> ct:lbytes (crypto_ciphertextbytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h ct /\ live h bp_matrix /\ live h c_matrix /\ disjoint bp_matrix ct /\ disjoint c_matrix ct /\ disjoint bp_matrix c_matrix) (ensures fun h0 _ h1 -> modifies (loc bp_matrix |+| loc c_matrix) h0 h1 /\ (as_matrix h1 bp_matrix, as_matrix h1 c_matrix) == S.get_bp_c_matrices a (as_seq h0 ct)) let get_bp_c_matrices a ct bp_matrix c_matrix = let c1 = sub ct 0ul (ct1bytes_len a) in let c2 = sub ct (ct1bytes_len a) (ct2bytes_len a) in frodo_unpack params_nbar (params_n a) (params_logq a) c1 bp_matrix; frodo_unpack params_nbar params_nbar (params_logq a) c2 c_matrix inline_for_extraction noextract val frodo_mu_decode: a:FP.frodo_alg -> s_bytes:lbytes (secretmatrixbytes_len a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> mu_decode:lbytes (bytes_mu a) -> Stack unit (requires fun h -> live h s_bytes /\ live h bp_matrix /\ live h c_matrix /\ live h mu_decode /\ disjoint mu_decode s_bytes /\ as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc mu_decode) h0 h1 /\ as_seq h1 mu_decode == S.frodo_mu_decode a (as_seq h0 s_bytes) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let frodo_mu_decode a s_bytes bp_matrix c_matrix mu_decode = push_frame(); let s_matrix = matrix_create (params_n a) params_nbar in let m_matrix = matrix_create params_nbar params_nbar in matrix_from_lbytes s_bytes s_matrix; matrix_mul_s bp_matrix s_matrix m_matrix; matrix_sub c_matrix m_matrix; frodo_key_decode (params_logq a) (params_extracted_bits a) params_nbar m_matrix mu_decode; clear_matrix s_matrix; clear_matrix m_matrix; pop_frame() inline_for_extraction noextract val get_bpp_cp_matrices_: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> sk:lbytes (crypto_secretkeybytes a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> cp_matrix:matrix_t params_nbar params_nbar -> sp_matrix:matrix_t params_nbar (params_n a) -> ep_matrix:matrix_t params_nbar (params_n a) -> epp_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h mu_decode /\ live h sk /\ live h bpp_matrix /\ live h cp_matrix /\ live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\ loc_pairwise_disjoint [loc mu_decode; loc sk; loc bpp_matrix; loc cp_matrix; loc sp_matrix; loc ep_matrix; loc epp_matrix]) (ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\ (as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) == S.get_bpp_cp_matrices_ a gen_a (as_seq h0 mu_decode) (as_seq h0 sk) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix) (as_matrix h0 epp_matrix)) let get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix = FP.expand_crypto_secretkeybytes a; FP.expand_crypto_publickeybytes a; let pk = sub sk (crypto_bytes a) (crypto_publickeybytes a) in let seed_a = sub pk 0ul bytes_seed_a in let b = sub pk bytes_seed_a (crypto_publickeybytes a -! bytes_seed_a) in frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bpp_matrix; frodo_mul_add_sb_plus_e_plus_mu a mu_decode b sp_matrix epp_matrix cp_matrix; mod_pow2 (params_logq a) bpp_matrix; mod_pow2 (params_logq a) cp_matrix #push-options "--z3rlimit 150" inline_for_extraction noextract val get_bpp_cp_matrices: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> seed_se:lbytes (crypto_bytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> cp_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h seed_se /\ live h mu_decode /\ live h sk /\ live h bpp_matrix /\ live h cp_matrix /\ loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk; loc bpp_matrix; loc cp_matrix]) (ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\ (as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) == S.get_bpp_cp_matrices a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se) (as_seq h0 sk)) let get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix = push_frame (); let sp_matrix = matrix_create params_nbar (params_n a) in let ep_matrix = matrix_create params_nbar (params_n a) in let epp_matrix = matrix_create params_nbar params_nbar in get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix; get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix; clear_matrix3 a sp_matrix ep_matrix epp_matrix; pop_frame () #pop-options inline_for_extraction noextract val crypto_kem_dec_kp_s_cond: a:FP.frodo_alg -> bp_matrix:matrix_t params_nbar (params_n a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> cp_matrix:matrix_t params_nbar params_nbar -> Stack uint16 (requires fun h -> live h bp_matrix /\ live h bpp_matrix /\ live h c_matrix /\ live h cp_matrix) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.crypto_kem_dec_kp_s_cond a (as_matrix h0 bp_matrix) (as_matrix h0 bpp_matrix) (as_matrix h0 c_matrix) (as_matrix h0 cp_matrix)) let crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix = let b1 = matrix_eq bp_matrix bpp_matrix in let b2 = matrix_eq c_matrix cp_matrix in b1 &. b2 inline_for_extraction noextract val crypto_kem_dec_kp_s: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> seed_se:lbytes (crypto_bytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack uint16 (requires fun h -> live h mu_decode /\ live h bp_matrix /\ live h seed_se /\ live h c_matrix /\ live h sk /\ loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk]) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.crypto_kem_dec_kp_s a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se) (as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let crypto_kem_dec_kp_s a gen_a mu_decode seed_se sk bp_matrix c_matrix = push_frame (); let bpp_matrix = matrix_create params_nbar (params_n a) in let cp_matrix = matrix_create params_nbar params_nbar in get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix; let mask = crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix in pop_frame (); mask inline_for_extraction noextract val crypto_kem_dec_ss0: a:FP.frodo_alg -> ct:lbytes (crypto_ciphertextbytes a) -> mask:uint16{v mask == 0 \/ v mask == v (ones U16 SEC)} -> kp:lbytes (crypto_bytes a) -> s:lbytes (crypto_bytes a) -> ss:lbytes (crypto_bytes a) -> Stack unit (requires fun h -> live h ct /\ live h kp /\ live h s /\ live h ss /\ disjoint ss ct /\ disjoint ss kp /\ disjoint ss s /\ disjoint kp s) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ss0 a (as_seq h0 ct) mask (as_seq h0 kp) (as_seq h0 s)) let crypto_kem_dec_ss0 a ct mask kp s ss = push_frame (); let kp_s = create (crypto_bytes a) (u8 0) in Lib.ByteBuffer.buf_mask_select kp s (to_u8 mask) kp_s; let ss_init_len = crypto_ciphertextbytes a +! crypto_bytes a in let ss_init = create ss_init_len (u8 0) in concat2 (crypto_ciphertextbytes a) ct (crypto_bytes a) kp_s ss_init; frodo_shake a ss_init_len ss_init (crypto_bytes a) ss; clear_words_u8 ss_init; clear_words_u8 kp_s; pop_frame () inline_for_extraction noextract val crypto_kem_dec_seed_se_k: a:FP.frodo_alg -> mu_decode:lbytes (bytes_mu a) -> sk:lbytes (crypto_secretkeybytes a) -> seed_se_k:lbytes (2ul *! crypto_bytes a) -> Stack unit (requires fun h -> live h mu_decode /\ live h sk /\ live h seed_se_k /\ disjoint mu_decode seed_se_k /\ disjoint sk seed_se_k) (ensures fun h0 _ h1 -> modifies (loc seed_se_k) h0 h1 /\ as_seq h1 seed_se_k == S.crypto_kem_dec_seed_se_k a (as_seq h0 mu_decode) (as_seq h0 sk))
false
false
Hacl.Impl.Frodo.KEM.Decaps.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val crypto_kem_dec_seed_se_k: a:FP.frodo_alg -> mu_decode:lbytes (bytes_mu a) -> sk:lbytes (crypto_secretkeybytes a) -> seed_se_k:lbytes (2ul *! crypto_bytes a) -> Stack unit (requires fun h -> live h mu_decode /\ live h sk /\ live h seed_se_k /\ disjoint mu_decode seed_se_k /\ disjoint sk seed_se_k) (ensures fun h0 _ h1 -> modifies (loc seed_se_k) h0 h1 /\ as_seq h1 seed_se_k == S.crypto_kem_dec_seed_se_k a (as_seq h0 mu_decode) (as_seq h0 sk))
[]
Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec_seed_se_k
{ "file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Decaps.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_alg -> mu_decode: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.bytes_mu a) -> sk: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_secretkeybytes a) -> seed_se_k: Hacl.Impl.Matrix.lbytes (2ul *! Hacl.Impl.Frodo.Params.crypto_bytes a) -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 14, "end_line": 248, "start_col": 2, "start_line": 241 }
FStar.HyperStack.ST.Stack
val crypto_kem_dec0: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ss:lbytes (crypto_bytes a) -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> mu_decode:lbytes (bytes_mu a) -> Stack unit (requires fun h -> live h ss /\ live h ct /\ live h sk /\ live h mu_decode /\ live h bp_matrix /\ live h c_matrix /\ as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0) /\ loc_pairwise_disjoint [loc ss; loc ct; loc sk; loc mu_decode; loc bp_matrix; loc c_matrix]) (ensures fun h0 _ h1 -> modifies (loc ss |+| loc mu_decode) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ a gen_a (as_seq h0 ct) (as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
[ { "abbrev": true, "full_module": "Spec.Matrix", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Frodo.KEM.Decaps", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Impl.Frodo.KEM.KeyGen", "short_module": "KG" }, { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "FP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Frodo.Random", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Sample", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Pack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Encode", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM.Encaps", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Params", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let crypto_kem_dec0 a gen_a ss ct sk bp_matrix c_matrix mu_decode = crypto_kem_dec_mu a sk bp_matrix c_matrix mu_decode; crypto_kem_dec_ss2 a gen_a ct sk mu_decode bp_matrix c_matrix ss
val crypto_kem_dec0: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ss:lbytes (crypto_bytes a) -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> mu_decode:lbytes (bytes_mu a) -> Stack unit (requires fun h -> live h ss /\ live h ct /\ live h sk /\ live h mu_decode /\ live h bp_matrix /\ live h c_matrix /\ as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0) /\ loc_pairwise_disjoint [loc ss; loc ct; loc sk; loc mu_decode; loc bp_matrix; loc c_matrix]) (ensures fun h0 _ h1 -> modifies (loc ss |+| loc mu_decode) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ a gen_a (as_seq h0 ct) (as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let crypto_kem_dec0 a gen_a ss ct sk bp_matrix c_matrix mu_decode =
true
null
false
crypto_kem_dec_mu a sk bp_matrix c_matrix mu_decode; crypto_kem_dec_ss2 a gen_a ct sk mu_decode bp_matrix c_matrix ss
{ "checked_file": "Hacl.Impl.Frodo.KEM.Decaps.fst.checked", "dependencies": [ "Spec.Matrix.fst.checked", "Spec.Frodo.Params.fst.checked", "Spec.Frodo.KEM.Decaps.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Sample.fst.checked", "Hacl.Impl.Frodo.Params.fst.checked", "Hacl.Impl.Frodo.Pack.fst.checked", "Hacl.Impl.Frodo.KEM.KeyGen.fst.checked", "Hacl.Impl.Frodo.KEM.Encaps.fst.checked", "Hacl.Impl.Frodo.KEM.fst.checked", "Hacl.Impl.Frodo.Encode.fst.checked", "Hacl.Frodo.Random.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.KEM.Decaps.fst" }
[]
[ "Spec.Frodo.Params.frodo_alg", "Spec.Frodo.Params.frodo_gen_a", "Prims.b2t", "Hacl.Impl.Frodo.Params.is_supported", "Hacl.Impl.Matrix.lbytes", "Hacl.Impl.Frodo.Params.crypto_bytes", "Hacl.Impl.Frodo.Params.crypto_ciphertextbytes", "Hacl.Impl.Frodo.Params.crypto_secretkeybytes", "Hacl.Impl.Matrix.matrix_t", "Hacl.Impl.Frodo.Params.params_nbar", "Hacl.Impl.Frodo.Params.params_n", "Hacl.Impl.Frodo.Params.bytes_mu", "Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec_ss2", "Prims.unit", "Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec_mu" ]
[]
module Hacl.Impl.Frodo.KEM.Decaps open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix open Hacl.Impl.Frodo.Params open Hacl.Impl.Frodo.KEM open Hacl.Impl.Frodo.KEM.Encaps open Hacl.Impl.Frodo.Encode open Hacl.Impl.Frodo.Pack open Hacl.Impl.Frodo.Sample open Hacl.Frodo.Random module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module FP = Spec.Frodo.Params module KG = Hacl.Impl.Frodo.KEM.KeyGen module S = Spec.Frodo.KEM.Decaps module M = Spec.Matrix #set-options "--z3rlimit 100 --fuel 0 --ifuel 0" inline_for_extraction noextract val get_bp_c_matrices: a:FP.frodo_alg -> ct:lbytes (crypto_ciphertextbytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h ct /\ live h bp_matrix /\ live h c_matrix /\ disjoint bp_matrix ct /\ disjoint c_matrix ct /\ disjoint bp_matrix c_matrix) (ensures fun h0 _ h1 -> modifies (loc bp_matrix |+| loc c_matrix) h0 h1 /\ (as_matrix h1 bp_matrix, as_matrix h1 c_matrix) == S.get_bp_c_matrices a (as_seq h0 ct)) let get_bp_c_matrices a ct bp_matrix c_matrix = let c1 = sub ct 0ul (ct1bytes_len a) in let c2 = sub ct (ct1bytes_len a) (ct2bytes_len a) in frodo_unpack params_nbar (params_n a) (params_logq a) c1 bp_matrix; frodo_unpack params_nbar params_nbar (params_logq a) c2 c_matrix inline_for_extraction noextract val frodo_mu_decode: a:FP.frodo_alg -> s_bytes:lbytes (secretmatrixbytes_len a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> mu_decode:lbytes (bytes_mu a) -> Stack unit (requires fun h -> live h s_bytes /\ live h bp_matrix /\ live h c_matrix /\ live h mu_decode /\ disjoint mu_decode s_bytes /\ as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc mu_decode) h0 h1 /\ as_seq h1 mu_decode == S.frodo_mu_decode a (as_seq h0 s_bytes) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let frodo_mu_decode a s_bytes bp_matrix c_matrix mu_decode = push_frame(); let s_matrix = matrix_create (params_n a) params_nbar in let m_matrix = matrix_create params_nbar params_nbar in matrix_from_lbytes s_bytes s_matrix; matrix_mul_s bp_matrix s_matrix m_matrix; matrix_sub c_matrix m_matrix; frodo_key_decode (params_logq a) (params_extracted_bits a) params_nbar m_matrix mu_decode; clear_matrix s_matrix; clear_matrix m_matrix; pop_frame() inline_for_extraction noextract val get_bpp_cp_matrices_: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> sk:lbytes (crypto_secretkeybytes a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> cp_matrix:matrix_t params_nbar params_nbar -> sp_matrix:matrix_t params_nbar (params_n a) -> ep_matrix:matrix_t params_nbar (params_n a) -> epp_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h mu_decode /\ live h sk /\ live h bpp_matrix /\ live h cp_matrix /\ live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\ loc_pairwise_disjoint [loc mu_decode; loc sk; loc bpp_matrix; loc cp_matrix; loc sp_matrix; loc ep_matrix; loc epp_matrix]) (ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\ (as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) == S.get_bpp_cp_matrices_ a gen_a (as_seq h0 mu_decode) (as_seq h0 sk) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix) (as_matrix h0 epp_matrix)) let get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix = FP.expand_crypto_secretkeybytes a; FP.expand_crypto_publickeybytes a; let pk = sub sk (crypto_bytes a) (crypto_publickeybytes a) in let seed_a = sub pk 0ul bytes_seed_a in let b = sub pk bytes_seed_a (crypto_publickeybytes a -! bytes_seed_a) in frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bpp_matrix; frodo_mul_add_sb_plus_e_plus_mu a mu_decode b sp_matrix epp_matrix cp_matrix; mod_pow2 (params_logq a) bpp_matrix; mod_pow2 (params_logq a) cp_matrix #push-options "--z3rlimit 150" inline_for_extraction noextract val get_bpp_cp_matrices: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> seed_se:lbytes (crypto_bytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> cp_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h seed_se /\ live h mu_decode /\ live h sk /\ live h bpp_matrix /\ live h cp_matrix /\ loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk; loc bpp_matrix; loc cp_matrix]) (ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\ (as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) == S.get_bpp_cp_matrices a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se) (as_seq h0 sk)) let get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix = push_frame (); let sp_matrix = matrix_create params_nbar (params_n a) in let ep_matrix = matrix_create params_nbar (params_n a) in let epp_matrix = matrix_create params_nbar params_nbar in get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix; get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix; clear_matrix3 a sp_matrix ep_matrix epp_matrix; pop_frame () #pop-options inline_for_extraction noextract val crypto_kem_dec_kp_s_cond: a:FP.frodo_alg -> bp_matrix:matrix_t params_nbar (params_n a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> cp_matrix:matrix_t params_nbar params_nbar -> Stack uint16 (requires fun h -> live h bp_matrix /\ live h bpp_matrix /\ live h c_matrix /\ live h cp_matrix) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.crypto_kem_dec_kp_s_cond a (as_matrix h0 bp_matrix) (as_matrix h0 bpp_matrix) (as_matrix h0 c_matrix) (as_matrix h0 cp_matrix)) let crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix = let b1 = matrix_eq bp_matrix bpp_matrix in let b2 = matrix_eq c_matrix cp_matrix in b1 &. b2 inline_for_extraction noextract val crypto_kem_dec_kp_s: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> seed_se:lbytes (crypto_bytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack uint16 (requires fun h -> live h mu_decode /\ live h bp_matrix /\ live h seed_se /\ live h c_matrix /\ live h sk /\ loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk]) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.crypto_kem_dec_kp_s a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se) (as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let crypto_kem_dec_kp_s a gen_a mu_decode seed_se sk bp_matrix c_matrix = push_frame (); let bpp_matrix = matrix_create params_nbar (params_n a) in let cp_matrix = matrix_create params_nbar params_nbar in get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix; let mask = crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix in pop_frame (); mask inline_for_extraction noextract val crypto_kem_dec_ss0: a:FP.frodo_alg -> ct:lbytes (crypto_ciphertextbytes a) -> mask:uint16{v mask == 0 \/ v mask == v (ones U16 SEC)} -> kp:lbytes (crypto_bytes a) -> s:lbytes (crypto_bytes a) -> ss:lbytes (crypto_bytes a) -> Stack unit (requires fun h -> live h ct /\ live h kp /\ live h s /\ live h ss /\ disjoint ss ct /\ disjoint ss kp /\ disjoint ss s /\ disjoint kp s) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ss0 a (as_seq h0 ct) mask (as_seq h0 kp) (as_seq h0 s)) let crypto_kem_dec_ss0 a ct mask kp s ss = push_frame (); let kp_s = create (crypto_bytes a) (u8 0) in Lib.ByteBuffer.buf_mask_select kp s (to_u8 mask) kp_s; let ss_init_len = crypto_ciphertextbytes a +! crypto_bytes a in let ss_init = create ss_init_len (u8 0) in concat2 (crypto_ciphertextbytes a) ct (crypto_bytes a) kp_s ss_init; frodo_shake a ss_init_len ss_init (crypto_bytes a) ss; clear_words_u8 ss_init; clear_words_u8 kp_s; pop_frame () inline_for_extraction noextract val crypto_kem_dec_seed_se_k: a:FP.frodo_alg -> mu_decode:lbytes (bytes_mu a) -> sk:lbytes (crypto_secretkeybytes a) -> seed_se_k:lbytes (2ul *! crypto_bytes a) -> Stack unit (requires fun h -> live h mu_decode /\ live h sk /\ live h seed_se_k /\ disjoint mu_decode seed_se_k /\ disjoint sk seed_se_k) (ensures fun h0 _ h1 -> modifies (loc seed_se_k) h0 h1 /\ as_seq h1 seed_se_k == S.crypto_kem_dec_seed_se_k a (as_seq h0 mu_decode) (as_seq h0 sk)) let crypto_kem_dec_seed_se_k a mu_decode sk seed_se_k = push_frame (); let pkh_mu_decode_len = bytes_pkhash a +! bytes_mu a in let pkh_mu_decode = create pkh_mu_decode_len (u8 0) in let pkh = sub sk (crypto_secretkeybytes a -! bytes_pkhash a) (bytes_pkhash a) in concat2 (bytes_pkhash a) pkh (bytes_mu a) mu_decode pkh_mu_decode; frodo_shake a pkh_mu_decode_len pkh_mu_decode (2ul *! crypto_bytes a) seed_se_k; pop_frame () inline_for_extraction noextract val crypto_kem_dec_ss1: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> mu_decode:lbytes (bytes_mu a) -> seed_se_k:lbytes (2ul *! crypto_bytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> ss:lbytes (crypto_bytes a) -> Stack unit (requires fun h -> live h mu_decode /\ live h bp_matrix /\ live h seed_se_k /\ live h c_matrix /\ live h sk /\ live h ct /\ live h ss /\ loc_pairwise_disjoint [loc ct; loc sk; loc seed_se_k; loc mu_decode; loc bp_matrix; loc c_matrix; loc ss]) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ss1 a gen_a (as_seq h0 ct) (as_seq h0 sk) (as_seq h0 mu_decode) (as_seq h0 seed_se_k) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let crypto_kem_dec_ss1 a gen_a ct sk mu_decode seed_se_k bp_matrix c_matrix ss = let seed_se = sub seed_se_k 0ul (crypto_bytes a) in let kp = sub seed_se_k (crypto_bytes a) (crypto_bytes a) in let s = sub sk 0ul (crypto_bytes a) in let mask = crypto_kem_dec_kp_s a gen_a mu_decode seed_se sk bp_matrix c_matrix in crypto_kem_dec_ss0 a ct mask kp s ss inline_for_extraction noextract val crypto_kem_dec_ss2: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> mu_decode:lbytes (bytes_mu a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> ss:lbytes (crypto_bytes a) -> Stack unit (requires fun h -> live h mu_decode /\ live h bp_matrix /\ live h c_matrix /\ live h sk /\ live h ct /\ live h ss /\ loc_pairwise_disjoint [loc ct; loc sk; loc mu_decode; loc bp_matrix; loc c_matrix; loc ss]) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ss2 a gen_a (as_seq h0 ct) (as_seq h0 sk) (as_seq h0 mu_decode) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let crypto_kem_dec_ss2 a gen_a ct sk mu_decode bp_matrix c_matrix ss = push_frame (); let seed_se_k = create (2ul *! crypto_bytes a) (u8 0) in crypto_kem_dec_seed_se_k a mu_decode sk seed_se_k; crypto_kem_dec_ss1 a gen_a ct sk mu_decode seed_se_k bp_matrix c_matrix ss; clear_words_u8 seed_se_k; pop_frame () inline_for_extraction noextract val crypto_kem_dec_mu: a:FP.frodo_alg -> sk:lbytes (crypto_secretkeybytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> mu_decode:lbytes (bytes_mu a) -> Stack unit (requires fun h -> live h sk /\ live h mu_decode /\ live h bp_matrix /\ live h c_matrix /\ as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0) /\ loc_pairwise_disjoint [loc sk; loc mu_decode; loc bp_matrix; loc c_matrix]) (ensures fun h0 _ h1 -> modifies (loc mu_decode) h0 h1 /\ as_seq h1 mu_decode == S.crypto_kem_dec_mu a (as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let crypto_kem_dec_mu a sk bp_matrix c_matrix mu_decode = FP.expand_crypto_secretkeybytes a; let s_bytes = sub sk (crypto_bytes a +! crypto_publickeybytes a) (secretmatrixbytes_len a) in frodo_mu_decode a s_bytes bp_matrix c_matrix mu_decode inline_for_extraction noextract val crypto_kem_dec0: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ss:lbytes (crypto_bytes a) -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> mu_decode:lbytes (bytes_mu a) -> Stack unit (requires fun h -> live h ss /\ live h ct /\ live h sk /\ live h mu_decode /\ live h bp_matrix /\ live h c_matrix /\ as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0) /\ loc_pairwise_disjoint [loc ss; loc ct; loc sk; loc mu_decode; loc bp_matrix; loc c_matrix]) (ensures fun h0 _ h1 -> modifies (loc ss |+| loc mu_decode) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ a gen_a (as_seq h0 ct) (as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
false
false
Hacl.Impl.Frodo.KEM.Decaps.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val crypto_kem_dec0: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ss:lbytes (crypto_bytes a) -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> mu_decode:lbytes (bytes_mu a) -> Stack unit (requires fun h -> live h ss /\ live h ct /\ live h sk /\ live h mu_decode /\ live h bp_matrix /\ live h c_matrix /\ as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0) /\ loc_pairwise_disjoint [loc ss; loc ct; loc sk; loc mu_decode; loc bp_matrix; loc c_matrix]) (ensures fun h0 _ h1 -> modifies (loc ss |+| loc mu_decode) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ a gen_a (as_seq h0 ct) (as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
[]
Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec0
{ "file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Decaps.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_alg -> gen_a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported gen_a} -> ss: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_bytes a) -> ct: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_ciphertextbytes a) -> sk: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_secretkeybytes a) -> bp_matrix: Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar (Hacl.Impl.Frodo.Params.params_n a) -> c_matrix: Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar Hacl.Impl.Frodo.Params.params_nbar -> mu_decode: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.bytes_mu a) -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 66, "end_line": 356, "start_col": 2, "start_line": 355 }
FStar.HyperStack.ST.Stack
val crypto_kem_dec1: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ss:lbytes (crypto_bytes a) -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h ss /\ live h ct /\ live h sk /\ live h bp_matrix /\ live h c_matrix /\ loc_pairwise_disjoint [loc ss; loc ct; loc sk; loc bp_matrix; loc c_matrix]) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ a gen_a (as_seq h0 ct) (as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
[ { "abbrev": true, "full_module": "Spec.Matrix", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Frodo.KEM.Decaps", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Impl.Frodo.KEM.KeyGen", "short_module": "KG" }, { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "FP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Frodo.Random", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Sample", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Pack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Encode", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM.Encaps", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Params", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let crypto_kem_dec1 a gen_a ss ct sk bp_matrix c_matrix = push_frame (); let mu_decode = create (bytes_mu a) (u8 0) in crypto_kem_dec0 a gen_a ss ct sk bp_matrix c_matrix mu_decode; clear_words_u8 mu_decode; pop_frame ()
val crypto_kem_dec1: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ss:lbytes (crypto_bytes a) -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h ss /\ live h ct /\ live h sk /\ live h bp_matrix /\ live h c_matrix /\ loc_pairwise_disjoint [loc ss; loc ct; loc sk; loc bp_matrix; loc c_matrix]) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ a gen_a (as_seq h0 ct) (as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let crypto_kem_dec1 a gen_a ss ct sk bp_matrix c_matrix =
true
null
false
push_frame (); let mu_decode = create (bytes_mu a) (u8 0) in crypto_kem_dec0 a gen_a ss ct sk bp_matrix c_matrix mu_decode; clear_words_u8 mu_decode; pop_frame ()
{ "checked_file": "Hacl.Impl.Frodo.KEM.Decaps.fst.checked", "dependencies": [ "Spec.Matrix.fst.checked", "Spec.Frodo.Params.fst.checked", "Spec.Frodo.KEM.Decaps.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Sample.fst.checked", "Hacl.Impl.Frodo.Params.fst.checked", "Hacl.Impl.Frodo.Pack.fst.checked", "Hacl.Impl.Frodo.KEM.KeyGen.fst.checked", "Hacl.Impl.Frodo.KEM.Encaps.fst.checked", "Hacl.Impl.Frodo.KEM.fst.checked", "Hacl.Impl.Frodo.Encode.fst.checked", "Hacl.Frodo.Random.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.KEM.Decaps.fst" }
[]
[ "Spec.Frodo.Params.frodo_alg", "Spec.Frodo.Params.frodo_gen_a", "Prims.b2t", "Hacl.Impl.Frodo.Params.is_supported", "Hacl.Impl.Matrix.lbytes", "Hacl.Impl.Frodo.Params.crypto_bytes", "Hacl.Impl.Frodo.Params.crypto_ciphertextbytes", "Hacl.Impl.Frodo.Params.crypto_secretkeybytes", "Hacl.Impl.Matrix.matrix_t", "Hacl.Impl.Frodo.Params.params_nbar", "Hacl.Impl.Frodo.Params.params_n", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Impl.Frodo.KEM.clear_words_u8", "Hacl.Impl.Frodo.Params.bytes_mu", "Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec0", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.create", "Lib.IntTypes.uint8", "Lib.IntTypes.u8", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Impl.Frodo.KEM.Decaps open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix open Hacl.Impl.Frodo.Params open Hacl.Impl.Frodo.KEM open Hacl.Impl.Frodo.KEM.Encaps open Hacl.Impl.Frodo.Encode open Hacl.Impl.Frodo.Pack open Hacl.Impl.Frodo.Sample open Hacl.Frodo.Random module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module FP = Spec.Frodo.Params module KG = Hacl.Impl.Frodo.KEM.KeyGen module S = Spec.Frodo.KEM.Decaps module M = Spec.Matrix #set-options "--z3rlimit 100 --fuel 0 --ifuel 0" inline_for_extraction noextract val get_bp_c_matrices: a:FP.frodo_alg -> ct:lbytes (crypto_ciphertextbytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h ct /\ live h bp_matrix /\ live h c_matrix /\ disjoint bp_matrix ct /\ disjoint c_matrix ct /\ disjoint bp_matrix c_matrix) (ensures fun h0 _ h1 -> modifies (loc bp_matrix |+| loc c_matrix) h0 h1 /\ (as_matrix h1 bp_matrix, as_matrix h1 c_matrix) == S.get_bp_c_matrices a (as_seq h0 ct)) let get_bp_c_matrices a ct bp_matrix c_matrix = let c1 = sub ct 0ul (ct1bytes_len a) in let c2 = sub ct (ct1bytes_len a) (ct2bytes_len a) in frodo_unpack params_nbar (params_n a) (params_logq a) c1 bp_matrix; frodo_unpack params_nbar params_nbar (params_logq a) c2 c_matrix inline_for_extraction noextract val frodo_mu_decode: a:FP.frodo_alg -> s_bytes:lbytes (secretmatrixbytes_len a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> mu_decode:lbytes (bytes_mu a) -> Stack unit (requires fun h -> live h s_bytes /\ live h bp_matrix /\ live h c_matrix /\ live h mu_decode /\ disjoint mu_decode s_bytes /\ as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc mu_decode) h0 h1 /\ as_seq h1 mu_decode == S.frodo_mu_decode a (as_seq h0 s_bytes) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let frodo_mu_decode a s_bytes bp_matrix c_matrix mu_decode = push_frame(); let s_matrix = matrix_create (params_n a) params_nbar in let m_matrix = matrix_create params_nbar params_nbar in matrix_from_lbytes s_bytes s_matrix; matrix_mul_s bp_matrix s_matrix m_matrix; matrix_sub c_matrix m_matrix; frodo_key_decode (params_logq a) (params_extracted_bits a) params_nbar m_matrix mu_decode; clear_matrix s_matrix; clear_matrix m_matrix; pop_frame() inline_for_extraction noextract val get_bpp_cp_matrices_: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> sk:lbytes (crypto_secretkeybytes a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> cp_matrix:matrix_t params_nbar params_nbar -> sp_matrix:matrix_t params_nbar (params_n a) -> ep_matrix:matrix_t params_nbar (params_n a) -> epp_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h mu_decode /\ live h sk /\ live h bpp_matrix /\ live h cp_matrix /\ live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\ loc_pairwise_disjoint [loc mu_decode; loc sk; loc bpp_matrix; loc cp_matrix; loc sp_matrix; loc ep_matrix; loc epp_matrix]) (ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\ (as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) == S.get_bpp_cp_matrices_ a gen_a (as_seq h0 mu_decode) (as_seq h0 sk) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix) (as_matrix h0 epp_matrix)) let get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix = FP.expand_crypto_secretkeybytes a; FP.expand_crypto_publickeybytes a; let pk = sub sk (crypto_bytes a) (crypto_publickeybytes a) in let seed_a = sub pk 0ul bytes_seed_a in let b = sub pk bytes_seed_a (crypto_publickeybytes a -! bytes_seed_a) in frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bpp_matrix; frodo_mul_add_sb_plus_e_plus_mu a mu_decode b sp_matrix epp_matrix cp_matrix; mod_pow2 (params_logq a) bpp_matrix; mod_pow2 (params_logq a) cp_matrix #push-options "--z3rlimit 150" inline_for_extraction noextract val get_bpp_cp_matrices: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> seed_se:lbytes (crypto_bytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> cp_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h seed_se /\ live h mu_decode /\ live h sk /\ live h bpp_matrix /\ live h cp_matrix /\ loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk; loc bpp_matrix; loc cp_matrix]) (ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\ (as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) == S.get_bpp_cp_matrices a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se) (as_seq h0 sk)) let get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix = push_frame (); let sp_matrix = matrix_create params_nbar (params_n a) in let ep_matrix = matrix_create params_nbar (params_n a) in let epp_matrix = matrix_create params_nbar params_nbar in get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix; get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix; clear_matrix3 a sp_matrix ep_matrix epp_matrix; pop_frame () #pop-options inline_for_extraction noextract val crypto_kem_dec_kp_s_cond: a:FP.frodo_alg -> bp_matrix:matrix_t params_nbar (params_n a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> cp_matrix:matrix_t params_nbar params_nbar -> Stack uint16 (requires fun h -> live h bp_matrix /\ live h bpp_matrix /\ live h c_matrix /\ live h cp_matrix) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.crypto_kem_dec_kp_s_cond a (as_matrix h0 bp_matrix) (as_matrix h0 bpp_matrix) (as_matrix h0 c_matrix) (as_matrix h0 cp_matrix)) let crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix = let b1 = matrix_eq bp_matrix bpp_matrix in let b2 = matrix_eq c_matrix cp_matrix in b1 &. b2 inline_for_extraction noextract val crypto_kem_dec_kp_s: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> seed_se:lbytes (crypto_bytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack uint16 (requires fun h -> live h mu_decode /\ live h bp_matrix /\ live h seed_se /\ live h c_matrix /\ live h sk /\ loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk]) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.crypto_kem_dec_kp_s a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se) (as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let crypto_kem_dec_kp_s a gen_a mu_decode seed_se sk bp_matrix c_matrix = push_frame (); let bpp_matrix = matrix_create params_nbar (params_n a) in let cp_matrix = matrix_create params_nbar params_nbar in get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix; let mask = crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix in pop_frame (); mask inline_for_extraction noextract val crypto_kem_dec_ss0: a:FP.frodo_alg -> ct:lbytes (crypto_ciphertextbytes a) -> mask:uint16{v mask == 0 \/ v mask == v (ones U16 SEC)} -> kp:lbytes (crypto_bytes a) -> s:lbytes (crypto_bytes a) -> ss:lbytes (crypto_bytes a) -> Stack unit (requires fun h -> live h ct /\ live h kp /\ live h s /\ live h ss /\ disjoint ss ct /\ disjoint ss kp /\ disjoint ss s /\ disjoint kp s) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ss0 a (as_seq h0 ct) mask (as_seq h0 kp) (as_seq h0 s)) let crypto_kem_dec_ss0 a ct mask kp s ss = push_frame (); let kp_s = create (crypto_bytes a) (u8 0) in Lib.ByteBuffer.buf_mask_select kp s (to_u8 mask) kp_s; let ss_init_len = crypto_ciphertextbytes a +! crypto_bytes a in let ss_init = create ss_init_len (u8 0) in concat2 (crypto_ciphertextbytes a) ct (crypto_bytes a) kp_s ss_init; frodo_shake a ss_init_len ss_init (crypto_bytes a) ss; clear_words_u8 ss_init; clear_words_u8 kp_s; pop_frame () inline_for_extraction noextract val crypto_kem_dec_seed_se_k: a:FP.frodo_alg -> mu_decode:lbytes (bytes_mu a) -> sk:lbytes (crypto_secretkeybytes a) -> seed_se_k:lbytes (2ul *! crypto_bytes a) -> Stack unit (requires fun h -> live h mu_decode /\ live h sk /\ live h seed_se_k /\ disjoint mu_decode seed_se_k /\ disjoint sk seed_se_k) (ensures fun h0 _ h1 -> modifies (loc seed_se_k) h0 h1 /\ as_seq h1 seed_se_k == S.crypto_kem_dec_seed_se_k a (as_seq h0 mu_decode) (as_seq h0 sk)) let crypto_kem_dec_seed_se_k a mu_decode sk seed_se_k = push_frame (); let pkh_mu_decode_len = bytes_pkhash a +! bytes_mu a in let pkh_mu_decode = create pkh_mu_decode_len (u8 0) in let pkh = sub sk (crypto_secretkeybytes a -! bytes_pkhash a) (bytes_pkhash a) in concat2 (bytes_pkhash a) pkh (bytes_mu a) mu_decode pkh_mu_decode; frodo_shake a pkh_mu_decode_len pkh_mu_decode (2ul *! crypto_bytes a) seed_se_k; pop_frame () inline_for_extraction noextract val crypto_kem_dec_ss1: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> mu_decode:lbytes (bytes_mu a) -> seed_se_k:lbytes (2ul *! crypto_bytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> ss:lbytes (crypto_bytes a) -> Stack unit (requires fun h -> live h mu_decode /\ live h bp_matrix /\ live h seed_se_k /\ live h c_matrix /\ live h sk /\ live h ct /\ live h ss /\ loc_pairwise_disjoint [loc ct; loc sk; loc seed_se_k; loc mu_decode; loc bp_matrix; loc c_matrix; loc ss]) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ss1 a gen_a (as_seq h0 ct) (as_seq h0 sk) (as_seq h0 mu_decode) (as_seq h0 seed_se_k) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let crypto_kem_dec_ss1 a gen_a ct sk mu_decode seed_se_k bp_matrix c_matrix ss = let seed_se = sub seed_se_k 0ul (crypto_bytes a) in let kp = sub seed_se_k (crypto_bytes a) (crypto_bytes a) in let s = sub sk 0ul (crypto_bytes a) in let mask = crypto_kem_dec_kp_s a gen_a mu_decode seed_se sk bp_matrix c_matrix in crypto_kem_dec_ss0 a ct mask kp s ss inline_for_extraction noextract val crypto_kem_dec_ss2: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> mu_decode:lbytes (bytes_mu a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> ss:lbytes (crypto_bytes a) -> Stack unit (requires fun h -> live h mu_decode /\ live h bp_matrix /\ live h c_matrix /\ live h sk /\ live h ct /\ live h ss /\ loc_pairwise_disjoint [loc ct; loc sk; loc mu_decode; loc bp_matrix; loc c_matrix; loc ss]) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ss2 a gen_a (as_seq h0 ct) (as_seq h0 sk) (as_seq h0 mu_decode) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let crypto_kem_dec_ss2 a gen_a ct sk mu_decode bp_matrix c_matrix ss = push_frame (); let seed_se_k = create (2ul *! crypto_bytes a) (u8 0) in crypto_kem_dec_seed_se_k a mu_decode sk seed_se_k; crypto_kem_dec_ss1 a gen_a ct sk mu_decode seed_se_k bp_matrix c_matrix ss; clear_words_u8 seed_se_k; pop_frame () inline_for_extraction noextract val crypto_kem_dec_mu: a:FP.frodo_alg -> sk:lbytes (crypto_secretkeybytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> mu_decode:lbytes (bytes_mu a) -> Stack unit (requires fun h -> live h sk /\ live h mu_decode /\ live h bp_matrix /\ live h c_matrix /\ as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0) /\ loc_pairwise_disjoint [loc sk; loc mu_decode; loc bp_matrix; loc c_matrix]) (ensures fun h0 _ h1 -> modifies (loc mu_decode) h0 h1 /\ as_seq h1 mu_decode == S.crypto_kem_dec_mu a (as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let crypto_kem_dec_mu a sk bp_matrix c_matrix mu_decode = FP.expand_crypto_secretkeybytes a; let s_bytes = sub sk (crypto_bytes a +! crypto_publickeybytes a) (secretmatrixbytes_len a) in frodo_mu_decode a s_bytes bp_matrix c_matrix mu_decode inline_for_extraction noextract val crypto_kem_dec0: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ss:lbytes (crypto_bytes a) -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> mu_decode:lbytes (bytes_mu a) -> Stack unit (requires fun h -> live h ss /\ live h ct /\ live h sk /\ live h mu_decode /\ live h bp_matrix /\ live h c_matrix /\ as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0) /\ loc_pairwise_disjoint [loc ss; loc ct; loc sk; loc mu_decode; loc bp_matrix; loc c_matrix]) (ensures fun h0 _ h1 -> modifies (loc ss |+| loc mu_decode) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ a gen_a (as_seq h0 ct) (as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let crypto_kem_dec0 a gen_a ss ct sk bp_matrix c_matrix mu_decode = crypto_kem_dec_mu a sk bp_matrix c_matrix mu_decode; crypto_kem_dec_ss2 a gen_a ct sk mu_decode bp_matrix c_matrix ss inline_for_extraction noextract val crypto_kem_dec1: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ss:lbytes (crypto_bytes a) -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h ss /\ live h ct /\ live h sk /\ live h bp_matrix /\ live h c_matrix /\ loc_pairwise_disjoint [loc ss; loc ct; loc sk; loc bp_matrix; loc c_matrix]) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ a gen_a (as_seq h0 ct) (as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
false
false
Hacl.Impl.Frodo.KEM.Decaps.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val crypto_kem_dec1: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ss:lbytes (crypto_bytes a) -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h ss /\ live h ct /\ live h sk /\ live h bp_matrix /\ live h c_matrix /\ loc_pairwise_disjoint [loc ss; loc ct; loc sk; loc bp_matrix; loc c_matrix]) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ a gen_a (as_seq h0 ct) (as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
[]
Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec1
{ "file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Decaps.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_alg -> gen_a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported gen_a} -> ss: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_bytes a) -> ct: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_ciphertextbytes a) -> sk: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_secretkeybytes a) -> bp_matrix: Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar (Hacl.Impl.Frodo.Params.params_n a) -> c_matrix: Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar Hacl.Impl.Frodo.Params.params_nbar -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 14, "end_line": 382, "start_col": 2, "start_line": 378 }
FStar.HyperStack.ST.Stack
val crypto_kem_dec_ss1: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> mu_decode:lbytes (bytes_mu a) -> seed_se_k:lbytes (2ul *! crypto_bytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> ss:lbytes (crypto_bytes a) -> Stack unit (requires fun h -> live h mu_decode /\ live h bp_matrix /\ live h seed_se_k /\ live h c_matrix /\ live h sk /\ live h ct /\ live h ss /\ loc_pairwise_disjoint [loc ct; loc sk; loc seed_se_k; loc mu_decode; loc bp_matrix; loc c_matrix; loc ss]) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ss1 a gen_a (as_seq h0 ct) (as_seq h0 sk) (as_seq h0 mu_decode) (as_seq h0 seed_se_k) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
[ { "abbrev": true, "full_module": "Spec.Matrix", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Frodo.KEM.Decaps", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Impl.Frodo.KEM.KeyGen", "short_module": "KG" }, { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "FP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Frodo.Random", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Sample", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Pack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Encode", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM.Encaps", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Params", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let crypto_kem_dec_ss1 a gen_a ct sk mu_decode seed_se_k bp_matrix c_matrix ss = let seed_se = sub seed_se_k 0ul (crypto_bytes a) in let kp = sub seed_se_k (crypto_bytes a) (crypto_bytes a) in let s = sub sk 0ul (crypto_bytes a) in let mask = crypto_kem_dec_kp_s a gen_a mu_decode seed_se sk bp_matrix c_matrix in crypto_kem_dec_ss0 a ct mask kp s ss
val crypto_kem_dec_ss1: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> mu_decode:lbytes (bytes_mu a) -> seed_se_k:lbytes (2ul *! crypto_bytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> ss:lbytes (crypto_bytes a) -> Stack unit (requires fun h -> live h mu_decode /\ live h bp_matrix /\ live h seed_se_k /\ live h c_matrix /\ live h sk /\ live h ct /\ live h ss /\ loc_pairwise_disjoint [loc ct; loc sk; loc seed_se_k; loc mu_decode; loc bp_matrix; loc c_matrix; loc ss]) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ss1 a gen_a (as_seq h0 ct) (as_seq h0 sk) (as_seq h0 mu_decode) (as_seq h0 seed_se_k) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let crypto_kem_dec_ss1 a gen_a ct sk mu_decode seed_se_k bp_matrix c_matrix ss =
true
null
false
let seed_se = sub seed_se_k 0ul (crypto_bytes a) in let kp = sub seed_se_k (crypto_bytes a) (crypto_bytes a) in let s = sub sk 0ul (crypto_bytes a) in let mask = crypto_kem_dec_kp_s a gen_a mu_decode seed_se sk bp_matrix c_matrix in crypto_kem_dec_ss0 a ct mask kp s ss
{ "checked_file": "Hacl.Impl.Frodo.KEM.Decaps.fst.checked", "dependencies": [ "Spec.Matrix.fst.checked", "Spec.Frodo.Params.fst.checked", "Spec.Frodo.KEM.Decaps.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Sample.fst.checked", "Hacl.Impl.Frodo.Params.fst.checked", "Hacl.Impl.Frodo.Pack.fst.checked", "Hacl.Impl.Frodo.KEM.KeyGen.fst.checked", "Hacl.Impl.Frodo.KEM.Encaps.fst.checked", "Hacl.Impl.Frodo.KEM.fst.checked", "Hacl.Impl.Frodo.Encode.fst.checked", "Hacl.Frodo.Random.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.KEM.Decaps.fst" }
[]
[ "Spec.Frodo.Params.frodo_alg", "Spec.Frodo.Params.frodo_gen_a", "Prims.b2t", "Hacl.Impl.Frodo.Params.is_supported", "Hacl.Impl.Matrix.lbytes", "Hacl.Impl.Frodo.Params.crypto_ciphertextbytes", "Hacl.Impl.Frodo.Params.crypto_secretkeybytes", "Hacl.Impl.Frodo.Params.bytes_mu", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Frodo.Params.crypto_bytes", "Hacl.Impl.Matrix.matrix_t", "Hacl.Impl.Frodo.Params.params_nbar", "Hacl.Impl.Frodo.Params.params_n", "Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec_ss0", "Prims.unit", "Lib.IntTypes.int_t", "Lib.IntTypes.U16", "Lib.IntTypes.SEC", "Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec_kp_s", "Lib.IntTypes.uint16", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.U8", "Lib.Buffer.sub", "Lib.IntTypes.uint8" ]
[]
module Hacl.Impl.Frodo.KEM.Decaps open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix open Hacl.Impl.Frodo.Params open Hacl.Impl.Frodo.KEM open Hacl.Impl.Frodo.KEM.Encaps open Hacl.Impl.Frodo.Encode open Hacl.Impl.Frodo.Pack open Hacl.Impl.Frodo.Sample open Hacl.Frodo.Random module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module FP = Spec.Frodo.Params module KG = Hacl.Impl.Frodo.KEM.KeyGen module S = Spec.Frodo.KEM.Decaps module M = Spec.Matrix #set-options "--z3rlimit 100 --fuel 0 --ifuel 0" inline_for_extraction noextract val get_bp_c_matrices: a:FP.frodo_alg -> ct:lbytes (crypto_ciphertextbytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h ct /\ live h bp_matrix /\ live h c_matrix /\ disjoint bp_matrix ct /\ disjoint c_matrix ct /\ disjoint bp_matrix c_matrix) (ensures fun h0 _ h1 -> modifies (loc bp_matrix |+| loc c_matrix) h0 h1 /\ (as_matrix h1 bp_matrix, as_matrix h1 c_matrix) == S.get_bp_c_matrices a (as_seq h0 ct)) let get_bp_c_matrices a ct bp_matrix c_matrix = let c1 = sub ct 0ul (ct1bytes_len a) in let c2 = sub ct (ct1bytes_len a) (ct2bytes_len a) in frodo_unpack params_nbar (params_n a) (params_logq a) c1 bp_matrix; frodo_unpack params_nbar params_nbar (params_logq a) c2 c_matrix inline_for_extraction noextract val frodo_mu_decode: a:FP.frodo_alg -> s_bytes:lbytes (secretmatrixbytes_len a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> mu_decode:lbytes (bytes_mu a) -> Stack unit (requires fun h -> live h s_bytes /\ live h bp_matrix /\ live h c_matrix /\ live h mu_decode /\ disjoint mu_decode s_bytes /\ as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc mu_decode) h0 h1 /\ as_seq h1 mu_decode == S.frodo_mu_decode a (as_seq h0 s_bytes) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let frodo_mu_decode a s_bytes bp_matrix c_matrix mu_decode = push_frame(); let s_matrix = matrix_create (params_n a) params_nbar in let m_matrix = matrix_create params_nbar params_nbar in matrix_from_lbytes s_bytes s_matrix; matrix_mul_s bp_matrix s_matrix m_matrix; matrix_sub c_matrix m_matrix; frodo_key_decode (params_logq a) (params_extracted_bits a) params_nbar m_matrix mu_decode; clear_matrix s_matrix; clear_matrix m_matrix; pop_frame() inline_for_extraction noextract val get_bpp_cp_matrices_: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> sk:lbytes (crypto_secretkeybytes a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> cp_matrix:matrix_t params_nbar params_nbar -> sp_matrix:matrix_t params_nbar (params_n a) -> ep_matrix:matrix_t params_nbar (params_n a) -> epp_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h mu_decode /\ live h sk /\ live h bpp_matrix /\ live h cp_matrix /\ live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\ loc_pairwise_disjoint [loc mu_decode; loc sk; loc bpp_matrix; loc cp_matrix; loc sp_matrix; loc ep_matrix; loc epp_matrix]) (ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\ (as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) == S.get_bpp_cp_matrices_ a gen_a (as_seq h0 mu_decode) (as_seq h0 sk) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix) (as_matrix h0 epp_matrix)) let get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix = FP.expand_crypto_secretkeybytes a; FP.expand_crypto_publickeybytes a; let pk = sub sk (crypto_bytes a) (crypto_publickeybytes a) in let seed_a = sub pk 0ul bytes_seed_a in let b = sub pk bytes_seed_a (crypto_publickeybytes a -! bytes_seed_a) in frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bpp_matrix; frodo_mul_add_sb_plus_e_plus_mu a mu_decode b sp_matrix epp_matrix cp_matrix; mod_pow2 (params_logq a) bpp_matrix; mod_pow2 (params_logq a) cp_matrix #push-options "--z3rlimit 150" inline_for_extraction noextract val get_bpp_cp_matrices: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> seed_se:lbytes (crypto_bytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> cp_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h seed_se /\ live h mu_decode /\ live h sk /\ live h bpp_matrix /\ live h cp_matrix /\ loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk; loc bpp_matrix; loc cp_matrix]) (ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\ (as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) == S.get_bpp_cp_matrices a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se) (as_seq h0 sk)) let get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix = push_frame (); let sp_matrix = matrix_create params_nbar (params_n a) in let ep_matrix = matrix_create params_nbar (params_n a) in let epp_matrix = matrix_create params_nbar params_nbar in get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix; get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix; clear_matrix3 a sp_matrix ep_matrix epp_matrix; pop_frame () #pop-options inline_for_extraction noextract val crypto_kem_dec_kp_s_cond: a:FP.frodo_alg -> bp_matrix:matrix_t params_nbar (params_n a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> cp_matrix:matrix_t params_nbar params_nbar -> Stack uint16 (requires fun h -> live h bp_matrix /\ live h bpp_matrix /\ live h c_matrix /\ live h cp_matrix) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.crypto_kem_dec_kp_s_cond a (as_matrix h0 bp_matrix) (as_matrix h0 bpp_matrix) (as_matrix h0 c_matrix) (as_matrix h0 cp_matrix)) let crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix = let b1 = matrix_eq bp_matrix bpp_matrix in let b2 = matrix_eq c_matrix cp_matrix in b1 &. b2 inline_for_extraction noextract val crypto_kem_dec_kp_s: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> seed_se:lbytes (crypto_bytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack uint16 (requires fun h -> live h mu_decode /\ live h bp_matrix /\ live h seed_se /\ live h c_matrix /\ live h sk /\ loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk]) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.crypto_kem_dec_kp_s a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se) (as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let crypto_kem_dec_kp_s a gen_a mu_decode seed_se sk bp_matrix c_matrix = push_frame (); let bpp_matrix = matrix_create params_nbar (params_n a) in let cp_matrix = matrix_create params_nbar params_nbar in get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix; let mask = crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix in pop_frame (); mask inline_for_extraction noextract val crypto_kem_dec_ss0: a:FP.frodo_alg -> ct:lbytes (crypto_ciphertextbytes a) -> mask:uint16{v mask == 0 \/ v mask == v (ones U16 SEC)} -> kp:lbytes (crypto_bytes a) -> s:lbytes (crypto_bytes a) -> ss:lbytes (crypto_bytes a) -> Stack unit (requires fun h -> live h ct /\ live h kp /\ live h s /\ live h ss /\ disjoint ss ct /\ disjoint ss kp /\ disjoint ss s /\ disjoint kp s) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ss0 a (as_seq h0 ct) mask (as_seq h0 kp) (as_seq h0 s)) let crypto_kem_dec_ss0 a ct mask kp s ss = push_frame (); let kp_s = create (crypto_bytes a) (u8 0) in Lib.ByteBuffer.buf_mask_select kp s (to_u8 mask) kp_s; let ss_init_len = crypto_ciphertextbytes a +! crypto_bytes a in let ss_init = create ss_init_len (u8 0) in concat2 (crypto_ciphertextbytes a) ct (crypto_bytes a) kp_s ss_init; frodo_shake a ss_init_len ss_init (crypto_bytes a) ss; clear_words_u8 ss_init; clear_words_u8 kp_s; pop_frame () inline_for_extraction noextract val crypto_kem_dec_seed_se_k: a:FP.frodo_alg -> mu_decode:lbytes (bytes_mu a) -> sk:lbytes (crypto_secretkeybytes a) -> seed_se_k:lbytes (2ul *! crypto_bytes a) -> Stack unit (requires fun h -> live h mu_decode /\ live h sk /\ live h seed_se_k /\ disjoint mu_decode seed_se_k /\ disjoint sk seed_se_k) (ensures fun h0 _ h1 -> modifies (loc seed_se_k) h0 h1 /\ as_seq h1 seed_se_k == S.crypto_kem_dec_seed_se_k a (as_seq h0 mu_decode) (as_seq h0 sk)) let crypto_kem_dec_seed_se_k a mu_decode sk seed_se_k = push_frame (); let pkh_mu_decode_len = bytes_pkhash a +! bytes_mu a in let pkh_mu_decode = create pkh_mu_decode_len (u8 0) in let pkh = sub sk (crypto_secretkeybytes a -! bytes_pkhash a) (bytes_pkhash a) in concat2 (bytes_pkhash a) pkh (bytes_mu a) mu_decode pkh_mu_decode; frodo_shake a pkh_mu_decode_len pkh_mu_decode (2ul *! crypto_bytes a) seed_se_k; pop_frame () inline_for_extraction noextract val crypto_kem_dec_ss1: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> mu_decode:lbytes (bytes_mu a) -> seed_se_k:lbytes (2ul *! crypto_bytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> ss:lbytes (crypto_bytes a) -> Stack unit (requires fun h -> live h mu_decode /\ live h bp_matrix /\ live h seed_se_k /\ live h c_matrix /\ live h sk /\ live h ct /\ live h ss /\ loc_pairwise_disjoint [loc ct; loc sk; loc seed_se_k; loc mu_decode; loc bp_matrix; loc c_matrix; loc ss]) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ss1 a gen_a (as_seq h0 ct) (as_seq h0 sk) (as_seq h0 mu_decode) (as_seq h0 seed_se_k) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
false
false
Hacl.Impl.Frodo.KEM.Decaps.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val crypto_kem_dec_ss1: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> mu_decode:lbytes (bytes_mu a) -> seed_se_k:lbytes (2ul *! crypto_bytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> ss:lbytes (crypto_bytes a) -> Stack unit (requires fun h -> live h mu_decode /\ live h bp_matrix /\ live h seed_se_k /\ live h c_matrix /\ live h sk /\ live h ct /\ live h ss /\ loc_pairwise_disjoint [loc ct; loc sk; loc seed_se_k; loc mu_decode; loc bp_matrix; loc c_matrix; loc ss]) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ss1 a gen_a (as_seq h0 ct) (as_seq h0 sk) (as_seq h0 mu_decode) (as_seq h0 seed_se_k) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
[]
Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec_ss1
{ "file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Decaps.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_alg -> gen_a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported gen_a} -> ct: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_ciphertextbytes a) -> sk: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_secretkeybytes a) -> mu_decode: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.bytes_mu a) -> seed_se_k: Hacl.Impl.Matrix.lbytes (2ul *! Hacl.Impl.Frodo.Params.crypto_bytes a) -> bp_matrix: Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar (Hacl.Impl.Frodo.Params.params_n a) -> c_matrix: Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar Hacl.Impl.Frodo.Params.params_nbar -> ss: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_bytes a) -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 38, "end_line": 278, "start_col": 80, "start_line": 272 }
FStar.HyperStack.ST.Stack
val crypto_kem_dec: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ss:lbytes (crypto_bytes a) -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> Stack uint32 (requires fun h -> live h ss /\ live h ct /\ live h sk /\ disjoint ss ct /\ disjoint ss sk /\ disjoint ct sk) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec a gen_a (as_seq h0 ct) (as_seq h0 sk))
[ { "abbrev": true, "full_module": "Spec.Matrix", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Frodo.KEM.Decaps", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Impl.Frodo.KEM.KeyGen", "short_module": "KG" }, { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "FP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Frodo.Random", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Sample", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Pack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Encode", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM.Encaps", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Params", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let crypto_kem_dec a gen_a ss ct sk = push_frame (); let bp_matrix = matrix_create params_nbar (params_n a) in let c_matrix = matrix_create params_nbar params_nbar in get_bp_c_matrices a ct bp_matrix c_matrix; crypto_kem_dec1 a gen_a ss ct sk bp_matrix c_matrix; pop_frame (); u32 0
val crypto_kem_dec: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ss:lbytes (crypto_bytes a) -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> Stack uint32 (requires fun h -> live h ss /\ live h ct /\ live h sk /\ disjoint ss ct /\ disjoint ss sk /\ disjoint ct sk) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec a gen_a (as_seq h0 ct) (as_seq h0 sk)) let crypto_kem_dec a gen_a ss ct sk =
true
null
false
push_frame (); let bp_matrix = matrix_create params_nbar (params_n a) in let c_matrix = matrix_create params_nbar params_nbar in get_bp_c_matrices a ct bp_matrix c_matrix; crypto_kem_dec1 a gen_a ss ct sk bp_matrix c_matrix; pop_frame (); u32 0
{ "checked_file": "Hacl.Impl.Frodo.KEM.Decaps.fst.checked", "dependencies": [ "Spec.Matrix.fst.checked", "Spec.Frodo.Params.fst.checked", "Spec.Frodo.KEM.Decaps.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Sample.fst.checked", "Hacl.Impl.Frodo.Params.fst.checked", "Hacl.Impl.Frodo.Pack.fst.checked", "Hacl.Impl.Frodo.KEM.KeyGen.fst.checked", "Hacl.Impl.Frodo.KEM.Encaps.fst.checked", "Hacl.Impl.Frodo.KEM.fst.checked", "Hacl.Impl.Frodo.Encode.fst.checked", "Hacl.Frodo.Random.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.KEM.Decaps.fst" }
[]
[ "Spec.Frodo.Params.frodo_alg", "Spec.Frodo.Params.frodo_gen_a", "Prims.b2t", "Hacl.Impl.Frodo.Params.is_supported", "Hacl.Impl.Matrix.lbytes", "Hacl.Impl.Frodo.Params.crypto_bytes", "Hacl.Impl.Frodo.Params.crypto_ciphertextbytes", "Hacl.Impl.Frodo.Params.crypto_secretkeybytes", "Lib.IntTypes.u32", "Lib.IntTypes.uint32", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec1", "Hacl.Impl.Frodo.KEM.Decaps.get_bp_c_matrices", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U16", "Lib.IntTypes.SEC", "Lib.IntTypes.mul", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.Frodo.Params.params_nbar", "Hacl.Impl.Matrix.matrix_create", "Hacl.Impl.Matrix.matrix_t", "Hacl.Impl.Frodo.Params.params_n", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Impl.Frodo.KEM.Decaps open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix open Hacl.Impl.Frodo.Params open Hacl.Impl.Frodo.KEM open Hacl.Impl.Frodo.KEM.Encaps open Hacl.Impl.Frodo.Encode open Hacl.Impl.Frodo.Pack open Hacl.Impl.Frodo.Sample open Hacl.Frodo.Random module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module FP = Spec.Frodo.Params module KG = Hacl.Impl.Frodo.KEM.KeyGen module S = Spec.Frodo.KEM.Decaps module M = Spec.Matrix #set-options "--z3rlimit 100 --fuel 0 --ifuel 0" inline_for_extraction noextract val get_bp_c_matrices: a:FP.frodo_alg -> ct:lbytes (crypto_ciphertextbytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h ct /\ live h bp_matrix /\ live h c_matrix /\ disjoint bp_matrix ct /\ disjoint c_matrix ct /\ disjoint bp_matrix c_matrix) (ensures fun h0 _ h1 -> modifies (loc bp_matrix |+| loc c_matrix) h0 h1 /\ (as_matrix h1 bp_matrix, as_matrix h1 c_matrix) == S.get_bp_c_matrices a (as_seq h0 ct)) let get_bp_c_matrices a ct bp_matrix c_matrix = let c1 = sub ct 0ul (ct1bytes_len a) in let c2 = sub ct (ct1bytes_len a) (ct2bytes_len a) in frodo_unpack params_nbar (params_n a) (params_logq a) c1 bp_matrix; frodo_unpack params_nbar params_nbar (params_logq a) c2 c_matrix inline_for_extraction noextract val frodo_mu_decode: a:FP.frodo_alg -> s_bytes:lbytes (secretmatrixbytes_len a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> mu_decode:lbytes (bytes_mu a) -> Stack unit (requires fun h -> live h s_bytes /\ live h bp_matrix /\ live h c_matrix /\ live h mu_decode /\ disjoint mu_decode s_bytes /\ as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc mu_decode) h0 h1 /\ as_seq h1 mu_decode == S.frodo_mu_decode a (as_seq h0 s_bytes) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let frodo_mu_decode a s_bytes bp_matrix c_matrix mu_decode = push_frame(); let s_matrix = matrix_create (params_n a) params_nbar in let m_matrix = matrix_create params_nbar params_nbar in matrix_from_lbytes s_bytes s_matrix; matrix_mul_s bp_matrix s_matrix m_matrix; matrix_sub c_matrix m_matrix; frodo_key_decode (params_logq a) (params_extracted_bits a) params_nbar m_matrix mu_decode; clear_matrix s_matrix; clear_matrix m_matrix; pop_frame() inline_for_extraction noextract val get_bpp_cp_matrices_: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> sk:lbytes (crypto_secretkeybytes a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> cp_matrix:matrix_t params_nbar params_nbar -> sp_matrix:matrix_t params_nbar (params_n a) -> ep_matrix:matrix_t params_nbar (params_n a) -> epp_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h mu_decode /\ live h sk /\ live h bpp_matrix /\ live h cp_matrix /\ live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\ loc_pairwise_disjoint [loc mu_decode; loc sk; loc bpp_matrix; loc cp_matrix; loc sp_matrix; loc ep_matrix; loc epp_matrix]) (ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\ (as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) == S.get_bpp_cp_matrices_ a gen_a (as_seq h0 mu_decode) (as_seq h0 sk) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix) (as_matrix h0 epp_matrix)) let get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix = FP.expand_crypto_secretkeybytes a; FP.expand_crypto_publickeybytes a; let pk = sub sk (crypto_bytes a) (crypto_publickeybytes a) in let seed_a = sub pk 0ul bytes_seed_a in let b = sub pk bytes_seed_a (crypto_publickeybytes a -! bytes_seed_a) in frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bpp_matrix; frodo_mul_add_sb_plus_e_plus_mu a mu_decode b sp_matrix epp_matrix cp_matrix; mod_pow2 (params_logq a) bpp_matrix; mod_pow2 (params_logq a) cp_matrix #push-options "--z3rlimit 150" inline_for_extraction noextract val get_bpp_cp_matrices: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> seed_se:lbytes (crypto_bytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> cp_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h seed_se /\ live h mu_decode /\ live h sk /\ live h bpp_matrix /\ live h cp_matrix /\ loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk; loc bpp_matrix; loc cp_matrix]) (ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\ (as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) == S.get_bpp_cp_matrices a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se) (as_seq h0 sk)) let get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix = push_frame (); let sp_matrix = matrix_create params_nbar (params_n a) in let ep_matrix = matrix_create params_nbar (params_n a) in let epp_matrix = matrix_create params_nbar params_nbar in get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix; get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix; clear_matrix3 a sp_matrix ep_matrix epp_matrix; pop_frame () #pop-options inline_for_extraction noextract val crypto_kem_dec_kp_s_cond: a:FP.frodo_alg -> bp_matrix:matrix_t params_nbar (params_n a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> cp_matrix:matrix_t params_nbar params_nbar -> Stack uint16 (requires fun h -> live h bp_matrix /\ live h bpp_matrix /\ live h c_matrix /\ live h cp_matrix) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.crypto_kem_dec_kp_s_cond a (as_matrix h0 bp_matrix) (as_matrix h0 bpp_matrix) (as_matrix h0 c_matrix) (as_matrix h0 cp_matrix)) let crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix = let b1 = matrix_eq bp_matrix bpp_matrix in let b2 = matrix_eq c_matrix cp_matrix in b1 &. b2 inline_for_extraction noextract val crypto_kem_dec_kp_s: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> seed_se:lbytes (crypto_bytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack uint16 (requires fun h -> live h mu_decode /\ live h bp_matrix /\ live h seed_se /\ live h c_matrix /\ live h sk /\ loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk]) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.crypto_kem_dec_kp_s a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se) (as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let crypto_kem_dec_kp_s a gen_a mu_decode seed_se sk bp_matrix c_matrix = push_frame (); let bpp_matrix = matrix_create params_nbar (params_n a) in let cp_matrix = matrix_create params_nbar params_nbar in get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix; let mask = crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix in pop_frame (); mask inline_for_extraction noextract val crypto_kem_dec_ss0: a:FP.frodo_alg -> ct:lbytes (crypto_ciphertextbytes a) -> mask:uint16{v mask == 0 \/ v mask == v (ones U16 SEC)} -> kp:lbytes (crypto_bytes a) -> s:lbytes (crypto_bytes a) -> ss:lbytes (crypto_bytes a) -> Stack unit (requires fun h -> live h ct /\ live h kp /\ live h s /\ live h ss /\ disjoint ss ct /\ disjoint ss kp /\ disjoint ss s /\ disjoint kp s) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ss0 a (as_seq h0 ct) mask (as_seq h0 kp) (as_seq h0 s)) let crypto_kem_dec_ss0 a ct mask kp s ss = push_frame (); let kp_s = create (crypto_bytes a) (u8 0) in Lib.ByteBuffer.buf_mask_select kp s (to_u8 mask) kp_s; let ss_init_len = crypto_ciphertextbytes a +! crypto_bytes a in let ss_init = create ss_init_len (u8 0) in concat2 (crypto_ciphertextbytes a) ct (crypto_bytes a) kp_s ss_init; frodo_shake a ss_init_len ss_init (crypto_bytes a) ss; clear_words_u8 ss_init; clear_words_u8 kp_s; pop_frame () inline_for_extraction noextract val crypto_kem_dec_seed_se_k: a:FP.frodo_alg -> mu_decode:lbytes (bytes_mu a) -> sk:lbytes (crypto_secretkeybytes a) -> seed_se_k:lbytes (2ul *! crypto_bytes a) -> Stack unit (requires fun h -> live h mu_decode /\ live h sk /\ live h seed_se_k /\ disjoint mu_decode seed_se_k /\ disjoint sk seed_se_k) (ensures fun h0 _ h1 -> modifies (loc seed_se_k) h0 h1 /\ as_seq h1 seed_se_k == S.crypto_kem_dec_seed_se_k a (as_seq h0 mu_decode) (as_seq h0 sk)) let crypto_kem_dec_seed_se_k a mu_decode sk seed_se_k = push_frame (); let pkh_mu_decode_len = bytes_pkhash a +! bytes_mu a in let pkh_mu_decode = create pkh_mu_decode_len (u8 0) in let pkh = sub sk (crypto_secretkeybytes a -! bytes_pkhash a) (bytes_pkhash a) in concat2 (bytes_pkhash a) pkh (bytes_mu a) mu_decode pkh_mu_decode; frodo_shake a pkh_mu_decode_len pkh_mu_decode (2ul *! crypto_bytes a) seed_se_k; pop_frame () inline_for_extraction noextract val crypto_kem_dec_ss1: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> mu_decode:lbytes (bytes_mu a) -> seed_se_k:lbytes (2ul *! crypto_bytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> ss:lbytes (crypto_bytes a) -> Stack unit (requires fun h -> live h mu_decode /\ live h bp_matrix /\ live h seed_se_k /\ live h c_matrix /\ live h sk /\ live h ct /\ live h ss /\ loc_pairwise_disjoint [loc ct; loc sk; loc seed_se_k; loc mu_decode; loc bp_matrix; loc c_matrix; loc ss]) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ss1 a gen_a (as_seq h0 ct) (as_seq h0 sk) (as_seq h0 mu_decode) (as_seq h0 seed_se_k) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let crypto_kem_dec_ss1 a gen_a ct sk mu_decode seed_se_k bp_matrix c_matrix ss = let seed_se = sub seed_se_k 0ul (crypto_bytes a) in let kp = sub seed_se_k (crypto_bytes a) (crypto_bytes a) in let s = sub sk 0ul (crypto_bytes a) in let mask = crypto_kem_dec_kp_s a gen_a mu_decode seed_se sk bp_matrix c_matrix in crypto_kem_dec_ss0 a ct mask kp s ss inline_for_extraction noextract val crypto_kem_dec_ss2: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> mu_decode:lbytes (bytes_mu a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> ss:lbytes (crypto_bytes a) -> Stack unit (requires fun h -> live h mu_decode /\ live h bp_matrix /\ live h c_matrix /\ live h sk /\ live h ct /\ live h ss /\ loc_pairwise_disjoint [loc ct; loc sk; loc mu_decode; loc bp_matrix; loc c_matrix; loc ss]) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ss2 a gen_a (as_seq h0 ct) (as_seq h0 sk) (as_seq h0 mu_decode) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let crypto_kem_dec_ss2 a gen_a ct sk mu_decode bp_matrix c_matrix ss = push_frame (); let seed_se_k = create (2ul *! crypto_bytes a) (u8 0) in crypto_kem_dec_seed_se_k a mu_decode sk seed_se_k; crypto_kem_dec_ss1 a gen_a ct sk mu_decode seed_se_k bp_matrix c_matrix ss; clear_words_u8 seed_se_k; pop_frame () inline_for_extraction noextract val crypto_kem_dec_mu: a:FP.frodo_alg -> sk:lbytes (crypto_secretkeybytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> mu_decode:lbytes (bytes_mu a) -> Stack unit (requires fun h -> live h sk /\ live h mu_decode /\ live h bp_matrix /\ live h c_matrix /\ as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0) /\ loc_pairwise_disjoint [loc sk; loc mu_decode; loc bp_matrix; loc c_matrix]) (ensures fun h0 _ h1 -> modifies (loc mu_decode) h0 h1 /\ as_seq h1 mu_decode == S.crypto_kem_dec_mu a (as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let crypto_kem_dec_mu a sk bp_matrix c_matrix mu_decode = FP.expand_crypto_secretkeybytes a; let s_bytes = sub sk (crypto_bytes a +! crypto_publickeybytes a) (secretmatrixbytes_len a) in frodo_mu_decode a s_bytes bp_matrix c_matrix mu_decode inline_for_extraction noextract val crypto_kem_dec0: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ss:lbytes (crypto_bytes a) -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> mu_decode:lbytes (bytes_mu a) -> Stack unit (requires fun h -> live h ss /\ live h ct /\ live h sk /\ live h mu_decode /\ live h bp_matrix /\ live h c_matrix /\ as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0) /\ loc_pairwise_disjoint [loc ss; loc ct; loc sk; loc mu_decode; loc bp_matrix; loc c_matrix]) (ensures fun h0 _ h1 -> modifies (loc ss |+| loc mu_decode) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ a gen_a (as_seq h0 ct) (as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let crypto_kem_dec0 a gen_a ss ct sk bp_matrix c_matrix mu_decode = crypto_kem_dec_mu a sk bp_matrix c_matrix mu_decode; crypto_kem_dec_ss2 a gen_a ct sk mu_decode bp_matrix c_matrix ss inline_for_extraction noextract val crypto_kem_dec1: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ss:lbytes (crypto_bytes a) -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h ss /\ live h ct /\ live h sk /\ live h bp_matrix /\ live h c_matrix /\ loc_pairwise_disjoint [loc ss; loc ct; loc sk; loc bp_matrix; loc c_matrix]) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ a gen_a (as_seq h0 ct) (as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let crypto_kem_dec1 a gen_a ss ct sk bp_matrix c_matrix = push_frame (); let mu_decode = create (bytes_mu a) (u8 0) in crypto_kem_dec0 a gen_a ss ct sk bp_matrix c_matrix mu_decode; clear_words_u8 mu_decode; pop_frame () inline_for_extraction noextract val crypto_kem_dec: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ss:lbytes (crypto_bytes a) -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> Stack uint32 (requires fun h -> live h ss /\ live h ct /\ live h sk /\ disjoint ss ct /\ disjoint ss sk /\ disjoint ct sk) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec a gen_a (as_seq h0 ct) (as_seq h0 sk))
false
false
Hacl.Impl.Frodo.KEM.Decaps.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val crypto_kem_dec: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ss:lbytes (crypto_bytes a) -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> Stack uint32 (requires fun h -> live h ss /\ live h ct /\ live h sk /\ disjoint ss ct /\ disjoint ss sk /\ disjoint ct sk) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec a gen_a (as_seq h0 ct) (as_seq h0 sk))
[]
Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec
{ "file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Decaps.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_alg -> gen_a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported gen_a} -> ss: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_bytes a) -> ct: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_ciphertextbytes a) -> sk: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_secretkeybytes a) -> FStar.HyperStack.ST.Stack Lib.IntTypes.uint32
{ "end_col": 7, "end_line": 407, "start_col": 2, "start_line": 400 }
FStar.HyperStack.ST.Stack
val crypto_kem_dec_kp_s: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> seed_se:lbytes (crypto_bytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack uint16 (requires fun h -> live h mu_decode /\ live h bp_matrix /\ live h seed_se /\ live h c_matrix /\ live h sk /\ loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk]) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.crypto_kem_dec_kp_s a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se) (as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
[ { "abbrev": true, "full_module": "Spec.Matrix", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Frodo.KEM.Decaps", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Impl.Frodo.KEM.KeyGen", "short_module": "KG" }, { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "FP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Frodo.Random", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Sample", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Pack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Encode", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM.Encaps", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Params", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let crypto_kem_dec_kp_s a gen_a mu_decode seed_se sk bp_matrix c_matrix = push_frame (); let bpp_matrix = matrix_create params_nbar (params_n a) in let cp_matrix = matrix_create params_nbar params_nbar in get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix; let mask = crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix in pop_frame (); mask
val crypto_kem_dec_kp_s: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> seed_se:lbytes (crypto_bytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack uint16 (requires fun h -> live h mu_decode /\ live h bp_matrix /\ live h seed_se /\ live h c_matrix /\ live h sk /\ loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk]) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.crypto_kem_dec_kp_s a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se) (as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let crypto_kem_dec_kp_s a gen_a mu_decode seed_se sk bp_matrix c_matrix =
true
null
false
push_frame (); let bpp_matrix = matrix_create params_nbar (params_n a) in let cp_matrix = matrix_create params_nbar params_nbar in get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix; let mask = crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix in pop_frame (); mask
{ "checked_file": "Hacl.Impl.Frodo.KEM.Decaps.fst.checked", "dependencies": [ "Spec.Matrix.fst.checked", "Spec.Frodo.Params.fst.checked", "Spec.Frodo.KEM.Decaps.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Sample.fst.checked", "Hacl.Impl.Frodo.Params.fst.checked", "Hacl.Impl.Frodo.Pack.fst.checked", "Hacl.Impl.Frodo.KEM.KeyGen.fst.checked", "Hacl.Impl.Frodo.KEM.Encaps.fst.checked", "Hacl.Impl.Frodo.KEM.fst.checked", "Hacl.Impl.Frodo.Encode.fst.checked", "Hacl.Frodo.Random.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.KEM.Decaps.fst" }
[]
[ "Spec.Frodo.Params.frodo_alg", "Spec.Frodo.Params.frodo_gen_a", "Prims.b2t", "Hacl.Impl.Frodo.Params.is_supported", "Hacl.Impl.Matrix.lbytes", "Hacl.Impl.Frodo.Params.bytes_mu", "Hacl.Impl.Frodo.Params.crypto_bytes", "Hacl.Impl.Frodo.Params.crypto_secretkeybytes", "Hacl.Impl.Matrix.matrix_t", "Hacl.Impl.Frodo.Params.params_nbar", "Hacl.Impl.Frodo.Params.params_n", "Lib.IntTypes.uint16", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Lib.IntTypes.int_t", "Lib.IntTypes.U16", "Lib.IntTypes.SEC", "Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec_kp_s_cond", "Hacl.Impl.Frodo.KEM.Decaps.get_bpp_cp_matrices", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.mul", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.Matrix.matrix_create", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Impl.Frodo.KEM.Decaps open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix open Hacl.Impl.Frodo.Params open Hacl.Impl.Frodo.KEM open Hacl.Impl.Frodo.KEM.Encaps open Hacl.Impl.Frodo.Encode open Hacl.Impl.Frodo.Pack open Hacl.Impl.Frodo.Sample open Hacl.Frodo.Random module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module FP = Spec.Frodo.Params module KG = Hacl.Impl.Frodo.KEM.KeyGen module S = Spec.Frodo.KEM.Decaps module M = Spec.Matrix #set-options "--z3rlimit 100 --fuel 0 --ifuel 0" inline_for_extraction noextract val get_bp_c_matrices: a:FP.frodo_alg -> ct:lbytes (crypto_ciphertextbytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h ct /\ live h bp_matrix /\ live h c_matrix /\ disjoint bp_matrix ct /\ disjoint c_matrix ct /\ disjoint bp_matrix c_matrix) (ensures fun h0 _ h1 -> modifies (loc bp_matrix |+| loc c_matrix) h0 h1 /\ (as_matrix h1 bp_matrix, as_matrix h1 c_matrix) == S.get_bp_c_matrices a (as_seq h0 ct)) let get_bp_c_matrices a ct bp_matrix c_matrix = let c1 = sub ct 0ul (ct1bytes_len a) in let c2 = sub ct (ct1bytes_len a) (ct2bytes_len a) in frodo_unpack params_nbar (params_n a) (params_logq a) c1 bp_matrix; frodo_unpack params_nbar params_nbar (params_logq a) c2 c_matrix inline_for_extraction noextract val frodo_mu_decode: a:FP.frodo_alg -> s_bytes:lbytes (secretmatrixbytes_len a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> mu_decode:lbytes (bytes_mu a) -> Stack unit (requires fun h -> live h s_bytes /\ live h bp_matrix /\ live h c_matrix /\ live h mu_decode /\ disjoint mu_decode s_bytes /\ as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc mu_decode) h0 h1 /\ as_seq h1 mu_decode == S.frodo_mu_decode a (as_seq h0 s_bytes) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let frodo_mu_decode a s_bytes bp_matrix c_matrix mu_decode = push_frame(); let s_matrix = matrix_create (params_n a) params_nbar in let m_matrix = matrix_create params_nbar params_nbar in matrix_from_lbytes s_bytes s_matrix; matrix_mul_s bp_matrix s_matrix m_matrix; matrix_sub c_matrix m_matrix; frodo_key_decode (params_logq a) (params_extracted_bits a) params_nbar m_matrix mu_decode; clear_matrix s_matrix; clear_matrix m_matrix; pop_frame() inline_for_extraction noextract val get_bpp_cp_matrices_: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> sk:lbytes (crypto_secretkeybytes a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> cp_matrix:matrix_t params_nbar params_nbar -> sp_matrix:matrix_t params_nbar (params_n a) -> ep_matrix:matrix_t params_nbar (params_n a) -> epp_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h mu_decode /\ live h sk /\ live h bpp_matrix /\ live h cp_matrix /\ live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\ loc_pairwise_disjoint [loc mu_decode; loc sk; loc bpp_matrix; loc cp_matrix; loc sp_matrix; loc ep_matrix; loc epp_matrix]) (ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\ (as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) == S.get_bpp_cp_matrices_ a gen_a (as_seq h0 mu_decode) (as_seq h0 sk) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix) (as_matrix h0 epp_matrix)) let get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix = FP.expand_crypto_secretkeybytes a; FP.expand_crypto_publickeybytes a; let pk = sub sk (crypto_bytes a) (crypto_publickeybytes a) in let seed_a = sub pk 0ul bytes_seed_a in let b = sub pk bytes_seed_a (crypto_publickeybytes a -! bytes_seed_a) in frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bpp_matrix; frodo_mul_add_sb_plus_e_plus_mu a mu_decode b sp_matrix epp_matrix cp_matrix; mod_pow2 (params_logq a) bpp_matrix; mod_pow2 (params_logq a) cp_matrix #push-options "--z3rlimit 150" inline_for_extraction noextract val get_bpp_cp_matrices: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> seed_se:lbytes (crypto_bytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> cp_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h seed_se /\ live h mu_decode /\ live h sk /\ live h bpp_matrix /\ live h cp_matrix /\ loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk; loc bpp_matrix; loc cp_matrix]) (ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\ (as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) == S.get_bpp_cp_matrices a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se) (as_seq h0 sk)) let get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix = push_frame (); let sp_matrix = matrix_create params_nbar (params_n a) in let ep_matrix = matrix_create params_nbar (params_n a) in let epp_matrix = matrix_create params_nbar params_nbar in get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix; get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix; clear_matrix3 a sp_matrix ep_matrix epp_matrix; pop_frame () #pop-options inline_for_extraction noextract val crypto_kem_dec_kp_s_cond: a:FP.frodo_alg -> bp_matrix:matrix_t params_nbar (params_n a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> cp_matrix:matrix_t params_nbar params_nbar -> Stack uint16 (requires fun h -> live h bp_matrix /\ live h bpp_matrix /\ live h c_matrix /\ live h cp_matrix) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.crypto_kem_dec_kp_s_cond a (as_matrix h0 bp_matrix) (as_matrix h0 bpp_matrix) (as_matrix h0 c_matrix) (as_matrix h0 cp_matrix)) let crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix = let b1 = matrix_eq bp_matrix bpp_matrix in let b2 = matrix_eq c_matrix cp_matrix in b1 &. b2 inline_for_extraction noextract val crypto_kem_dec_kp_s: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> seed_se:lbytes (crypto_bytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack uint16 (requires fun h -> live h mu_decode /\ live h bp_matrix /\ live h seed_se /\ live h c_matrix /\ live h sk /\ loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk]) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.crypto_kem_dec_kp_s a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se) (as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
false
false
Hacl.Impl.Frodo.KEM.Decaps.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val crypto_kem_dec_kp_s: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> seed_se:lbytes (crypto_bytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack uint16 (requires fun h -> live h mu_decode /\ live h bp_matrix /\ live h seed_se /\ live h c_matrix /\ live h sk /\ loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk]) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.crypto_kem_dec_kp_s a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se) (as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
[]
Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec_kp_s
{ "file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Decaps.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_alg -> gen_a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported gen_a} -> mu_decode: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.bytes_mu a) -> seed_se: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_bytes a) -> sk: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_secretkeybytes a) -> bp_matrix: Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar (Hacl.Impl.Frodo.Params.params_n a) -> c_matrix: Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar Hacl.Impl.Frodo.Params.params_nbar -> FStar.HyperStack.ST.Stack Lib.IntTypes.uint16
{ "end_col": 6, "end_line": 194, "start_col": 2, "start_line": 188 }
FStar.HyperStack.ST.Stack
val crypto_kem_dec_ss2: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> mu_decode:lbytes (bytes_mu a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> ss:lbytes (crypto_bytes a) -> Stack unit (requires fun h -> live h mu_decode /\ live h bp_matrix /\ live h c_matrix /\ live h sk /\ live h ct /\ live h ss /\ loc_pairwise_disjoint [loc ct; loc sk; loc mu_decode; loc bp_matrix; loc c_matrix; loc ss]) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ss2 a gen_a (as_seq h0 ct) (as_seq h0 sk) (as_seq h0 mu_decode) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
[ { "abbrev": true, "full_module": "Spec.Matrix", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Frodo.KEM.Decaps", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Impl.Frodo.KEM.KeyGen", "short_module": "KG" }, { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "FP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Frodo.Random", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Sample", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Pack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Encode", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM.Encaps", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Params", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let crypto_kem_dec_ss2 a gen_a ct sk mu_decode bp_matrix c_matrix ss = push_frame (); let seed_se_k = create (2ul *! crypto_bytes a) (u8 0) in crypto_kem_dec_seed_se_k a mu_decode sk seed_se_k; crypto_kem_dec_ss1 a gen_a ct sk mu_decode seed_se_k bp_matrix c_matrix ss; clear_words_u8 seed_se_k; pop_frame ()
val crypto_kem_dec_ss2: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> mu_decode:lbytes (bytes_mu a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> ss:lbytes (crypto_bytes a) -> Stack unit (requires fun h -> live h mu_decode /\ live h bp_matrix /\ live h c_matrix /\ live h sk /\ live h ct /\ live h ss /\ loc_pairwise_disjoint [loc ct; loc sk; loc mu_decode; loc bp_matrix; loc c_matrix; loc ss]) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ss2 a gen_a (as_seq h0 ct) (as_seq h0 sk) (as_seq h0 mu_decode) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let crypto_kem_dec_ss2 a gen_a ct sk mu_decode bp_matrix c_matrix ss =
true
null
false
push_frame (); let seed_se_k = create (2ul *! crypto_bytes a) (u8 0) in crypto_kem_dec_seed_se_k a mu_decode sk seed_se_k; crypto_kem_dec_ss1 a gen_a ct sk mu_decode seed_se_k bp_matrix c_matrix ss; clear_words_u8 seed_se_k; pop_frame ()
{ "checked_file": "Hacl.Impl.Frodo.KEM.Decaps.fst.checked", "dependencies": [ "Spec.Matrix.fst.checked", "Spec.Frodo.Params.fst.checked", "Spec.Frodo.KEM.Decaps.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Sample.fst.checked", "Hacl.Impl.Frodo.Params.fst.checked", "Hacl.Impl.Frodo.Pack.fst.checked", "Hacl.Impl.Frodo.KEM.KeyGen.fst.checked", "Hacl.Impl.Frodo.KEM.Encaps.fst.checked", "Hacl.Impl.Frodo.KEM.fst.checked", "Hacl.Impl.Frodo.Encode.fst.checked", "Hacl.Frodo.Random.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.KEM.Decaps.fst" }
[]
[ "Spec.Frodo.Params.frodo_alg", "Spec.Frodo.Params.frodo_gen_a", "Prims.b2t", "Hacl.Impl.Frodo.Params.is_supported", "Hacl.Impl.Matrix.lbytes", "Hacl.Impl.Frodo.Params.crypto_ciphertextbytes", "Hacl.Impl.Frodo.Params.crypto_secretkeybytes", "Hacl.Impl.Frodo.Params.bytes_mu", "Hacl.Impl.Matrix.matrix_t", "Hacl.Impl.Frodo.Params.params_nbar", "Hacl.Impl.Frodo.Params.params_n", "Hacl.Impl.Frodo.Params.crypto_bytes", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Impl.Frodo.KEM.clear_words_u8", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec_ss1", "Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec_seed_se_k", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.IntTypes.mul", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.create", "Lib.IntTypes.uint8", "Lib.IntTypes.u8", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Impl.Frodo.KEM.Decaps open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix open Hacl.Impl.Frodo.Params open Hacl.Impl.Frodo.KEM open Hacl.Impl.Frodo.KEM.Encaps open Hacl.Impl.Frodo.Encode open Hacl.Impl.Frodo.Pack open Hacl.Impl.Frodo.Sample open Hacl.Frodo.Random module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module FP = Spec.Frodo.Params module KG = Hacl.Impl.Frodo.KEM.KeyGen module S = Spec.Frodo.KEM.Decaps module M = Spec.Matrix #set-options "--z3rlimit 100 --fuel 0 --ifuel 0" inline_for_extraction noextract val get_bp_c_matrices: a:FP.frodo_alg -> ct:lbytes (crypto_ciphertextbytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h ct /\ live h bp_matrix /\ live h c_matrix /\ disjoint bp_matrix ct /\ disjoint c_matrix ct /\ disjoint bp_matrix c_matrix) (ensures fun h0 _ h1 -> modifies (loc bp_matrix |+| loc c_matrix) h0 h1 /\ (as_matrix h1 bp_matrix, as_matrix h1 c_matrix) == S.get_bp_c_matrices a (as_seq h0 ct)) let get_bp_c_matrices a ct bp_matrix c_matrix = let c1 = sub ct 0ul (ct1bytes_len a) in let c2 = sub ct (ct1bytes_len a) (ct2bytes_len a) in frodo_unpack params_nbar (params_n a) (params_logq a) c1 bp_matrix; frodo_unpack params_nbar params_nbar (params_logq a) c2 c_matrix inline_for_extraction noextract val frodo_mu_decode: a:FP.frodo_alg -> s_bytes:lbytes (secretmatrixbytes_len a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> mu_decode:lbytes (bytes_mu a) -> Stack unit (requires fun h -> live h s_bytes /\ live h bp_matrix /\ live h c_matrix /\ live h mu_decode /\ disjoint mu_decode s_bytes /\ as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc mu_decode) h0 h1 /\ as_seq h1 mu_decode == S.frodo_mu_decode a (as_seq h0 s_bytes) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let frodo_mu_decode a s_bytes bp_matrix c_matrix mu_decode = push_frame(); let s_matrix = matrix_create (params_n a) params_nbar in let m_matrix = matrix_create params_nbar params_nbar in matrix_from_lbytes s_bytes s_matrix; matrix_mul_s bp_matrix s_matrix m_matrix; matrix_sub c_matrix m_matrix; frodo_key_decode (params_logq a) (params_extracted_bits a) params_nbar m_matrix mu_decode; clear_matrix s_matrix; clear_matrix m_matrix; pop_frame() inline_for_extraction noextract val get_bpp_cp_matrices_: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> sk:lbytes (crypto_secretkeybytes a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> cp_matrix:matrix_t params_nbar params_nbar -> sp_matrix:matrix_t params_nbar (params_n a) -> ep_matrix:matrix_t params_nbar (params_n a) -> epp_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h mu_decode /\ live h sk /\ live h bpp_matrix /\ live h cp_matrix /\ live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\ loc_pairwise_disjoint [loc mu_decode; loc sk; loc bpp_matrix; loc cp_matrix; loc sp_matrix; loc ep_matrix; loc epp_matrix]) (ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\ (as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) == S.get_bpp_cp_matrices_ a gen_a (as_seq h0 mu_decode) (as_seq h0 sk) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix) (as_matrix h0 epp_matrix)) let get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix = FP.expand_crypto_secretkeybytes a; FP.expand_crypto_publickeybytes a; let pk = sub sk (crypto_bytes a) (crypto_publickeybytes a) in let seed_a = sub pk 0ul bytes_seed_a in let b = sub pk bytes_seed_a (crypto_publickeybytes a -! bytes_seed_a) in frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bpp_matrix; frodo_mul_add_sb_plus_e_plus_mu a mu_decode b sp_matrix epp_matrix cp_matrix; mod_pow2 (params_logq a) bpp_matrix; mod_pow2 (params_logq a) cp_matrix #push-options "--z3rlimit 150" inline_for_extraction noextract val get_bpp_cp_matrices: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> seed_se:lbytes (crypto_bytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> cp_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h seed_se /\ live h mu_decode /\ live h sk /\ live h bpp_matrix /\ live h cp_matrix /\ loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk; loc bpp_matrix; loc cp_matrix]) (ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\ (as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) == S.get_bpp_cp_matrices a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se) (as_seq h0 sk)) let get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix = push_frame (); let sp_matrix = matrix_create params_nbar (params_n a) in let ep_matrix = matrix_create params_nbar (params_n a) in let epp_matrix = matrix_create params_nbar params_nbar in get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix; get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix; clear_matrix3 a sp_matrix ep_matrix epp_matrix; pop_frame () #pop-options inline_for_extraction noextract val crypto_kem_dec_kp_s_cond: a:FP.frodo_alg -> bp_matrix:matrix_t params_nbar (params_n a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> cp_matrix:matrix_t params_nbar params_nbar -> Stack uint16 (requires fun h -> live h bp_matrix /\ live h bpp_matrix /\ live h c_matrix /\ live h cp_matrix) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.crypto_kem_dec_kp_s_cond a (as_matrix h0 bp_matrix) (as_matrix h0 bpp_matrix) (as_matrix h0 c_matrix) (as_matrix h0 cp_matrix)) let crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix = let b1 = matrix_eq bp_matrix bpp_matrix in let b2 = matrix_eq c_matrix cp_matrix in b1 &. b2 inline_for_extraction noextract val crypto_kem_dec_kp_s: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> seed_se:lbytes (crypto_bytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack uint16 (requires fun h -> live h mu_decode /\ live h bp_matrix /\ live h seed_se /\ live h c_matrix /\ live h sk /\ loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk]) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.crypto_kem_dec_kp_s a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se) (as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let crypto_kem_dec_kp_s a gen_a mu_decode seed_se sk bp_matrix c_matrix = push_frame (); let bpp_matrix = matrix_create params_nbar (params_n a) in let cp_matrix = matrix_create params_nbar params_nbar in get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix; let mask = crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix in pop_frame (); mask inline_for_extraction noextract val crypto_kem_dec_ss0: a:FP.frodo_alg -> ct:lbytes (crypto_ciphertextbytes a) -> mask:uint16{v mask == 0 \/ v mask == v (ones U16 SEC)} -> kp:lbytes (crypto_bytes a) -> s:lbytes (crypto_bytes a) -> ss:lbytes (crypto_bytes a) -> Stack unit (requires fun h -> live h ct /\ live h kp /\ live h s /\ live h ss /\ disjoint ss ct /\ disjoint ss kp /\ disjoint ss s /\ disjoint kp s) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ss0 a (as_seq h0 ct) mask (as_seq h0 kp) (as_seq h0 s)) let crypto_kem_dec_ss0 a ct mask kp s ss = push_frame (); let kp_s = create (crypto_bytes a) (u8 0) in Lib.ByteBuffer.buf_mask_select kp s (to_u8 mask) kp_s; let ss_init_len = crypto_ciphertextbytes a +! crypto_bytes a in let ss_init = create ss_init_len (u8 0) in concat2 (crypto_ciphertextbytes a) ct (crypto_bytes a) kp_s ss_init; frodo_shake a ss_init_len ss_init (crypto_bytes a) ss; clear_words_u8 ss_init; clear_words_u8 kp_s; pop_frame () inline_for_extraction noextract val crypto_kem_dec_seed_se_k: a:FP.frodo_alg -> mu_decode:lbytes (bytes_mu a) -> sk:lbytes (crypto_secretkeybytes a) -> seed_se_k:lbytes (2ul *! crypto_bytes a) -> Stack unit (requires fun h -> live h mu_decode /\ live h sk /\ live h seed_se_k /\ disjoint mu_decode seed_se_k /\ disjoint sk seed_se_k) (ensures fun h0 _ h1 -> modifies (loc seed_se_k) h0 h1 /\ as_seq h1 seed_se_k == S.crypto_kem_dec_seed_se_k a (as_seq h0 mu_decode) (as_seq h0 sk)) let crypto_kem_dec_seed_se_k a mu_decode sk seed_se_k = push_frame (); let pkh_mu_decode_len = bytes_pkhash a +! bytes_mu a in let pkh_mu_decode = create pkh_mu_decode_len (u8 0) in let pkh = sub sk (crypto_secretkeybytes a -! bytes_pkhash a) (bytes_pkhash a) in concat2 (bytes_pkhash a) pkh (bytes_mu a) mu_decode pkh_mu_decode; frodo_shake a pkh_mu_decode_len pkh_mu_decode (2ul *! crypto_bytes a) seed_se_k; pop_frame () inline_for_extraction noextract val crypto_kem_dec_ss1: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> mu_decode:lbytes (bytes_mu a) -> seed_se_k:lbytes (2ul *! crypto_bytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> ss:lbytes (crypto_bytes a) -> Stack unit (requires fun h -> live h mu_decode /\ live h bp_matrix /\ live h seed_se_k /\ live h c_matrix /\ live h sk /\ live h ct /\ live h ss /\ loc_pairwise_disjoint [loc ct; loc sk; loc seed_se_k; loc mu_decode; loc bp_matrix; loc c_matrix; loc ss]) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ss1 a gen_a (as_seq h0 ct) (as_seq h0 sk) (as_seq h0 mu_decode) (as_seq h0 seed_se_k) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let crypto_kem_dec_ss1 a gen_a ct sk mu_decode seed_se_k bp_matrix c_matrix ss = let seed_se = sub seed_se_k 0ul (crypto_bytes a) in let kp = sub seed_se_k (crypto_bytes a) (crypto_bytes a) in let s = sub sk 0ul (crypto_bytes a) in let mask = crypto_kem_dec_kp_s a gen_a mu_decode seed_se sk bp_matrix c_matrix in crypto_kem_dec_ss0 a ct mask kp s ss inline_for_extraction noextract val crypto_kem_dec_ss2: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> mu_decode:lbytes (bytes_mu a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> ss:lbytes (crypto_bytes a) -> Stack unit (requires fun h -> live h mu_decode /\ live h bp_matrix /\ live h c_matrix /\ live h sk /\ live h ct /\ live h ss /\ loc_pairwise_disjoint [loc ct; loc sk; loc mu_decode; loc bp_matrix; loc c_matrix; loc ss]) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ss2 a gen_a (as_seq h0 ct) (as_seq h0 sk) (as_seq h0 mu_decode) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
false
false
Hacl.Impl.Frodo.KEM.Decaps.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val crypto_kem_dec_ss2: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> mu_decode:lbytes (bytes_mu a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> ss:lbytes (crypto_bytes a) -> Stack unit (requires fun h -> live h mu_decode /\ live h bp_matrix /\ live h c_matrix /\ live h sk /\ live h ct /\ live h ss /\ loc_pairwise_disjoint [loc ct; loc sk; loc mu_decode; loc bp_matrix; loc c_matrix; loc ss]) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ss2 a gen_a (as_seq h0 ct) (as_seq h0 sk) (as_seq h0 mu_decode) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
[]
Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec_ss2
{ "file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Decaps.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_alg -> gen_a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported gen_a} -> ct: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_ciphertextbytes a) -> sk: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_secretkeybytes a) -> mu_decode: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.bytes_mu a) -> bp_matrix: Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar (Hacl.Impl.Frodo.Params.params_n a) -> c_matrix: Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar Hacl.Impl.Frodo.Params.params_nbar -> ss: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_bytes a) -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 14, "end_line": 307, "start_col": 2, "start_line": 302 }
FStar.HyperStack.ST.Stack
val frodo_mu_decode: a:FP.frodo_alg -> s_bytes:lbytes (secretmatrixbytes_len a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> mu_decode:lbytes (bytes_mu a) -> Stack unit (requires fun h -> live h s_bytes /\ live h bp_matrix /\ live h c_matrix /\ live h mu_decode /\ disjoint mu_decode s_bytes /\ as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc mu_decode) h0 h1 /\ as_seq h1 mu_decode == S.frodo_mu_decode a (as_seq h0 s_bytes) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
[ { "abbrev": true, "full_module": "Spec.Matrix", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Frodo.KEM.Decaps", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Impl.Frodo.KEM.KeyGen", "short_module": "KG" }, { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "FP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Frodo.Random", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Sample", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Pack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Encode", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM.Encaps", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Params", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let frodo_mu_decode a s_bytes bp_matrix c_matrix mu_decode = push_frame(); let s_matrix = matrix_create (params_n a) params_nbar in let m_matrix = matrix_create params_nbar params_nbar in matrix_from_lbytes s_bytes s_matrix; matrix_mul_s bp_matrix s_matrix m_matrix; matrix_sub c_matrix m_matrix; frodo_key_decode (params_logq a) (params_extracted_bits a) params_nbar m_matrix mu_decode; clear_matrix s_matrix; clear_matrix m_matrix; pop_frame()
val frodo_mu_decode: a:FP.frodo_alg -> s_bytes:lbytes (secretmatrixbytes_len a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> mu_decode:lbytes (bytes_mu a) -> Stack unit (requires fun h -> live h s_bytes /\ live h bp_matrix /\ live h c_matrix /\ live h mu_decode /\ disjoint mu_decode s_bytes /\ as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc mu_decode) h0 h1 /\ as_seq h1 mu_decode == S.frodo_mu_decode a (as_seq h0 s_bytes) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let frodo_mu_decode a s_bytes bp_matrix c_matrix mu_decode =
true
null
false
push_frame (); let s_matrix = matrix_create (params_n a) params_nbar in let m_matrix = matrix_create params_nbar params_nbar in matrix_from_lbytes s_bytes s_matrix; matrix_mul_s bp_matrix s_matrix m_matrix; matrix_sub c_matrix m_matrix; frodo_key_decode (params_logq a) (params_extracted_bits a) params_nbar m_matrix mu_decode; clear_matrix s_matrix; clear_matrix m_matrix; pop_frame ()
{ "checked_file": "Hacl.Impl.Frodo.KEM.Decaps.fst.checked", "dependencies": [ "Spec.Matrix.fst.checked", "Spec.Frodo.Params.fst.checked", "Spec.Frodo.KEM.Decaps.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Sample.fst.checked", "Hacl.Impl.Frodo.Params.fst.checked", "Hacl.Impl.Frodo.Pack.fst.checked", "Hacl.Impl.Frodo.KEM.KeyGen.fst.checked", "Hacl.Impl.Frodo.KEM.Encaps.fst.checked", "Hacl.Impl.Frodo.KEM.fst.checked", "Hacl.Impl.Frodo.Encode.fst.checked", "Hacl.Frodo.Random.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.KEM.Decaps.fst" }
[]
[ "Spec.Frodo.Params.frodo_alg", "Hacl.Impl.Matrix.lbytes", "Hacl.Impl.Frodo.Params.secretmatrixbytes_len", "Hacl.Impl.Matrix.matrix_t", "Hacl.Impl.Frodo.Params.params_nbar", "Hacl.Impl.Frodo.Params.params_n", "Hacl.Impl.Frodo.Params.bytes_mu", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Impl.Frodo.KEM.clear_matrix", "Hacl.Impl.Frodo.Encode.frodo_key_decode", "Hacl.Impl.Frodo.Params.params_logq", "Hacl.Impl.Frodo.Params.params_extracted_bits", "Hacl.Impl.Matrix.matrix_sub", "Hacl.Impl.Matrix.matrix_mul_s", "Hacl.Impl.Matrix.matrix_from_lbytes", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U16", "Lib.IntTypes.SEC", "Lib.IntTypes.mul", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.Matrix.matrix_create", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Impl.Frodo.KEM.Decaps open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix open Hacl.Impl.Frodo.Params open Hacl.Impl.Frodo.KEM open Hacl.Impl.Frodo.KEM.Encaps open Hacl.Impl.Frodo.Encode open Hacl.Impl.Frodo.Pack open Hacl.Impl.Frodo.Sample open Hacl.Frodo.Random module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module FP = Spec.Frodo.Params module KG = Hacl.Impl.Frodo.KEM.KeyGen module S = Spec.Frodo.KEM.Decaps module M = Spec.Matrix #set-options "--z3rlimit 100 --fuel 0 --ifuel 0" inline_for_extraction noextract val get_bp_c_matrices: a:FP.frodo_alg -> ct:lbytes (crypto_ciphertextbytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h ct /\ live h bp_matrix /\ live h c_matrix /\ disjoint bp_matrix ct /\ disjoint c_matrix ct /\ disjoint bp_matrix c_matrix) (ensures fun h0 _ h1 -> modifies (loc bp_matrix |+| loc c_matrix) h0 h1 /\ (as_matrix h1 bp_matrix, as_matrix h1 c_matrix) == S.get_bp_c_matrices a (as_seq h0 ct)) let get_bp_c_matrices a ct bp_matrix c_matrix = let c1 = sub ct 0ul (ct1bytes_len a) in let c2 = sub ct (ct1bytes_len a) (ct2bytes_len a) in frodo_unpack params_nbar (params_n a) (params_logq a) c1 bp_matrix; frodo_unpack params_nbar params_nbar (params_logq a) c2 c_matrix inline_for_extraction noextract val frodo_mu_decode: a:FP.frodo_alg -> s_bytes:lbytes (secretmatrixbytes_len a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> mu_decode:lbytes (bytes_mu a) -> Stack unit (requires fun h -> live h s_bytes /\ live h bp_matrix /\ live h c_matrix /\ live h mu_decode /\ disjoint mu_decode s_bytes /\ as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc mu_decode) h0 h1 /\ as_seq h1 mu_decode == S.frodo_mu_decode a (as_seq h0 s_bytes) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
false
false
Hacl.Impl.Frodo.KEM.Decaps.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val frodo_mu_decode: a:FP.frodo_alg -> s_bytes:lbytes (secretmatrixbytes_len a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> mu_decode:lbytes (bytes_mu a) -> Stack unit (requires fun h -> live h s_bytes /\ live h bp_matrix /\ live h c_matrix /\ live h mu_decode /\ disjoint mu_decode s_bytes /\ as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc mu_decode) h0 h1 /\ as_seq h1 mu_decode == S.frodo_mu_decode a (as_seq h0 s_bytes) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
[]
Hacl.Impl.Frodo.KEM.Decaps.frodo_mu_decode
{ "file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Decaps.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_alg -> s_bytes: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.secretmatrixbytes_len a) -> bp_matrix: Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar (Hacl.Impl.Frodo.Params.params_n a) -> c_matrix: Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar Hacl.Impl.Frodo.Params.params_nbar -> mu_decode: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.bytes_mu a) -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 13, "end_line": 78, "start_col": 2, "start_line": 69 }
FStar.HyperStack.ST.Stack
val get_bpp_cp_matrices_: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> sk:lbytes (crypto_secretkeybytes a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> cp_matrix:matrix_t params_nbar params_nbar -> sp_matrix:matrix_t params_nbar (params_n a) -> ep_matrix:matrix_t params_nbar (params_n a) -> epp_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h mu_decode /\ live h sk /\ live h bpp_matrix /\ live h cp_matrix /\ live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\ loc_pairwise_disjoint [loc mu_decode; loc sk; loc bpp_matrix; loc cp_matrix; loc sp_matrix; loc ep_matrix; loc epp_matrix]) (ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\ (as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) == S.get_bpp_cp_matrices_ a gen_a (as_seq h0 mu_decode) (as_seq h0 sk) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix) (as_matrix h0 epp_matrix))
[ { "abbrev": true, "full_module": "Spec.Matrix", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Frodo.KEM.Decaps", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Impl.Frodo.KEM.KeyGen", "short_module": "KG" }, { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "FP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Frodo.Random", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Sample", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Pack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Encode", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM.Encaps", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Params", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix = FP.expand_crypto_secretkeybytes a; FP.expand_crypto_publickeybytes a; let pk = sub sk (crypto_bytes a) (crypto_publickeybytes a) in let seed_a = sub pk 0ul bytes_seed_a in let b = sub pk bytes_seed_a (crypto_publickeybytes a -! bytes_seed_a) in frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bpp_matrix; frodo_mul_add_sb_plus_e_plus_mu a mu_decode b sp_matrix epp_matrix cp_matrix; mod_pow2 (params_logq a) bpp_matrix; mod_pow2 (params_logq a) cp_matrix
val get_bpp_cp_matrices_: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> sk:lbytes (crypto_secretkeybytes a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> cp_matrix:matrix_t params_nbar params_nbar -> sp_matrix:matrix_t params_nbar (params_n a) -> ep_matrix:matrix_t params_nbar (params_n a) -> epp_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h mu_decode /\ live h sk /\ live h bpp_matrix /\ live h cp_matrix /\ live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\ loc_pairwise_disjoint [loc mu_decode; loc sk; loc bpp_matrix; loc cp_matrix; loc sp_matrix; loc ep_matrix; loc epp_matrix]) (ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\ (as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) == S.get_bpp_cp_matrices_ a gen_a (as_seq h0 mu_decode) (as_seq h0 sk) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix) (as_matrix h0 epp_matrix)) let get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix =
true
null
false
FP.expand_crypto_secretkeybytes a; FP.expand_crypto_publickeybytes a; let pk = sub sk (crypto_bytes a) (crypto_publickeybytes a) in let seed_a = sub pk 0ul bytes_seed_a in let b = sub pk bytes_seed_a (crypto_publickeybytes a -! bytes_seed_a) in frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bpp_matrix; frodo_mul_add_sb_plus_e_plus_mu a mu_decode b sp_matrix epp_matrix cp_matrix; mod_pow2 (params_logq a) bpp_matrix; mod_pow2 (params_logq a) cp_matrix
{ "checked_file": "Hacl.Impl.Frodo.KEM.Decaps.fst.checked", "dependencies": [ "Spec.Matrix.fst.checked", "Spec.Frodo.Params.fst.checked", "Spec.Frodo.KEM.Decaps.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Sample.fst.checked", "Hacl.Impl.Frodo.Params.fst.checked", "Hacl.Impl.Frodo.Pack.fst.checked", "Hacl.Impl.Frodo.KEM.KeyGen.fst.checked", "Hacl.Impl.Frodo.KEM.Encaps.fst.checked", "Hacl.Impl.Frodo.KEM.fst.checked", "Hacl.Impl.Frodo.Encode.fst.checked", "Hacl.Frodo.Random.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.KEM.Decaps.fst" }
[]
[ "Spec.Frodo.Params.frodo_alg", "Spec.Frodo.Params.frodo_gen_a", "Prims.b2t", "Hacl.Impl.Frodo.Params.is_supported", "Hacl.Impl.Matrix.lbytes", "Hacl.Impl.Frodo.Params.bytes_mu", "Hacl.Impl.Frodo.Params.crypto_secretkeybytes", "Hacl.Impl.Matrix.matrix_t", "Hacl.Impl.Frodo.Params.params_nbar", "Hacl.Impl.Frodo.Params.params_n", "Hacl.Impl.Matrix.mod_pow2", "Hacl.Impl.Frodo.Params.params_logq", "Prims.unit", "Hacl.Impl.Frodo.KEM.Encaps.frodo_mul_add_sb_plus_e_plus_mu", "Hacl.Impl.Frodo.KEM.Encaps.frodo_mul_add_sa_plus_e", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.IntTypes.sub", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.Frodo.Params.crypto_publickeybytes", "Hacl.Impl.Frodo.Params.bytes_seed_a", "Lib.Buffer.sub", "Lib.IntTypes.uint8", "Lib.IntTypes.op_Subtraction_Bang", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Frodo.Params.crypto_bytes", "Spec.Frodo.Params.expand_crypto_publickeybytes", "Spec.Frodo.Params.expand_crypto_secretkeybytes" ]
[]
module Hacl.Impl.Frodo.KEM.Decaps open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix open Hacl.Impl.Frodo.Params open Hacl.Impl.Frodo.KEM open Hacl.Impl.Frodo.KEM.Encaps open Hacl.Impl.Frodo.Encode open Hacl.Impl.Frodo.Pack open Hacl.Impl.Frodo.Sample open Hacl.Frodo.Random module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module FP = Spec.Frodo.Params module KG = Hacl.Impl.Frodo.KEM.KeyGen module S = Spec.Frodo.KEM.Decaps module M = Spec.Matrix #set-options "--z3rlimit 100 --fuel 0 --ifuel 0" inline_for_extraction noextract val get_bp_c_matrices: a:FP.frodo_alg -> ct:lbytes (crypto_ciphertextbytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h ct /\ live h bp_matrix /\ live h c_matrix /\ disjoint bp_matrix ct /\ disjoint c_matrix ct /\ disjoint bp_matrix c_matrix) (ensures fun h0 _ h1 -> modifies (loc bp_matrix |+| loc c_matrix) h0 h1 /\ (as_matrix h1 bp_matrix, as_matrix h1 c_matrix) == S.get_bp_c_matrices a (as_seq h0 ct)) let get_bp_c_matrices a ct bp_matrix c_matrix = let c1 = sub ct 0ul (ct1bytes_len a) in let c2 = sub ct (ct1bytes_len a) (ct2bytes_len a) in frodo_unpack params_nbar (params_n a) (params_logq a) c1 bp_matrix; frodo_unpack params_nbar params_nbar (params_logq a) c2 c_matrix inline_for_extraction noextract val frodo_mu_decode: a:FP.frodo_alg -> s_bytes:lbytes (secretmatrixbytes_len a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> mu_decode:lbytes (bytes_mu a) -> Stack unit (requires fun h -> live h s_bytes /\ live h bp_matrix /\ live h c_matrix /\ live h mu_decode /\ disjoint mu_decode s_bytes /\ as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc mu_decode) h0 h1 /\ as_seq h1 mu_decode == S.frodo_mu_decode a (as_seq h0 s_bytes) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let frodo_mu_decode a s_bytes bp_matrix c_matrix mu_decode = push_frame(); let s_matrix = matrix_create (params_n a) params_nbar in let m_matrix = matrix_create params_nbar params_nbar in matrix_from_lbytes s_bytes s_matrix; matrix_mul_s bp_matrix s_matrix m_matrix; matrix_sub c_matrix m_matrix; frodo_key_decode (params_logq a) (params_extracted_bits a) params_nbar m_matrix mu_decode; clear_matrix s_matrix; clear_matrix m_matrix; pop_frame() inline_for_extraction noextract val get_bpp_cp_matrices_: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> sk:lbytes (crypto_secretkeybytes a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> cp_matrix:matrix_t params_nbar params_nbar -> sp_matrix:matrix_t params_nbar (params_n a) -> ep_matrix:matrix_t params_nbar (params_n a) -> epp_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h mu_decode /\ live h sk /\ live h bpp_matrix /\ live h cp_matrix /\ live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\ loc_pairwise_disjoint [loc mu_decode; loc sk; loc bpp_matrix; loc cp_matrix; loc sp_matrix; loc ep_matrix; loc epp_matrix]) (ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\ (as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) == S.get_bpp_cp_matrices_ a gen_a (as_seq h0 mu_decode) (as_seq h0 sk) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix) (as_matrix h0 epp_matrix))
false
false
Hacl.Impl.Frodo.KEM.Decaps.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val get_bpp_cp_matrices_: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> sk:lbytes (crypto_secretkeybytes a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> cp_matrix:matrix_t params_nbar params_nbar -> sp_matrix:matrix_t params_nbar (params_n a) -> ep_matrix:matrix_t params_nbar (params_n a) -> epp_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h mu_decode /\ live h sk /\ live h bpp_matrix /\ live h cp_matrix /\ live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\ loc_pairwise_disjoint [loc mu_decode; loc sk; loc bpp_matrix; loc cp_matrix; loc sp_matrix; loc ep_matrix; loc epp_matrix]) (ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\ (as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) == S.get_bpp_cp_matrices_ a gen_a (as_seq h0 mu_decode) (as_seq h0 sk) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix) (as_matrix h0 epp_matrix))
[]
Hacl.Impl.Frodo.KEM.Decaps.get_bpp_cp_matrices_
{ "file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Decaps.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_alg -> gen_a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported gen_a} -> mu_decode: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.bytes_mu a) -> sk: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_secretkeybytes a) -> bpp_matrix: Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar (Hacl.Impl.Frodo.Params.params_n a) -> cp_matrix: Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar Hacl.Impl.Frodo.Params.params_nbar -> sp_matrix: Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar (Hacl.Impl.Frodo.Params.params_n a) -> ep_matrix: Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar (Hacl.Impl.Frodo.Params.params_n a) -> epp_matrix: Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar Hacl.Impl.Frodo.Params.params_nbar -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 36, "end_line": 114, "start_col": 2, "start_line": 105 }
FStar.HyperStack.ST.Stack
val get_bpp_cp_matrices: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> seed_se:lbytes (crypto_bytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> cp_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h seed_se /\ live h mu_decode /\ live h sk /\ live h bpp_matrix /\ live h cp_matrix /\ loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk; loc bpp_matrix; loc cp_matrix]) (ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\ (as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) == S.get_bpp_cp_matrices a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se) (as_seq h0 sk))
[ { "abbrev": true, "full_module": "Spec.Matrix", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Frodo.KEM.Decaps", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Impl.Frodo.KEM.KeyGen", "short_module": "KG" }, { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "FP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Frodo.Random", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Sample", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Pack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Encode", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM.Encaps", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Params", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix = push_frame (); let sp_matrix = matrix_create params_nbar (params_n a) in let ep_matrix = matrix_create params_nbar (params_n a) in let epp_matrix = matrix_create params_nbar params_nbar in get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix; get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix; clear_matrix3 a sp_matrix ep_matrix epp_matrix; pop_frame ()
val get_bpp_cp_matrices: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> seed_se:lbytes (crypto_bytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> cp_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h seed_se /\ live h mu_decode /\ live h sk /\ live h bpp_matrix /\ live h cp_matrix /\ loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk; loc bpp_matrix; loc cp_matrix]) (ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\ (as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) == S.get_bpp_cp_matrices a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se) (as_seq h0 sk)) let get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix =
true
null
false
push_frame (); let sp_matrix = matrix_create params_nbar (params_n a) in let ep_matrix = matrix_create params_nbar (params_n a) in let epp_matrix = matrix_create params_nbar params_nbar in get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix; get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix; clear_matrix3 a sp_matrix ep_matrix epp_matrix; pop_frame ()
{ "checked_file": "Hacl.Impl.Frodo.KEM.Decaps.fst.checked", "dependencies": [ "Spec.Matrix.fst.checked", "Spec.Frodo.Params.fst.checked", "Spec.Frodo.KEM.Decaps.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Sample.fst.checked", "Hacl.Impl.Frodo.Params.fst.checked", "Hacl.Impl.Frodo.Pack.fst.checked", "Hacl.Impl.Frodo.KEM.KeyGen.fst.checked", "Hacl.Impl.Frodo.KEM.Encaps.fst.checked", "Hacl.Impl.Frodo.KEM.fst.checked", "Hacl.Impl.Frodo.Encode.fst.checked", "Hacl.Frodo.Random.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.KEM.Decaps.fst" }
[]
[ "Spec.Frodo.Params.frodo_alg", "Spec.Frodo.Params.frodo_gen_a", "Prims.b2t", "Hacl.Impl.Frodo.Params.is_supported", "Hacl.Impl.Matrix.lbytes", "Hacl.Impl.Frodo.Params.bytes_mu", "Hacl.Impl.Frodo.Params.crypto_bytes", "Hacl.Impl.Frodo.Params.crypto_secretkeybytes", "Hacl.Impl.Matrix.matrix_t", "Hacl.Impl.Frodo.Params.params_nbar", "Hacl.Impl.Frodo.Params.params_n", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Impl.Frodo.KEM.Encaps.clear_matrix3", "Hacl.Impl.Frodo.KEM.Decaps.get_bpp_cp_matrices_", "Hacl.Impl.Frodo.KEM.Encaps.get_sp_ep_epp_matrices", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U16", "Lib.IntTypes.SEC", "Lib.IntTypes.mul", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.Matrix.matrix_create", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Impl.Frodo.KEM.Decaps open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix open Hacl.Impl.Frodo.Params open Hacl.Impl.Frodo.KEM open Hacl.Impl.Frodo.KEM.Encaps open Hacl.Impl.Frodo.Encode open Hacl.Impl.Frodo.Pack open Hacl.Impl.Frodo.Sample open Hacl.Frodo.Random module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module FP = Spec.Frodo.Params module KG = Hacl.Impl.Frodo.KEM.KeyGen module S = Spec.Frodo.KEM.Decaps module M = Spec.Matrix #set-options "--z3rlimit 100 --fuel 0 --ifuel 0" inline_for_extraction noextract val get_bp_c_matrices: a:FP.frodo_alg -> ct:lbytes (crypto_ciphertextbytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h ct /\ live h bp_matrix /\ live h c_matrix /\ disjoint bp_matrix ct /\ disjoint c_matrix ct /\ disjoint bp_matrix c_matrix) (ensures fun h0 _ h1 -> modifies (loc bp_matrix |+| loc c_matrix) h0 h1 /\ (as_matrix h1 bp_matrix, as_matrix h1 c_matrix) == S.get_bp_c_matrices a (as_seq h0 ct)) let get_bp_c_matrices a ct bp_matrix c_matrix = let c1 = sub ct 0ul (ct1bytes_len a) in let c2 = sub ct (ct1bytes_len a) (ct2bytes_len a) in frodo_unpack params_nbar (params_n a) (params_logq a) c1 bp_matrix; frodo_unpack params_nbar params_nbar (params_logq a) c2 c_matrix inline_for_extraction noextract val frodo_mu_decode: a:FP.frodo_alg -> s_bytes:lbytes (secretmatrixbytes_len a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> mu_decode:lbytes (bytes_mu a) -> Stack unit (requires fun h -> live h s_bytes /\ live h bp_matrix /\ live h c_matrix /\ live h mu_decode /\ disjoint mu_decode s_bytes /\ as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc mu_decode) h0 h1 /\ as_seq h1 mu_decode == S.frodo_mu_decode a (as_seq h0 s_bytes) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let frodo_mu_decode a s_bytes bp_matrix c_matrix mu_decode = push_frame(); let s_matrix = matrix_create (params_n a) params_nbar in let m_matrix = matrix_create params_nbar params_nbar in matrix_from_lbytes s_bytes s_matrix; matrix_mul_s bp_matrix s_matrix m_matrix; matrix_sub c_matrix m_matrix; frodo_key_decode (params_logq a) (params_extracted_bits a) params_nbar m_matrix mu_decode; clear_matrix s_matrix; clear_matrix m_matrix; pop_frame() inline_for_extraction noextract val get_bpp_cp_matrices_: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> sk:lbytes (crypto_secretkeybytes a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> cp_matrix:matrix_t params_nbar params_nbar -> sp_matrix:matrix_t params_nbar (params_n a) -> ep_matrix:matrix_t params_nbar (params_n a) -> epp_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h mu_decode /\ live h sk /\ live h bpp_matrix /\ live h cp_matrix /\ live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\ loc_pairwise_disjoint [loc mu_decode; loc sk; loc bpp_matrix; loc cp_matrix; loc sp_matrix; loc ep_matrix; loc epp_matrix]) (ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\ (as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) == S.get_bpp_cp_matrices_ a gen_a (as_seq h0 mu_decode) (as_seq h0 sk) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix) (as_matrix h0 epp_matrix)) let get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix = FP.expand_crypto_secretkeybytes a; FP.expand_crypto_publickeybytes a; let pk = sub sk (crypto_bytes a) (crypto_publickeybytes a) in let seed_a = sub pk 0ul bytes_seed_a in let b = sub pk bytes_seed_a (crypto_publickeybytes a -! bytes_seed_a) in frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bpp_matrix; frodo_mul_add_sb_plus_e_plus_mu a mu_decode b sp_matrix epp_matrix cp_matrix; mod_pow2 (params_logq a) bpp_matrix; mod_pow2 (params_logq a) cp_matrix #push-options "--z3rlimit 150" inline_for_extraction noextract val get_bpp_cp_matrices: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> seed_se:lbytes (crypto_bytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> cp_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h seed_se /\ live h mu_decode /\ live h sk /\ live h bpp_matrix /\ live h cp_matrix /\ loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk; loc bpp_matrix; loc cp_matrix]) (ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\ (as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) == S.get_bpp_cp_matrices a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se) (as_seq h0 sk))
false
false
Hacl.Impl.Frodo.KEM.Decaps.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val get_bpp_cp_matrices: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> seed_se:lbytes (crypto_bytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> cp_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h seed_se /\ live h mu_decode /\ live h sk /\ live h bpp_matrix /\ live h cp_matrix /\ loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk; loc bpp_matrix; loc cp_matrix]) (ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\ (as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) == S.get_bpp_cp_matrices a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se) (as_seq h0 sk))
[]
Hacl.Impl.Frodo.KEM.Decaps.get_bpp_cp_matrices
{ "file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Decaps.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_alg -> gen_a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported gen_a} -> mu_decode: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.bytes_mu a) -> seed_se: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_bytes a) -> sk: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_secretkeybytes a) -> bpp_matrix: Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar (Hacl.Impl.Frodo.Params.params_n a) -> cp_matrix: Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar Hacl.Impl.Frodo.Params.params_nbar -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 14, "end_line": 144, "start_col": 2, "start_line": 137 }
Prims.Tot
val ffdhe_len (a: S.ffdhe_alg) : DH.size_pos
[ { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Impl.FFDHE", "short_module": "DH" }, { "abbrev": true, "full_module": "Spec.FFDHE", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ffdhe_len (a:S.ffdhe_alg) : DH.size_pos = DH.ffdhe_len a
val ffdhe_len (a: S.ffdhe_alg) : DH.size_pos let ffdhe_len (a: S.ffdhe_alg) : DH.size_pos =
false
null
false
DH.ffdhe_len a
{ "checked_file": "Hacl.FFDHE.fst.checked", "dependencies": [ "Spec.FFDHE.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Impl.FFDHE.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.FFDHE.fst" }
[ "total" ]
[ "Spec.FFDHE.ffdhe_alg", "Hacl.Impl.FFDHE.ffdhe_len", "Hacl.Impl.FFDHE.size_pos" ]
[]
module Hacl.FFDHE open Lib.IntTypes module S = Spec.FFDHE module DH = Hacl.Impl.FFDHE module BD = Hacl.Bignum.Definitions module BE = Hacl.Bignum.Exponentiation #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let t_limbs = U64 inline_for_extraction noextract let ke (a:S.ffdhe_alg) = BE.mk_runtime_exp #t_limbs (BD.blocks (DH.ffdhe_len a) (size (numbytes t_limbs))) private [@CInline] let ffdhe_precomp_p (a:S.ffdhe_alg) : DH.ffdhe_precomp_p_st t_limbs a (DH.ffdhe_len a) (ke a) = DH.ffdhe_precomp_p a (DH.ffdhe_len a) (ke a) private [@CInline] let ffdhe_check_pk (a:S.ffdhe_alg) : DH.ffdhe_check_pk_st t_limbs a (DH.ffdhe_len a) = DH.ffdhe_check_pk #t_limbs a (DH.ffdhe_len a) private [@CInline] let ffdhe_compute_exp (a:S.ffdhe_alg) : DH.ffdhe_compute_exp_st t_limbs a (DH.ffdhe_len a) (ke a) = DH.ffdhe_compute_exp a (DH.ffdhe_len a) (ke a)
false
true
Hacl.FFDHE.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ffdhe_len (a: S.ffdhe_alg) : DH.size_pos
[]
Hacl.FFDHE.ffdhe_len
{ "file_name": "code/ffdhe/Hacl.FFDHE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.FFDHE.ffdhe_alg -> Hacl.Impl.FFDHE.size_pos
{ "end_col": 60, "end_line": 35, "start_col": 46, "start_line": 35 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Impl.FFDHE", "short_module": "DH" }, { "abbrev": true, "full_module": "Spec.FFDHE", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let t_limbs = U64
let t_limbs =
false
null
false
U64
{ "checked_file": "Hacl.FFDHE.fst.checked", "dependencies": [ "Spec.FFDHE.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Impl.FFDHE.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.FFDHE.fst" }
[ "total" ]
[ "Lib.IntTypes.U64" ]
[]
module Hacl.FFDHE open Lib.IntTypes module S = Spec.FFDHE module DH = Hacl.Impl.FFDHE module BD = Hacl.Bignum.Definitions module BE = Hacl.Bignum.Exponentiation #set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
false
true
Hacl.FFDHE.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val t_limbs : Lib.IntTypes.inttype
[]
Hacl.FFDHE.t_limbs
{ "file_name": "code/ffdhe/Hacl.FFDHE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Lib.IntTypes.inttype
{ "end_col": 17, "end_line": 13, "start_col": 14, "start_line": 13 }
Prims.Tot
val ffdhe_precomp_p (a: S.ffdhe_alg) : DH.ffdhe_precomp_p_st t_limbs a (DH.ffdhe_len a) (ke a)
[ { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Impl.FFDHE", "short_module": "DH" }, { "abbrev": true, "full_module": "Spec.FFDHE", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ffdhe_precomp_p (a:S.ffdhe_alg) : DH.ffdhe_precomp_p_st t_limbs a (DH.ffdhe_len a) (ke a) = DH.ffdhe_precomp_p a (DH.ffdhe_len a) (ke a)
val ffdhe_precomp_p (a: S.ffdhe_alg) : DH.ffdhe_precomp_p_st t_limbs a (DH.ffdhe_len a) (ke a) let ffdhe_precomp_p (a: S.ffdhe_alg) : DH.ffdhe_precomp_p_st t_limbs a (DH.ffdhe_len a) (ke a) =
false
null
false
DH.ffdhe_precomp_p a (DH.ffdhe_len a) (ke a)
{ "checked_file": "Hacl.FFDHE.fst.checked", "dependencies": [ "Spec.FFDHE.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Impl.FFDHE.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.FFDHE.fst" }
[ "total" ]
[ "Spec.FFDHE.ffdhe_alg", "Hacl.Impl.FFDHE.ffdhe_precomp_p", "Hacl.FFDHE.t_limbs", "Hacl.Impl.FFDHE.ffdhe_len", "Hacl.FFDHE.ke", "Hacl.Impl.FFDHE.ffdhe_precomp_p_st" ]
[]
module Hacl.FFDHE open Lib.IntTypes module S = Spec.FFDHE module DH = Hacl.Impl.FFDHE module BD = Hacl.Bignum.Definitions module BE = Hacl.Bignum.Exponentiation #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let t_limbs = U64 inline_for_extraction noextract let ke (a:S.ffdhe_alg) = BE.mk_runtime_exp #t_limbs (BD.blocks (DH.ffdhe_len a) (size (numbytes t_limbs))) private [@CInline]
false
false
Hacl.FFDHE.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ffdhe_precomp_p (a: S.ffdhe_alg) : DH.ffdhe_precomp_p_st t_limbs a (DH.ffdhe_len a) (ke a)
[]
Hacl.FFDHE.ffdhe_precomp_p
{ "file_name": "code/ffdhe/Hacl.FFDHE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.FFDHE.ffdhe_alg -> Hacl.Impl.FFDHE.ffdhe_precomp_p_st Hacl.FFDHE.t_limbs a (Hacl.Impl.FFDHE.ffdhe_len a) (Hacl.FFDHE.ke a)
{ "end_col": 46, "end_line": 22, "start_col": 2, "start_line": 22 }
Prims.Tot
val ffdhe_compute_exp (a: S.ffdhe_alg) : DH.ffdhe_compute_exp_st t_limbs a (DH.ffdhe_len a) (ke a)
[ { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Impl.FFDHE", "short_module": "DH" }, { "abbrev": true, "full_module": "Spec.FFDHE", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ffdhe_compute_exp (a:S.ffdhe_alg) : DH.ffdhe_compute_exp_st t_limbs a (DH.ffdhe_len a) (ke a) = DH.ffdhe_compute_exp a (DH.ffdhe_len a) (ke a)
val ffdhe_compute_exp (a: S.ffdhe_alg) : DH.ffdhe_compute_exp_st t_limbs a (DH.ffdhe_len a) (ke a) let ffdhe_compute_exp (a: S.ffdhe_alg) : DH.ffdhe_compute_exp_st t_limbs a (DH.ffdhe_len a) (ke a) =
false
null
false
DH.ffdhe_compute_exp a (DH.ffdhe_len a) (ke a)
{ "checked_file": "Hacl.FFDHE.fst.checked", "dependencies": [ "Spec.FFDHE.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Impl.FFDHE.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.FFDHE.fst" }
[ "total" ]
[ "Spec.FFDHE.ffdhe_alg", "Hacl.Impl.FFDHE.ffdhe_compute_exp", "Hacl.FFDHE.t_limbs", "Hacl.Impl.FFDHE.ffdhe_len", "Hacl.FFDHE.ke", "Hacl.Impl.FFDHE.ffdhe_compute_exp_st" ]
[]
module Hacl.FFDHE open Lib.IntTypes module S = Spec.FFDHE module DH = Hacl.Impl.FFDHE module BD = Hacl.Bignum.Definitions module BE = Hacl.Bignum.Exponentiation #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let t_limbs = U64 inline_for_extraction noextract let ke (a:S.ffdhe_alg) = BE.mk_runtime_exp #t_limbs (BD.blocks (DH.ffdhe_len a) (size (numbytes t_limbs))) private [@CInline] let ffdhe_precomp_p (a:S.ffdhe_alg) : DH.ffdhe_precomp_p_st t_limbs a (DH.ffdhe_len a) (ke a) = DH.ffdhe_precomp_p a (DH.ffdhe_len a) (ke a) private [@CInline] let ffdhe_check_pk (a:S.ffdhe_alg) : DH.ffdhe_check_pk_st t_limbs a (DH.ffdhe_len a) = DH.ffdhe_check_pk #t_limbs a (DH.ffdhe_len a) private [@CInline]
false
false
Hacl.FFDHE.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ffdhe_compute_exp (a: S.ffdhe_alg) : DH.ffdhe_compute_exp_st t_limbs a (DH.ffdhe_len a) (ke a)
[]
Hacl.FFDHE.ffdhe_compute_exp
{ "file_name": "code/ffdhe/Hacl.FFDHE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.FFDHE.ffdhe_alg -> Hacl.Impl.FFDHE.ffdhe_compute_exp_st Hacl.FFDHE.t_limbs a (Hacl.Impl.FFDHE.ffdhe_len a) (Hacl.FFDHE.ke a)
{ "end_col": 48, "end_line": 32, "start_col": 2, "start_line": 32 }
Prims.Tot
val ffdhe_check_pk (a: S.ffdhe_alg) : DH.ffdhe_check_pk_st t_limbs a (DH.ffdhe_len a)
[ { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Impl.FFDHE", "short_module": "DH" }, { "abbrev": true, "full_module": "Spec.FFDHE", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ffdhe_check_pk (a:S.ffdhe_alg) : DH.ffdhe_check_pk_st t_limbs a (DH.ffdhe_len a) = DH.ffdhe_check_pk #t_limbs a (DH.ffdhe_len a)
val ffdhe_check_pk (a: S.ffdhe_alg) : DH.ffdhe_check_pk_st t_limbs a (DH.ffdhe_len a) let ffdhe_check_pk (a: S.ffdhe_alg) : DH.ffdhe_check_pk_st t_limbs a (DH.ffdhe_len a) =
false
null
false
DH.ffdhe_check_pk #t_limbs a (DH.ffdhe_len a)
{ "checked_file": "Hacl.FFDHE.fst.checked", "dependencies": [ "Spec.FFDHE.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Impl.FFDHE.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.FFDHE.fst" }
[ "total" ]
[ "Spec.FFDHE.ffdhe_alg", "Hacl.Impl.FFDHE.ffdhe_check_pk", "Hacl.FFDHE.t_limbs", "Hacl.Impl.FFDHE.ffdhe_len", "Hacl.Impl.FFDHE.ffdhe_check_pk_st" ]
[]
module Hacl.FFDHE open Lib.IntTypes module S = Spec.FFDHE module DH = Hacl.Impl.FFDHE module BD = Hacl.Bignum.Definitions module BE = Hacl.Bignum.Exponentiation #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let t_limbs = U64 inline_for_extraction noextract let ke (a:S.ffdhe_alg) = BE.mk_runtime_exp #t_limbs (BD.blocks (DH.ffdhe_len a) (size (numbytes t_limbs))) private [@CInline] let ffdhe_precomp_p (a:S.ffdhe_alg) : DH.ffdhe_precomp_p_st t_limbs a (DH.ffdhe_len a) (ke a) = DH.ffdhe_precomp_p a (DH.ffdhe_len a) (ke a) private [@CInline]
false
false
Hacl.FFDHE.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ffdhe_check_pk (a: S.ffdhe_alg) : DH.ffdhe_check_pk_st t_limbs a (DH.ffdhe_len a)
[]
Hacl.FFDHE.ffdhe_check_pk
{ "file_name": "code/ffdhe/Hacl.FFDHE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.FFDHE.ffdhe_alg -> Hacl.Impl.FFDHE.ffdhe_check_pk_st Hacl.FFDHE.t_limbs a (Hacl.Impl.FFDHE.ffdhe_len a)
{ "end_col": 47, "end_line": 27, "start_col": 2, "start_line": 27 }
Prims.Tot
val new_ffdhe_precomp_p: a:S.ffdhe_alg -> DH.new_ffdhe_precomp_p_st t_limbs a (ffdhe_len a) (ke a)
[ { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Impl.FFDHE", "short_module": "DH" }, { "abbrev": true, "full_module": "Spec.FFDHE", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let new_ffdhe_precomp_p a = DH.new_ffdhe_precomp_p a (DH.ffdhe_len a) (ke a) (ffdhe_precomp_p a)
val new_ffdhe_precomp_p: a:S.ffdhe_alg -> DH.new_ffdhe_precomp_p_st t_limbs a (ffdhe_len a) (ke a) let new_ffdhe_precomp_p a =
false
null
false
DH.new_ffdhe_precomp_p a (DH.ffdhe_len a) (ke a) (ffdhe_precomp_p a)
{ "checked_file": "Hacl.FFDHE.fst.checked", "dependencies": [ "Spec.FFDHE.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Impl.FFDHE.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.FFDHE.fst" }
[ "total" ]
[ "Spec.FFDHE.ffdhe_alg", "Hacl.Impl.FFDHE.new_ffdhe_precomp_p", "Hacl.FFDHE.t_limbs", "Hacl.Impl.FFDHE.ffdhe_len", "Hacl.FFDHE.ke", "Hacl.FFDHE.ffdhe_precomp_p", "Hacl.Impl.FFDHE.new_ffdhe_precomp_p_st", "Hacl.FFDHE.ffdhe_len" ]
[]
module Hacl.FFDHE open Lib.IntTypes module S = Spec.FFDHE module DH = Hacl.Impl.FFDHE module BD = Hacl.Bignum.Definitions module BE = Hacl.Bignum.Exponentiation #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let t_limbs = U64 inline_for_extraction noextract let ke (a:S.ffdhe_alg) = BE.mk_runtime_exp #t_limbs (BD.blocks (DH.ffdhe_len a) (size (numbytes t_limbs))) private [@CInline] let ffdhe_precomp_p (a:S.ffdhe_alg) : DH.ffdhe_precomp_p_st t_limbs a (DH.ffdhe_len a) (ke a) = DH.ffdhe_precomp_p a (DH.ffdhe_len a) (ke a) private [@CInline] let ffdhe_check_pk (a:S.ffdhe_alg) : DH.ffdhe_check_pk_st t_limbs a (DH.ffdhe_len a) = DH.ffdhe_check_pk #t_limbs a (DH.ffdhe_len a) private [@CInline] let ffdhe_compute_exp (a:S.ffdhe_alg) : DH.ffdhe_compute_exp_st t_limbs a (DH.ffdhe_len a) (ke a) = DH.ffdhe_compute_exp a (DH.ffdhe_len a) (ke a) let ffdhe_len (a:S.ffdhe_alg) : DH.size_pos = DH.ffdhe_len a val new_ffdhe_precomp_p: a:S.ffdhe_alg -> DH.new_ffdhe_precomp_p_st t_limbs a (ffdhe_len a) (ke a)
false
false
Hacl.FFDHE.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val new_ffdhe_precomp_p: a:S.ffdhe_alg -> DH.new_ffdhe_precomp_p_st t_limbs a (ffdhe_len a) (ke a)
[]
Hacl.FFDHE.new_ffdhe_precomp_p
{ "file_name": "code/ffdhe/Hacl.FFDHE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.FFDHE.ffdhe_alg -> Hacl.Impl.FFDHE.new_ffdhe_precomp_p_st Hacl.FFDHE.t_limbs a (Hacl.FFDHE.ffdhe_len a) (Hacl.FFDHE.ke a)
{ "end_col": 70, "end_line": 41, "start_col": 2, "start_line": 41 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Impl.FFDHE", "short_module": "DH" }, { "abbrev": true, "full_module": "Spec.FFDHE", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ke (a:S.ffdhe_alg) = BE.mk_runtime_exp #t_limbs (BD.blocks (DH.ffdhe_len a) (size (numbytes t_limbs)))
let ke (a: S.ffdhe_alg) =
false
null
false
BE.mk_runtime_exp #t_limbs (BD.blocks (DH.ffdhe_len a) (size (numbytes t_limbs)))
{ "checked_file": "Hacl.FFDHE.fst.checked", "dependencies": [ "Spec.FFDHE.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Impl.FFDHE.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.FFDHE.fst" }
[ "total" ]
[ "Spec.FFDHE.ffdhe_alg", "Hacl.Bignum.Exponentiation.mk_runtime_exp", "Hacl.FFDHE.t_limbs", "Hacl.Bignum.Definitions.blocks", "Hacl.Impl.FFDHE.ffdhe_len", "Lib.IntTypes.size", "Lib.IntTypes.numbytes", "Hacl.Bignum.Exponentiation.exp" ]
[]
module Hacl.FFDHE open Lib.IntTypes module S = Spec.FFDHE module DH = Hacl.Impl.FFDHE module BD = Hacl.Bignum.Definitions module BE = Hacl.Bignum.Exponentiation #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let t_limbs = U64 inline_for_extraction noextract
false
true
Hacl.FFDHE.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ke : a: Spec.FFDHE.ffdhe_alg -> Hacl.Bignum.Exponentiation.exp Hacl.FFDHE.t_limbs
[]
Hacl.FFDHE.ke
{ "file_name": "code/ffdhe/Hacl.FFDHE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.FFDHE.ffdhe_alg -> Hacl.Bignum.Exponentiation.exp Hacl.FFDHE.t_limbs
{ "end_col": 83, "end_line": 17, "start_col": 2, "start_line": 17 }
Prims.Tot
val ffdhe_secret_to_public: a:S.ffdhe_alg -> DH.ffdhe_secret_to_public_st t_limbs a (DH.ffdhe_len a) (ke a)
[ { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Impl.FFDHE", "short_module": "DH" }, { "abbrev": true, "full_module": "Spec.FFDHE", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ffdhe_secret_to_public a sk pk = let len = DH.ffdhe_len a in DH.ffdhe_secret_to_public a len (ke a) (ffdhe_secret_to_public_precomp a) (ffdhe_precomp_p a) sk pk
val ffdhe_secret_to_public: a:S.ffdhe_alg -> DH.ffdhe_secret_to_public_st t_limbs a (DH.ffdhe_len a) (ke a) let ffdhe_secret_to_public a sk pk =
false
null
false
let len = DH.ffdhe_len a in DH.ffdhe_secret_to_public a len (ke a) (ffdhe_secret_to_public_precomp a) (ffdhe_precomp_p a) sk pk
{ "checked_file": "Hacl.FFDHE.fst.checked", "dependencies": [ "Spec.FFDHE.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Impl.FFDHE.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.FFDHE.fst" }
[ "total" ]
[ "Spec.FFDHE.ffdhe_alg", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.Impl.FFDHE.ffdhe_len", "Hacl.Impl.FFDHE.ffdhe_secret_to_public", "Hacl.FFDHE.t_limbs", "Hacl.FFDHE.ke", "Hacl.FFDHE.ffdhe_secret_to_public_precomp", "Hacl.FFDHE.ffdhe_precomp_p", "Prims.unit", "Hacl.Impl.FFDHE.size_pos", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Lib.IntTypes.U32", "Prims.l_and", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "Lib.IntTypes.v", "Lib.IntTypes.PUB", "Spec.FFDHE.ffdhe_len" ]
[]
module Hacl.FFDHE open Lib.IntTypes module S = Spec.FFDHE module DH = Hacl.Impl.FFDHE module BD = Hacl.Bignum.Definitions module BE = Hacl.Bignum.Exponentiation #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let t_limbs = U64 inline_for_extraction noextract let ke (a:S.ffdhe_alg) = BE.mk_runtime_exp #t_limbs (BD.blocks (DH.ffdhe_len a) (size (numbytes t_limbs))) private [@CInline] let ffdhe_precomp_p (a:S.ffdhe_alg) : DH.ffdhe_precomp_p_st t_limbs a (DH.ffdhe_len a) (ke a) = DH.ffdhe_precomp_p a (DH.ffdhe_len a) (ke a) private [@CInline] let ffdhe_check_pk (a:S.ffdhe_alg) : DH.ffdhe_check_pk_st t_limbs a (DH.ffdhe_len a) = DH.ffdhe_check_pk #t_limbs a (DH.ffdhe_len a) private [@CInline] let ffdhe_compute_exp (a:S.ffdhe_alg) : DH.ffdhe_compute_exp_st t_limbs a (DH.ffdhe_len a) (ke a) = DH.ffdhe_compute_exp a (DH.ffdhe_len a) (ke a) let ffdhe_len (a:S.ffdhe_alg) : DH.size_pos = DH.ffdhe_len a val new_ffdhe_precomp_p: a:S.ffdhe_alg -> DH.new_ffdhe_precomp_p_st t_limbs a (ffdhe_len a) (ke a) let new_ffdhe_precomp_p a = DH.new_ffdhe_precomp_p a (DH.ffdhe_len a) (ke a) (ffdhe_precomp_p a) val ffdhe_secret_to_public_precomp: a:S.ffdhe_alg -> DH.ffdhe_secret_to_public_precomp_st t_limbs a (DH.ffdhe_len a) (ke a) let ffdhe_secret_to_public_precomp a p_r2_n sk pk = let len = DH.ffdhe_len a in DH.ffdhe_secret_to_public_precomp a len (ke a) (ffdhe_compute_exp a) p_r2_n sk pk val ffdhe_secret_to_public: a:S.ffdhe_alg ->
false
false
Hacl.FFDHE.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ffdhe_secret_to_public: a:S.ffdhe_alg -> DH.ffdhe_secret_to_public_st t_limbs a (DH.ffdhe_len a) (ke a)
[]
Hacl.FFDHE.ffdhe_secret_to_public
{ "file_name": "code/ffdhe/Hacl.FFDHE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.FFDHE.ffdhe_alg -> Hacl.Impl.FFDHE.ffdhe_secret_to_public_st Hacl.FFDHE.t_limbs a (Hacl.Impl.FFDHE.ffdhe_len a) (Hacl.FFDHE.ke a)
{ "end_col": 101, "end_line": 55, "start_col": 36, "start_line": 53 }
Prims.Tot
val ffdhe_shared_secret: a:S.ffdhe_alg -> DH.ffdhe_shared_secret_st t_limbs a (DH.ffdhe_len a) (ke a)
[ { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Impl.FFDHE", "short_module": "DH" }, { "abbrev": true, "full_module": "Spec.FFDHE", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ffdhe_shared_secret a sk pk ss = let len = DH.ffdhe_len a in DH.ffdhe_shared_secret a len (ke a) (ffdhe_shared_secret_precomp a) (ffdhe_precomp_p a) sk pk ss
val ffdhe_shared_secret: a:S.ffdhe_alg -> DH.ffdhe_shared_secret_st t_limbs a (DH.ffdhe_len a) (ke a) let ffdhe_shared_secret a sk pk ss =
false
null
false
let len = DH.ffdhe_len a in DH.ffdhe_shared_secret a len (ke a) (ffdhe_shared_secret_precomp a) (ffdhe_precomp_p a) sk pk ss
{ "checked_file": "Hacl.FFDHE.fst.checked", "dependencies": [ "Spec.FFDHE.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Impl.FFDHE.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.FFDHE.fst" }
[ "total" ]
[ "Spec.FFDHE.ffdhe_alg", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.Impl.FFDHE.ffdhe_len", "Hacl.Impl.FFDHE.ffdhe_shared_secret", "Hacl.FFDHE.t_limbs", "Hacl.FFDHE.ke", "Hacl.FFDHE.ffdhe_shared_secret_precomp", "Hacl.FFDHE.ffdhe_precomp_p", "Hacl.Bignum.Definitions.limb", "Hacl.Impl.FFDHE.size_pos", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Lib.IntTypes.U32", "Prims.l_and", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "Lib.IntTypes.v", "Lib.IntTypes.PUB", "Spec.FFDHE.ffdhe_len" ]
[]
module Hacl.FFDHE open Lib.IntTypes module S = Spec.FFDHE module DH = Hacl.Impl.FFDHE module BD = Hacl.Bignum.Definitions module BE = Hacl.Bignum.Exponentiation #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let t_limbs = U64 inline_for_extraction noextract let ke (a:S.ffdhe_alg) = BE.mk_runtime_exp #t_limbs (BD.blocks (DH.ffdhe_len a) (size (numbytes t_limbs))) private [@CInline] let ffdhe_precomp_p (a:S.ffdhe_alg) : DH.ffdhe_precomp_p_st t_limbs a (DH.ffdhe_len a) (ke a) = DH.ffdhe_precomp_p a (DH.ffdhe_len a) (ke a) private [@CInline] let ffdhe_check_pk (a:S.ffdhe_alg) : DH.ffdhe_check_pk_st t_limbs a (DH.ffdhe_len a) = DH.ffdhe_check_pk #t_limbs a (DH.ffdhe_len a) private [@CInline] let ffdhe_compute_exp (a:S.ffdhe_alg) : DH.ffdhe_compute_exp_st t_limbs a (DH.ffdhe_len a) (ke a) = DH.ffdhe_compute_exp a (DH.ffdhe_len a) (ke a) let ffdhe_len (a:S.ffdhe_alg) : DH.size_pos = DH.ffdhe_len a val new_ffdhe_precomp_p: a:S.ffdhe_alg -> DH.new_ffdhe_precomp_p_st t_limbs a (ffdhe_len a) (ke a) let new_ffdhe_precomp_p a = DH.new_ffdhe_precomp_p a (DH.ffdhe_len a) (ke a) (ffdhe_precomp_p a) val ffdhe_secret_to_public_precomp: a:S.ffdhe_alg -> DH.ffdhe_secret_to_public_precomp_st t_limbs a (DH.ffdhe_len a) (ke a) let ffdhe_secret_to_public_precomp a p_r2_n sk pk = let len = DH.ffdhe_len a in DH.ffdhe_secret_to_public_precomp a len (ke a) (ffdhe_compute_exp a) p_r2_n sk pk val ffdhe_secret_to_public: a:S.ffdhe_alg -> DH.ffdhe_secret_to_public_st t_limbs a (DH.ffdhe_len a) (ke a) let ffdhe_secret_to_public a sk pk = let len = DH.ffdhe_len a in DH.ffdhe_secret_to_public a len (ke a) (ffdhe_secret_to_public_precomp a) (ffdhe_precomp_p a) sk pk val ffdhe_shared_secret_precomp: a:S.ffdhe_alg -> DH.ffdhe_shared_secret_precomp_st t_limbs a (DH.ffdhe_len a) (ke a) let ffdhe_shared_secret_precomp a p_r2_n sk pk ss = let len = DH.ffdhe_len a in DH.ffdhe_shared_secret_precomp a len (ke a) (ffdhe_check_pk a) (ffdhe_compute_exp a) p_r2_n sk pk ss val ffdhe_shared_secret: a:S.ffdhe_alg ->
false
false
Hacl.FFDHE.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ffdhe_shared_secret: a:S.ffdhe_alg -> DH.ffdhe_shared_secret_st t_limbs a (DH.ffdhe_len a) (ke a)
[]
Hacl.FFDHE.ffdhe_shared_secret
{ "file_name": "code/ffdhe/Hacl.FFDHE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.FFDHE.ffdhe_alg -> Hacl.Impl.FFDHE.ffdhe_shared_secret_st Hacl.FFDHE.t_limbs a (Hacl.Impl.FFDHE.ffdhe_len a) (Hacl.FFDHE.ke a)
{ "end_col": 98, "end_line": 69, "start_col": 36, "start_line": 67 }
Prims.Tot
val ffdhe_secret_to_public_precomp: a:S.ffdhe_alg -> DH.ffdhe_secret_to_public_precomp_st t_limbs a (DH.ffdhe_len a) (ke a)
[ { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Impl.FFDHE", "short_module": "DH" }, { "abbrev": true, "full_module": "Spec.FFDHE", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ffdhe_secret_to_public_precomp a p_r2_n sk pk = let len = DH.ffdhe_len a in DH.ffdhe_secret_to_public_precomp a len (ke a) (ffdhe_compute_exp a) p_r2_n sk pk
val ffdhe_secret_to_public_precomp: a:S.ffdhe_alg -> DH.ffdhe_secret_to_public_precomp_st t_limbs a (DH.ffdhe_len a) (ke a) let ffdhe_secret_to_public_precomp a p_r2_n sk pk =
false
null
false
let len = DH.ffdhe_len a in DH.ffdhe_secret_to_public_precomp a len (ke a) (ffdhe_compute_exp a) p_r2_n sk pk
{ "checked_file": "Hacl.FFDHE.fst.checked", "dependencies": [ "Spec.FFDHE.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Impl.FFDHE.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.FFDHE.fst" }
[ "total" ]
[ "Spec.FFDHE.ffdhe_alg", "Hacl.Bignum.Definitions.lbignum", "Hacl.FFDHE.t_limbs", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.blocks", "Hacl.Impl.FFDHE.ffdhe_len", "Lib.IntTypes.size", "Lib.IntTypes.numbytes", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.Impl.FFDHE.ffdhe_secret_to_public_precomp", "Hacl.FFDHE.ke", "Hacl.FFDHE.ffdhe_compute_exp", "Prims.unit", "Hacl.Impl.FFDHE.size_pos", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.l_and", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "Lib.IntTypes.v", "Spec.FFDHE.ffdhe_len" ]
[]
module Hacl.FFDHE open Lib.IntTypes module S = Spec.FFDHE module DH = Hacl.Impl.FFDHE module BD = Hacl.Bignum.Definitions module BE = Hacl.Bignum.Exponentiation #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let t_limbs = U64 inline_for_extraction noextract let ke (a:S.ffdhe_alg) = BE.mk_runtime_exp #t_limbs (BD.blocks (DH.ffdhe_len a) (size (numbytes t_limbs))) private [@CInline] let ffdhe_precomp_p (a:S.ffdhe_alg) : DH.ffdhe_precomp_p_st t_limbs a (DH.ffdhe_len a) (ke a) = DH.ffdhe_precomp_p a (DH.ffdhe_len a) (ke a) private [@CInline] let ffdhe_check_pk (a:S.ffdhe_alg) : DH.ffdhe_check_pk_st t_limbs a (DH.ffdhe_len a) = DH.ffdhe_check_pk #t_limbs a (DH.ffdhe_len a) private [@CInline] let ffdhe_compute_exp (a:S.ffdhe_alg) : DH.ffdhe_compute_exp_st t_limbs a (DH.ffdhe_len a) (ke a) = DH.ffdhe_compute_exp a (DH.ffdhe_len a) (ke a) let ffdhe_len (a:S.ffdhe_alg) : DH.size_pos = DH.ffdhe_len a val new_ffdhe_precomp_p: a:S.ffdhe_alg -> DH.new_ffdhe_precomp_p_st t_limbs a (ffdhe_len a) (ke a) let new_ffdhe_precomp_p a = DH.new_ffdhe_precomp_p a (DH.ffdhe_len a) (ke a) (ffdhe_precomp_p a) val ffdhe_secret_to_public_precomp: a:S.ffdhe_alg ->
false
false
Hacl.FFDHE.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ffdhe_secret_to_public_precomp: a:S.ffdhe_alg -> DH.ffdhe_secret_to_public_precomp_st t_limbs a (DH.ffdhe_len a) (ke a)
[]
Hacl.FFDHE.ffdhe_secret_to_public_precomp
{ "file_name": "code/ffdhe/Hacl.FFDHE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.FFDHE.ffdhe_alg -> Hacl.Impl.FFDHE.ffdhe_secret_to_public_precomp_st Hacl.FFDHE.t_limbs a (Hacl.Impl.FFDHE.ffdhe_len a) (Hacl.FFDHE.ke a)
{ "end_col": 83, "end_line": 48, "start_col": 51, "start_line": 46 }
Prims.Tot
val ffdhe_shared_secret_precomp: a:S.ffdhe_alg -> DH.ffdhe_shared_secret_precomp_st t_limbs a (DH.ffdhe_len a) (ke a)
[ { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Impl.FFDHE", "short_module": "DH" }, { "abbrev": true, "full_module": "Spec.FFDHE", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ffdhe_shared_secret_precomp a p_r2_n sk pk ss = let len = DH.ffdhe_len a in DH.ffdhe_shared_secret_precomp a len (ke a) (ffdhe_check_pk a) (ffdhe_compute_exp a) p_r2_n sk pk ss
val ffdhe_shared_secret_precomp: a:S.ffdhe_alg -> DH.ffdhe_shared_secret_precomp_st t_limbs a (DH.ffdhe_len a) (ke a) let ffdhe_shared_secret_precomp a p_r2_n sk pk ss =
false
null
false
let len = DH.ffdhe_len a in DH.ffdhe_shared_secret_precomp a len (ke a) (ffdhe_check_pk a) (ffdhe_compute_exp a) p_r2_n sk pk ss
{ "checked_file": "Hacl.FFDHE.fst.checked", "dependencies": [ "Spec.FFDHE.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Impl.FFDHE.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.FFDHE.fst" }
[ "total" ]
[ "Spec.FFDHE.ffdhe_alg", "Hacl.Bignum.Definitions.lbignum", "Hacl.FFDHE.t_limbs", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.blocks", "Hacl.Impl.FFDHE.ffdhe_len", "Lib.IntTypes.size", "Lib.IntTypes.numbytes", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.Impl.FFDHE.ffdhe_shared_secret_precomp", "Hacl.FFDHE.ke", "Hacl.FFDHE.ffdhe_check_pk", "Hacl.FFDHE.ffdhe_compute_exp", "Hacl.Bignum.Definitions.limb", "Hacl.Impl.FFDHE.size_pos", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.l_and", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "Lib.IntTypes.v", "Spec.FFDHE.ffdhe_len" ]
[]
module Hacl.FFDHE open Lib.IntTypes module S = Spec.FFDHE module DH = Hacl.Impl.FFDHE module BD = Hacl.Bignum.Definitions module BE = Hacl.Bignum.Exponentiation #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let t_limbs = U64 inline_for_extraction noextract let ke (a:S.ffdhe_alg) = BE.mk_runtime_exp #t_limbs (BD.blocks (DH.ffdhe_len a) (size (numbytes t_limbs))) private [@CInline] let ffdhe_precomp_p (a:S.ffdhe_alg) : DH.ffdhe_precomp_p_st t_limbs a (DH.ffdhe_len a) (ke a) = DH.ffdhe_precomp_p a (DH.ffdhe_len a) (ke a) private [@CInline] let ffdhe_check_pk (a:S.ffdhe_alg) : DH.ffdhe_check_pk_st t_limbs a (DH.ffdhe_len a) = DH.ffdhe_check_pk #t_limbs a (DH.ffdhe_len a) private [@CInline] let ffdhe_compute_exp (a:S.ffdhe_alg) : DH.ffdhe_compute_exp_st t_limbs a (DH.ffdhe_len a) (ke a) = DH.ffdhe_compute_exp a (DH.ffdhe_len a) (ke a) let ffdhe_len (a:S.ffdhe_alg) : DH.size_pos = DH.ffdhe_len a val new_ffdhe_precomp_p: a:S.ffdhe_alg -> DH.new_ffdhe_precomp_p_st t_limbs a (ffdhe_len a) (ke a) let new_ffdhe_precomp_p a = DH.new_ffdhe_precomp_p a (DH.ffdhe_len a) (ke a) (ffdhe_precomp_p a) val ffdhe_secret_to_public_precomp: a:S.ffdhe_alg -> DH.ffdhe_secret_to_public_precomp_st t_limbs a (DH.ffdhe_len a) (ke a) let ffdhe_secret_to_public_precomp a p_r2_n sk pk = let len = DH.ffdhe_len a in DH.ffdhe_secret_to_public_precomp a len (ke a) (ffdhe_compute_exp a) p_r2_n sk pk val ffdhe_secret_to_public: a:S.ffdhe_alg -> DH.ffdhe_secret_to_public_st t_limbs a (DH.ffdhe_len a) (ke a) let ffdhe_secret_to_public a sk pk = let len = DH.ffdhe_len a in DH.ffdhe_secret_to_public a len (ke a) (ffdhe_secret_to_public_precomp a) (ffdhe_precomp_p a) sk pk val ffdhe_shared_secret_precomp: a:S.ffdhe_alg ->
false
false
Hacl.FFDHE.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ffdhe_shared_secret_precomp: a:S.ffdhe_alg -> DH.ffdhe_shared_secret_precomp_st t_limbs a (DH.ffdhe_len a) (ke a)
[]
Hacl.FFDHE.ffdhe_shared_secret_precomp
{ "file_name": "code/ffdhe/Hacl.FFDHE.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.FFDHE.ffdhe_alg -> Hacl.Impl.FFDHE.ffdhe_shared_secret_precomp_st Hacl.FFDHE.t_limbs a (Hacl.Impl.FFDHE.ffdhe_len a) (Hacl.FFDHE.ke a)
{ "end_col": 102, "end_line": 62, "start_col": 51, "start_line": 60 }
Prims.Tot
val sqr (#t: Type) (k: comm_monoid t) (a: t) : t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sqr (#t:Type) (k:comm_monoid t) (a:t) : t = mul a a
val sqr (#t: Type) (k: comm_monoid t) (a: t) : t let sqr (#t: Type) (k: comm_monoid t) (a: t) : t =
false
null
false
mul a a
{ "checked_file": "Lib.Exponentiation.Definition.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Lib.Exponentiation.Definition.fsti" }
[ "total" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Lib.Exponentiation.Definition.mul" ]
[]
module Lib.Exponentiation.Definition open FStar.Mul module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" //we don't require to have an inverse element to be an abelian group //so this is just commutative monoid inline_for_extraction class comm_monoid (t:Type) = { one: t; mul: t -> t -> t; lemma_one: a:t -> Lemma (mul a one == a); lemma_mul_assoc: a:t -> b:t -> c:t -> Lemma (mul (mul a b) c == mul a (mul b c)); lemma_mul_comm: a:t -> b:t -> Lemma (mul a b == mul b a) } inline_for_extraction class abelian_group (t:Type) = { cm:comm_monoid t; inverse: t -> t; lemma_inverse: a:t -> Lemma (mul (inverse a) a == one) }
false
false
Lib.Exponentiation.Definition.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sqr (#t: Type) (k: comm_monoid t) (a: t) : t
[]
Lib.Exponentiation.Definition.sqr
{ "file_name": "lib/Lib.Exponentiation.Definition.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> a: t -> t
{ "end_col": 55, "end_line": 28, "start_col": 48, "start_line": 28 }
Prims.Tot
val pow_neg (#t: Type) (k: abelian_group t) (x: t) (n: int) : t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let pow_neg (#t:Type) (k:abelian_group t) (x:t) (n:int) : t = if n >= 0 then pow k.cm x n else k.inverse (pow k.cm x (- n))
val pow_neg (#t: Type) (k: abelian_group t) (x: t) (n: int) : t let pow_neg (#t: Type) (k: abelian_group t) (x: t) (n: int) : t =
false
null
false
if n >= 0 then pow k.cm x n else k.inverse (pow k.cm x (- n))
{ "checked_file": "Lib.Exponentiation.Definition.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Lib.Exponentiation.Definition.fsti" }
[ "total" ]
[ "Lib.Exponentiation.Definition.abelian_group", "Prims.int", "Prims.op_GreaterThanOrEqual", "Lib.Exponentiation.Definition.pow", "Lib.Exponentiation.Definition.__proj__Mkabelian_group__item__cm", "Prims.bool", "Lib.Exponentiation.Definition.__proj__Mkabelian_group__item__inverse", "Prims.op_Minus" ]
[]
module Lib.Exponentiation.Definition open FStar.Mul module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" //we don't require to have an inverse element to be an abelian group //so this is just commutative monoid inline_for_extraction class comm_monoid (t:Type) = { one: t; mul: t -> t -> t; lemma_one: a:t -> Lemma (mul a one == a); lemma_mul_assoc: a:t -> b:t -> c:t -> Lemma (mul (mul a b) c == mul a (mul b c)); lemma_mul_comm: a:t -> b:t -> Lemma (mul a b == mul b a) } inline_for_extraction class abelian_group (t:Type) = { cm:comm_monoid t; inverse: t -> t; lemma_inverse: a:t -> Lemma (mul (inverse a) a == one) } let sqr (#t:Type) (k:comm_monoid t) (a:t) : t = mul a a [@(strict_on_arguments [3])] let rec pow (#t:Type) (k:comm_monoid t) (x:t) (n:nat) : t = if n = 0 then one else mul x (pow k x (n - 1))
false
false
Lib.Exponentiation.Definition.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val pow_neg (#t: Type) (k: abelian_group t) (x: t) (n: int) : t
[]
Lib.Exponentiation.Definition.pow_neg
{ "file_name": "lib/Lib.Exponentiation.Definition.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.abelian_group t -> x: t -> n: Prims.int -> t
{ "end_col": 63, "end_line": 37, "start_col": 2, "start_line": 37 }
Prims.Tot
val pow (#t: Type) (k: comm_monoid t) (x: t) (n: nat) : t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Lib.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec pow (#t:Type) (k:comm_monoid t) (x:t) (n:nat) : t = if n = 0 then one else mul x (pow k x (n - 1))
val pow (#t: Type) (k: comm_monoid t) (x: t) (n: nat) : t let rec pow (#t: Type) (k: comm_monoid t) (x: t) (n: nat) : t =
false
null
false
if n = 0 then one else mul x (pow k x (n - 1))
{ "checked_file": "Lib.Exponentiation.Definition.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.LoopCombinators.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Lib.Exponentiation.Definition.fsti" }
[ "total" ]
[ "Lib.Exponentiation.Definition.comm_monoid", "Prims.nat", "Prims.op_Equality", "Prims.int", "Lib.Exponentiation.Definition.one", "Prims.bool", "Lib.Exponentiation.Definition.mul", "Lib.Exponentiation.Definition.pow", "Prims.op_Subtraction" ]
[]
module Lib.Exponentiation.Definition open FStar.Mul module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" //we don't require to have an inverse element to be an abelian group //so this is just commutative monoid inline_for_extraction class comm_monoid (t:Type) = { one: t; mul: t -> t -> t; lemma_one: a:t -> Lemma (mul a one == a); lemma_mul_assoc: a:t -> b:t -> c:t -> Lemma (mul (mul a b) c == mul a (mul b c)); lemma_mul_comm: a:t -> b:t -> Lemma (mul a b == mul b a) } inline_for_extraction class abelian_group (t:Type) = { cm:comm_monoid t; inverse: t -> t; lemma_inverse: a:t -> Lemma (mul (inverse a) a == one) } let sqr (#t:Type) (k:comm_monoid t) (a:t) : t = mul a a [@(strict_on_arguments [3])]
false
false
Lib.Exponentiation.Definition.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val pow (#t: Type) (k: comm_monoid t) (x: t) (n: nat) : t
[ "recursion" ]
Lib.Exponentiation.Definition.pow
{ "file_name": "lib/Lib.Exponentiation.Definition.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Lib.Exponentiation.Definition.comm_monoid t -> x: t -> n: Prims.nat -> t
{ "end_col": 30, "end_line": 34, "start_col": 2, "start_line": 33 }
FStar.HyperStack.ST.Stack
val mk_base_point: p:P.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ P.point_inv h1 p /\ P.point_eval h1 p == S.g)
[ { "abbrev": true, "full_module": "Hacl.Spec.K256.Field52.Lemmas", "short_module": "BL" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointMul", "short_module": "PM" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointDouble", "short_module": "PD" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointAdd", "short_module": "PA" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Point", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Finv", "short_module": "FI" }, { "abbrev": true, "full_module": "Hacl.K256.Scalar", "short_module": "Q" }, { "abbrev": true, "full_module": "Hacl.K256.Field", "short_module": "F" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mk_base_point p = P.make_g p
val mk_base_point: p:P.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ P.point_inv h1 p /\ P.point_eval h1 p == S.g) let mk_base_point p =
true
null
false
P.make_g p
{ "checked_file": "Hacl.EC.K256.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Field52.Lemmas.fsti.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.Field.fsti.checked", "Hacl.Impl.K256.PointMul.fsti.checked", "Hacl.Impl.K256.PointDouble.fst.checked", "Hacl.Impl.K256.PointAdd.fst.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Finv.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.K256.fst" }
[]
[ "Hacl.Impl.K256.Point.point", "Hacl.Impl.K256.Point.make_g", "Prims.unit" ]
[]
module Hacl.EC.K256 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module BSeq = Lib.ByteSequence module S = Spec.K256 module F = Hacl.K256.Field module Q = Hacl.K256.Scalar module FI = Hacl.Impl.K256.Finv module P = Hacl.Impl.K256.Point module PA = Hacl.Impl.K256.PointAdd module PD = Hacl.Impl.K256.PointDouble module PM = Hacl.Impl.K256.PointMul module BL = Hacl.Spec.K256.Field52.Lemmas #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^256 - 0x1000003D1. This is a 64-bit optimized version, where a field element in radix-2^{52} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.zero) let mk_felem_zero f = Math.Lemmas.small_mod S.zero S.prime; F.set_zero f [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.one) let mk_felem_one f = Math.Lemmas.small_mod S.one S.prime; F.set_one f [@@ Comment "Write `a + b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_add (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fadd (F.feval h0 a) (F.feval h0 b)) let felem_add a b out = let h0 = ST.get () in BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b); F.fadd out a b; let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (2,2,2,2,4)); BL.normalize_weak5_lemma (2,2,2,2,4) (F.as_felem5 h1 out); F.fnormalize_weak out out [@@ Comment "Write `a - b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_sub (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fsub (F.feval h0 a) (F.feval h0 b)) let felem_sub a b out = let h0 = ST.get () in BL.fsub5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b) (u64 2); F.fsub out a b (u64 2); let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (5,5,5,5,6)); BL.normalize_weak5_lemma (5,5,5,5,6) (F.as_felem5 h1 out); F.fnormalize_weak out out [@@ Comment "Write `a * b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_mul (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 b)) let felem_mul a b out = F.fmul out a b [@@ Comment "Write `a * a mod p` in `out`. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are either disjoint or equal"] val felem_sqr (a out:F.felem) : Stack unit (requires fun h -> live h a /\ live h out /\ eq_or_disjoint out a /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 a)) let felem_sqr a out = F.fsqr out a [@@ Comment "Write `a ^ (p - 2) mod p` in `out`. The function computes modular multiplicative inverse if `a` <> zero. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_inv (a out:F.felem) : Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.finv (F.feval h0 a)) let felem_inv a out = FI.finv out a [@@ Comment "Load a bid-endian field element from memory. The argument `b` points to 32 bytes of valid memory, i.e., uint8_t[32]. The outparam `out` points to a field element of 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `b` and `out` are disjoint"] val felem_load: b:lbuffer uint8 32ul -> out:F.felem -> Stack unit (requires fun h -> live h b /\ live h out /\ disjoint b out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == BSeq.nat_from_bytes_be (as_seq h0 b) % S.prime) let felem_load b out = F.load_felem out b [@@ Comment "Serialize a field element into big-endian memory. The argument `a` points to a field element of 5 limbs in size, i.e., uint64_t[5]. The outparam `out` points to 32 bytes of valid memory, i.e., uint8_t[32]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_store: a:F.felem -> out:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == BSeq.nat_to_bytes_be 32 (F.feval h0 a)) let felem_store a out = push_frame (); let tmp = F.create_felem () in let h0 = ST.get () in BL.normalize5_lemma (1,1,1,1,2) (F.as_felem5 h0 a); F.fnormalize tmp a; F.store_felem out tmp; pop_frame () [@@ CPrologue "/******************************************************************************* Verified group operations for the secp256k1 curve of the form y^2 = x^3 + 7. This is a 64-bit optimized version, where a group element in projective coordinates is represented as an array of 15 unsigned 64-bit integers, i.e., uint64_t[15]. *******************************************************************************/\n"; Comment "Write the point at infinity (additive identity) in `p`. The outparam `p` is meant to be 15 limbs in size, i.e., uint64_t[15]."] val mk_point_at_inf: p:P.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ P.point_inv h1 p /\ S.to_aff_point (P.point_eval h1 p) == S.aff_point_at_inf) let mk_point_at_inf p = P.make_point_at_inf p [@@ Comment "Write the base point (generator) in `p`. The outparam `p` is meant to be 15 limbs in size, i.e., uint64_t[15]."] val mk_base_point: p:P.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ P.point_inv h1 p /\ P.point_eval h1 p == S.g)
false
false
Hacl.EC.K256.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mk_base_point: p:P.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ P.point_inv h1 p /\ P.point_eval h1 p == S.g)
[]
Hacl.EC.K256.mk_base_point
{ "file_name": "code/k256/Hacl.EC.K256.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: Hacl.Impl.K256.Point.point -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 12, "end_line": 246, "start_col": 2, "start_line": 246 }
FStar.HyperStack.ST.Stack
val mk_point_at_inf: p:P.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ P.point_inv h1 p /\ S.to_aff_point (P.point_eval h1 p) == S.aff_point_at_inf)
[ { "abbrev": true, "full_module": "Hacl.Spec.K256.Field52.Lemmas", "short_module": "BL" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointMul", "short_module": "PM" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointDouble", "short_module": "PD" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointAdd", "short_module": "PA" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Point", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Finv", "short_module": "FI" }, { "abbrev": true, "full_module": "Hacl.K256.Scalar", "short_module": "Q" }, { "abbrev": true, "full_module": "Hacl.K256.Field", "short_module": "F" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mk_point_at_inf p = P.make_point_at_inf p
val mk_point_at_inf: p:P.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ P.point_inv h1 p /\ S.to_aff_point (P.point_eval h1 p) == S.aff_point_at_inf) let mk_point_at_inf p =
true
null
false
P.make_point_at_inf p
{ "checked_file": "Hacl.EC.K256.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Field52.Lemmas.fsti.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.Field.fsti.checked", "Hacl.Impl.K256.PointMul.fsti.checked", "Hacl.Impl.K256.PointDouble.fst.checked", "Hacl.Impl.K256.PointAdd.fst.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Finv.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.K256.fst" }
[]
[ "Hacl.Impl.K256.Point.point", "Hacl.Impl.K256.Point.make_point_at_inf", "Prims.unit" ]
[]
module Hacl.EC.K256 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module BSeq = Lib.ByteSequence module S = Spec.K256 module F = Hacl.K256.Field module Q = Hacl.K256.Scalar module FI = Hacl.Impl.K256.Finv module P = Hacl.Impl.K256.Point module PA = Hacl.Impl.K256.PointAdd module PD = Hacl.Impl.K256.PointDouble module PM = Hacl.Impl.K256.PointMul module BL = Hacl.Spec.K256.Field52.Lemmas #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^256 - 0x1000003D1. This is a 64-bit optimized version, where a field element in radix-2^{52} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.zero) let mk_felem_zero f = Math.Lemmas.small_mod S.zero S.prime; F.set_zero f [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.one) let mk_felem_one f = Math.Lemmas.small_mod S.one S.prime; F.set_one f [@@ Comment "Write `a + b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_add (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fadd (F.feval h0 a) (F.feval h0 b)) let felem_add a b out = let h0 = ST.get () in BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b); F.fadd out a b; let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (2,2,2,2,4)); BL.normalize_weak5_lemma (2,2,2,2,4) (F.as_felem5 h1 out); F.fnormalize_weak out out [@@ Comment "Write `a - b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_sub (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fsub (F.feval h0 a) (F.feval h0 b)) let felem_sub a b out = let h0 = ST.get () in BL.fsub5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b) (u64 2); F.fsub out a b (u64 2); let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (5,5,5,5,6)); BL.normalize_weak5_lemma (5,5,5,5,6) (F.as_felem5 h1 out); F.fnormalize_weak out out [@@ Comment "Write `a * b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_mul (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 b)) let felem_mul a b out = F.fmul out a b [@@ Comment "Write `a * a mod p` in `out`. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are either disjoint or equal"] val felem_sqr (a out:F.felem) : Stack unit (requires fun h -> live h a /\ live h out /\ eq_or_disjoint out a /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 a)) let felem_sqr a out = F.fsqr out a [@@ Comment "Write `a ^ (p - 2) mod p` in `out`. The function computes modular multiplicative inverse if `a` <> zero. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_inv (a out:F.felem) : Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.finv (F.feval h0 a)) let felem_inv a out = FI.finv out a [@@ Comment "Load a bid-endian field element from memory. The argument `b` points to 32 bytes of valid memory, i.e., uint8_t[32]. The outparam `out` points to a field element of 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `b` and `out` are disjoint"] val felem_load: b:lbuffer uint8 32ul -> out:F.felem -> Stack unit (requires fun h -> live h b /\ live h out /\ disjoint b out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == BSeq.nat_from_bytes_be (as_seq h0 b) % S.prime) let felem_load b out = F.load_felem out b [@@ Comment "Serialize a field element into big-endian memory. The argument `a` points to a field element of 5 limbs in size, i.e., uint64_t[5]. The outparam `out` points to 32 bytes of valid memory, i.e., uint8_t[32]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_store: a:F.felem -> out:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == BSeq.nat_to_bytes_be 32 (F.feval h0 a)) let felem_store a out = push_frame (); let tmp = F.create_felem () in let h0 = ST.get () in BL.normalize5_lemma (1,1,1,1,2) (F.as_felem5 h0 a); F.fnormalize tmp a; F.store_felem out tmp; pop_frame () [@@ CPrologue "/******************************************************************************* Verified group operations for the secp256k1 curve of the form y^2 = x^3 + 7. This is a 64-bit optimized version, where a group element in projective coordinates is represented as an array of 15 unsigned 64-bit integers, i.e., uint64_t[15]. *******************************************************************************/\n"; Comment "Write the point at infinity (additive identity) in `p`. The outparam `p` is meant to be 15 limbs in size, i.e., uint64_t[15]."] val mk_point_at_inf: p:P.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ P.point_inv h1 p /\ S.to_aff_point (P.point_eval h1 p) == S.aff_point_at_inf)
false
false
Hacl.EC.K256.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mk_point_at_inf: p:P.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ P.point_inv h1 p /\ S.to_aff_point (P.point_eval h1 p) == S.aff_point_at_inf)
[]
Hacl.EC.K256.mk_point_at_inf
{ "file_name": "code/k256/Hacl.EC.K256.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: Hacl.Impl.K256.Point.point -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 23, "end_line": 234, "start_col": 2, "start_line": 234 }
FStar.HyperStack.ST.Stack
val mk_felem_one: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.one)
[ { "abbrev": true, "full_module": "Hacl.Spec.K256.Field52.Lemmas", "short_module": "BL" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointMul", "short_module": "PM" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointDouble", "short_module": "PD" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointAdd", "short_module": "PA" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Point", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Finv", "short_module": "FI" }, { "abbrev": true, "full_module": "Hacl.K256.Scalar", "short_module": "Q" }, { "abbrev": true, "full_module": "Hacl.K256.Field", "short_module": "F" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mk_felem_one f = Math.Lemmas.small_mod S.one S.prime; F.set_one f
val mk_felem_one: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.one) let mk_felem_one f =
true
null
false
Math.Lemmas.small_mod S.one S.prime; F.set_one f
{ "checked_file": "Hacl.EC.K256.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Field52.Lemmas.fsti.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.Field.fsti.checked", "Hacl.Impl.K256.PointMul.fsti.checked", "Hacl.Impl.K256.PointDouble.fst.checked", "Hacl.Impl.K256.PointAdd.fst.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Finv.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.K256.fst" }
[]
[ "Hacl.K256.Field.felem", "Hacl.K256.Field.set_one", "Prims.unit", "FStar.Math.Lemmas.small_mod", "Spec.K256.PointOps.one", "Spec.K256.PointOps.prime" ]
[]
module Hacl.EC.K256 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module BSeq = Lib.ByteSequence module S = Spec.K256 module F = Hacl.K256.Field module Q = Hacl.K256.Scalar module FI = Hacl.Impl.K256.Finv module P = Hacl.Impl.K256.Point module PA = Hacl.Impl.K256.PointAdd module PD = Hacl.Impl.K256.PointDouble module PM = Hacl.Impl.K256.PointMul module BL = Hacl.Spec.K256.Field52.Lemmas #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^256 - 0x1000003D1. This is a 64-bit optimized version, where a field element in radix-2^{52} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.zero) let mk_felem_zero f = Math.Lemmas.small_mod S.zero S.prime; F.set_zero f [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.one)
false
false
Hacl.EC.K256.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mk_felem_one: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.one)
[]
Hacl.EC.K256.mk_felem_one
{ "file_name": "code/k256/Hacl.EC.K256.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Hacl.K256.Field.felem -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 13, "end_line": 59, "start_col": 2, "start_line": 58 }
FStar.HyperStack.ST.Stack
val point_double (p out:P.point) : Stack unit (requires fun h -> live h out /\ live h p /\ eq_or_disjoint p out /\ P.point_inv h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.point_double (P.point_eval h0 p))
[ { "abbrev": true, "full_module": "Hacl.Spec.K256.Field52.Lemmas", "short_module": "BL" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointMul", "short_module": "PM" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointDouble", "short_module": "PD" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointAdd", "short_module": "PA" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Point", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Finv", "short_module": "FI" }, { "abbrev": true, "full_module": "Hacl.K256.Scalar", "short_module": "Q" }, { "abbrev": true, "full_module": "Hacl.K256.Field", "short_module": "F" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let point_double p out = PD.point_double out p
val point_double (p out:P.point) : Stack unit (requires fun h -> live h out /\ live h p /\ eq_or_disjoint p out /\ P.point_inv h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.point_double (P.point_eval h0 p)) let point_double p out =
true
null
false
PD.point_double out p
{ "checked_file": "Hacl.EC.K256.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Field52.Lemmas.fsti.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.Field.fsti.checked", "Hacl.Impl.K256.PointMul.fsti.checked", "Hacl.Impl.K256.PointDouble.fst.checked", "Hacl.Impl.K256.PointAdd.fst.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Finv.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.K256.fst" }
[]
[ "Hacl.Impl.K256.Point.point", "Hacl.Impl.K256.PointDouble.point_double", "Prims.unit" ]
[]
module Hacl.EC.K256 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module BSeq = Lib.ByteSequence module S = Spec.K256 module F = Hacl.K256.Field module Q = Hacl.K256.Scalar module FI = Hacl.Impl.K256.Finv module P = Hacl.Impl.K256.Point module PA = Hacl.Impl.K256.PointAdd module PD = Hacl.Impl.K256.PointDouble module PM = Hacl.Impl.K256.PointMul module BL = Hacl.Spec.K256.Field52.Lemmas #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^256 - 0x1000003D1. This is a 64-bit optimized version, where a field element in radix-2^{52} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.zero) let mk_felem_zero f = Math.Lemmas.small_mod S.zero S.prime; F.set_zero f [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.one) let mk_felem_one f = Math.Lemmas.small_mod S.one S.prime; F.set_one f [@@ Comment "Write `a + b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_add (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fadd (F.feval h0 a) (F.feval h0 b)) let felem_add a b out = let h0 = ST.get () in BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b); F.fadd out a b; let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (2,2,2,2,4)); BL.normalize_weak5_lemma (2,2,2,2,4) (F.as_felem5 h1 out); F.fnormalize_weak out out [@@ Comment "Write `a - b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_sub (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fsub (F.feval h0 a) (F.feval h0 b)) let felem_sub a b out = let h0 = ST.get () in BL.fsub5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b) (u64 2); F.fsub out a b (u64 2); let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (5,5,5,5,6)); BL.normalize_weak5_lemma (5,5,5,5,6) (F.as_felem5 h1 out); F.fnormalize_weak out out [@@ Comment "Write `a * b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_mul (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 b)) let felem_mul a b out = F.fmul out a b [@@ Comment "Write `a * a mod p` in `out`. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are either disjoint or equal"] val felem_sqr (a out:F.felem) : Stack unit (requires fun h -> live h a /\ live h out /\ eq_or_disjoint out a /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 a)) let felem_sqr a out = F.fsqr out a [@@ Comment "Write `a ^ (p - 2) mod p` in `out`. The function computes modular multiplicative inverse if `a` <> zero. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_inv (a out:F.felem) : Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.finv (F.feval h0 a)) let felem_inv a out = FI.finv out a [@@ Comment "Load a bid-endian field element from memory. The argument `b` points to 32 bytes of valid memory, i.e., uint8_t[32]. The outparam `out` points to a field element of 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `b` and `out` are disjoint"] val felem_load: b:lbuffer uint8 32ul -> out:F.felem -> Stack unit (requires fun h -> live h b /\ live h out /\ disjoint b out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == BSeq.nat_from_bytes_be (as_seq h0 b) % S.prime) let felem_load b out = F.load_felem out b [@@ Comment "Serialize a field element into big-endian memory. The argument `a` points to a field element of 5 limbs in size, i.e., uint64_t[5]. The outparam `out` points to 32 bytes of valid memory, i.e., uint8_t[32]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_store: a:F.felem -> out:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == BSeq.nat_to_bytes_be 32 (F.feval h0 a)) let felem_store a out = push_frame (); let tmp = F.create_felem () in let h0 = ST.get () in BL.normalize5_lemma (1,1,1,1,2) (F.as_felem5 h0 a); F.fnormalize tmp a; F.store_felem out tmp; pop_frame () [@@ CPrologue "/******************************************************************************* Verified group operations for the secp256k1 curve of the form y^2 = x^3 + 7. This is a 64-bit optimized version, where a group element in projective coordinates is represented as an array of 15 unsigned 64-bit integers, i.e., uint64_t[15]. *******************************************************************************/\n"; Comment "Write the point at infinity (additive identity) in `p`. The outparam `p` is meant to be 15 limbs in size, i.e., uint64_t[15]."] val mk_point_at_inf: p:P.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ P.point_inv h1 p /\ S.to_aff_point (P.point_eval h1 p) == S.aff_point_at_inf) let mk_point_at_inf p = P.make_point_at_inf p [@@ Comment "Write the base point (generator) in `p`. The outparam `p` is meant to be 15 limbs in size, i.e., uint64_t[15]."] val mk_base_point: p:P.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ P.point_inv h1 p /\ P.point_eval h1 p == S.g) let mk_base_point p = P.make_g p [@@ Comment "Write `-p` in `out` (point negation). The argument `p` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p` and `out` are either disjoint or equal"] val point_negate (p out:P.point) : Stack unit (requires fun h -> live h out /\ live h p /\ eq_or_disjoint out p /\ P.point_inv h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.point_negate (P.point_eval h0 p)) let point_negate p out = P.point_negate out p [@@ Comment "Write `p + q` in `out` (point addition). The arguments `p`, `q` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p`, `q`, and `out` are either pairwise disjoint or equal"] val point_add (p q out:P.point) : Stack unit (requires fun h -> live h out /\ live h p /\ live h q /\ eq_or_disjoint p out /\ eq_or_disjoint q out /\ eq_or_disjoint p q /\ P.point_inv h p /\ P.point_inv h q) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.point_add (P.point_eval h0 p) (P.point_eval h0 q)) let point_add p q out = PA.point_add out p q [@@ Comment "Write `p + p` in `out` (point doubling). The argument `p` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p` and `out` are either disjoint or equal"] val point_double (p out:P.point) : Stack unit (requires fun h -> live h out /\ live h p /\ eq_or_disjoint p out /\ P.point_inv h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.point_double (P.point_eval h0 p))
false
false
Hacl.EC.K256.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val point_double (p out:P.point) : Stack unit (requires fun h -> live h out /\ live h p /\ eq_or_disjoint p out /\ P.point_inv h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.point_double (P.point_eval h0 p))
[]
Hacl.EC.K256.point_double
{ "file_name": "code/k256/Hacl.EC.K256.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: Hacl.Impl.K256.Point.point -> out: Hacl.Impl.K256.Point.point -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 23, "end_line": 303, "start_col": 2, "start_line": 303 }
FStar.HyperStack.ST.Stack
val mk_felem_zero: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.zero)
[ { "abbrev": true, "full_module": "Hacl.Spec.K256.Field52.Lemmas", "short_module": "BL" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointMul", "short_module": "PM" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointDouble", "short_module": "PD" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointAdd", "short_module": "PA" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Point", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Finv", "short_module": "FI" }, { "abbrev": true, "full_module": "Hacl.K256.Scalar", "short_module": "Q" }, { "abbrev": true, "full_module": "Hacl.K256.Field", "short_module": "F" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mk_felem_zero f = Math.Lemmas.small_mod S.zero S.prime; F.set_zero f
val mk_felem_zero: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.zero) let mk_felem_zero f =
true
null
false
Math.Lemmas.small_mod S.zero S.prime; F.set_zero f
{ "checked_file": "Hacl.EC.K256.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Field52.Lemmas.fsti.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.Field.fsti.checked", "Hacl.Impl.K256.PointMul.fsti.checked", "Hacl.Impl.K256.PointDouble.fst.checked", "Hacl.Impl.K256.PointAdd.fst.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Finv.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.K256.fst" }
[]
[ "Hacl.K256.Field.felem", "Hacl.K256.Field.set_zero", "Prims.unit", "FStar.Math.Lemmas.small_mod", "Spec.K256.PointOps.zero", "Spec.K256.PointOps.prime" ]
[]
module Hacl.EC.K256 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module BSeq = Lib.ByteSequence module S = Spec.K256 module F = Hacl.K256.Field module Q = Hacl.K256.Scalar module FI = Hacl.Impl.K256.Finv module P = Hacl.Impl.K256.Point module PA = Hacl.Impl.K256.PointAdd module PD = Hacl.Impl.K256.PointDouble module PM = Hacl.Impl.K256.PointMul module BL = Hacl.Spec.K256.Field52.Lemmas #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^256 - 0x1000003D1. This is a 64-bit optimized version, where a field element in radix-2^{52} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.zero)
false
false
Hacl.EC.K256.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mk_felem_zero: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.zero)
[]
Hacl.EC.K256.mk_felem_zero
{ "file_name": "code/k256/Hacl.EC.K256.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Hacl.K256.Field.felem -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 14, "end_line": 46, "start_col": 2, "start_line": 45 }
FStar.HyperStack.ST.Stack
val felem_inv (a out:F.felem) : Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.finv (F.feval h0 a))
[ { "abbrev": true, "full_module": "Hacl.Spec.K256.Field52.Lemmas", "short_module": "BL" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointMul", "short_module": "PM" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointDouble", "short_module": "PD" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointAdd", "short_module": "PA" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Point", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Finv", "short_module": "FI" }, { "abbrev": true, "full_module": "Hacl.K256.Scalar", "short_module": "Q" }, { "abbrev": true, "full_module": "Hacl.K256.Field", "short_module": "F" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let felem_inv a out = FI.finv out a
val felem_inv (a out:F.felem) : Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.finv (F.feval h0 a)) let felem_inv a out =
true
null
false
FI.finv out a
{ "checked_file": "Hacl.EC.K256.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Field52.Lemmas.fsti.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.Field.fsti.checked", "Hacl.Impl.K256.PointMul.fsti.checked", "Hacl.Impl.K256.PointDouble.fst.checked", "Hacl.Impl.K256.PointAdd.fst.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Finv.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.K256.fst" }
[]
[ "Hacl.K256.Field.felem", "Hacl.Impl.K256.Finv.finv", "Prims.unit" ]
[]
module Hacl.EC.K256 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module BSeq = Lib.ByteSequence module S = Spec.K256 module F = Hacl.K256.Field module Q = Hacl.K256.Scalar module FI = Hacl.Impl.K256.Finv module P = Hacl.Impl.K256.Point module PA = Hacl.Impl.K256.PointAdd module PD = Hacl.Impl.K256.PointDouble module PM = Hacl.Impl.K256.PointMul module BL = Hacl.Spec.K256.Field52.Lemmas #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^256 - 0x1000003D1. This is a 64-bit optimized version, where a field element in radix-2^{52} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.zero) let mk_felem_zero f = Math.Lemmas.small_mod S.zero S.prime; F.set_zero f [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.one) let mk_felem_one f = Math.Lemmas.small_mod S.one S.prime; F.set_one f [@@ Comment "Write `a + b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_add (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fadd (F.feval h0 a) (F.feval h0 b)) let felem_add a b out = let h0 = ST.get () in BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b); F.fadd out a b; let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (2,2,2,2,4)); BL.normalize_weak5_lemma (2,2,2,2,4) (F.as_felem5 h1 out); F.fnormalize_weak out out [@@ Comment "Write `a - b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_sub (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fsub (F.feval h0 a) (F.feval h0 b)) let felem_sub a b out = let h0 = ST.get () in BL.fsub5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b) (u64 2); F.fsub out a b (u64 2); let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (5,5,5,5,6)); BL.normalize_weak5_lemma (5,5,5,5,6) (F.as_felem5 h1 out); F.fnormalize_weak out out [@@ Comment "Write `a * b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_mul (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 b)) let felem_mul a b out = F.fmul out a b [@@ Comment "Write `a * a mod p` in `out`. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are either disjoint or equal"] val felem_sqr (a out:F.felem) : Stack unit (requires fun h -> live h a /\ live h out /\ eq_or_disjoint out a /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 a)) let felem_sqr a out = F.fsqr out a [@@ Comment "Write `a ^ (p - 2) mod p` in `out`. The function computes modular multiplicative inverse if `a` <> zero. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_inv (a out:F.felem) : Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.finv (F.feval h0 a))
false
false
Hacl.EC.K256.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val felem_inv (a out:F.felem) : Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.finv (F.feval h0 a))
[]
Hacl.EC.K256.felem_inv
{ "file_name": "code/k256/Hacl.EC.K256.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.K256.Field.felem -> out: Hacl.K256.Field.felem -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 15, "end_line": 171, "start_col": 2, "start_line": 171 }
FStar.HyperStack.ST.Stack
val point_negate (p out:P.point) : Stack unit (requires fun h -> live h out /\ live h p /\ eq_or_disjoint out p /\ P.point_inv h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.point_negate (P.point_eval h0 p))
[ { "abbrev": true, "full_module": "Hacl.Spec.K256.Field52.Lemmas", "short_module": "BL" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointMul", "short_module": "PM" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointDouble", "short_module": "PD" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointAdd", "short_module": "PA" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Point", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Finv", "short_module": "FI" }, { "abbrev": true, "full_module": "Hacl.K256.Scalar", "short_module": "Q" }, { "abbrev": true, "full_module": "Hacl.K256.Field", "short_module": "F" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let point_negate p out = P.point_negate out p
val point_negate (p out:P.point) : Stack unit (requires fun h -> live h out /\ live h p /\ eq_or_disjoint out p /\ P.point_inv h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.point_negate (P.point_eval h0 p)) let point_negate p out =
true
null
false
P.point_negate out p
{ "checked_file": "Hacl.EC.K256.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Field52.Lemmas.fsti.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.Field.fsti.checked", "Hacl.Impl.K256.PointMul.fsti.checked", "Hacl.Impl.K256.PointDouble.fst.checked", "Hacl.Impl.K256.PointAdd.fst.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Finv.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.K256.fst" }
[]
[ "Hacl.Impl.K256.Point.point", "Hacl.Impl.K256.Point.point_negate", "Prims.unit" ]
[]
module Hacl.EC.K256 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module BSeq = Lib.ByteSequence module S = Spec.K256 module F = Hacl.K256.Field module Q = Hacl.K256.Scalar module FI = Hacl.Impl.K256.Finv module P = Hacl.Impl.K256.Point module PA = Hacl.Impl.K256.PointAdd module PD = Hacl.Impl.K256.PointDouble module PM = Hacl.Impl.K256.PointMul module BL = Hacl.Spec.K256.Field52.Lemmas #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^256 - 0x1000003D1. This is a 64-bit optimized version, where a field element in radix-2^{52} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.zero) let mk_felem_zero f = Math.Lemmas.small_mod S.zero S.prime; F.set_zero f [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.one) let mk_felem_one f = Math.Lemmas.small_mod S.one S.prime; F.set_one f [@@ Comment "Write `a + b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_add (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fadd (F.feval h0 a) (F.feval h0 b)) let felem_add a b out = let h0 = ST.get () in BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b); F.fadd out a b; let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (2,2,2,2,4)); BL.normalize_weak5_lemma (2,2,2,2,4) (F.as_felem5 h1 out); F.fnormalize_weak out out [@@ Comment "Write `a - b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_sub (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fsub (F.feval h0 a) (F.feval h0 b)) let felem_sub a b out = let h0 = ST.get () in BL.fsub5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b) (u64 2); F.fsub out a b (u64 2); let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (5,5,5,5,6)); BL.normalize_weak5_lemma (5,5,5,5,6) (F.as_felem5 h1 out); F.fnormalize_weak out out [@@ Comment "Write `a * b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_mul (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 b)) let felem_mul a b out = F.fmul out a b [@@ Comment "Write `a * a mod p` in `out`. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are either disjoint or equal"] val felem_sqr (a out:F.felem) : Stack unit (requires fun h -> live h a /\ live h out /\ eq_or_disjoint out a /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 a)) let felem_sqr a out = F.fsqr out a [@@ Comment "Write `a ^ (p - 2) mod p` in `out`. The function computes modular multiplicative inverse if `a` <> zero. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_inv (a out:F.felem) : Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.finv (F.feval h0 a)) let felem_inv a out = FI.finv out a [@@ Comment "Load a bid-endian field element from memory. The argument `b` points to 32 bytes of valid memory, i.e., uint8_t[32]. The outparam `out` points to a field element of 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `b` and `out` are disjoint"] val felem_load: b:lbuffer uint8 32ul -> out:F.felem -> Stack unit (requires fun h -> live h b /\ live h out /\ disjoint b out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == BSeq.nat_from_bytes_be (as_seq h0 b) % S.prime) let felem_load b out = F.load_felem out b [@@ Comment "Serialize a field element into big-endian memory. The argument `a` points to a field element of 5 limbs in size, i.e., uint64_t[5]. The outparam `out` points to 32 bytes of valid memory, i.e., uint8_t[32]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_store: a:F.felem -> out:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == BSeq.nat_to_bytes_be 32 (F.feval h0 a)) let felem_store a out = push_frame (); let tmp = F.create_felem () in let h0 = ST.get () in BL.normalize5_lemma (1,1,1,1,2) (F.as_felem5 h0 a); F.fnormalize tmp a; F.store_felem out tmp; pop_frame () [@@ CPrologue "/******************************************************************************* Verified group operations for the secp256k1 curve of the form y^2 = x^3 + 7. This is a 64-bit optimized version, where a group element in projective coordinates is represented as an array of 15 unsigned 64-bit integers, i.e., uint64_t[15]. *******************************************************************************/\n"; Comment "Write the point at infinity (additive identity) in `p`. The outparam `p` is meant to be 15 limbs in size, i.e., uint64_t[15]."] val mk_point_at_inf: p:P.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ P.point_inv h1 p /\ S.to_aff_point (P.point_eval h1 p) == S.aff_point_at_inf) let mk_point_at_inf p = P.make_point_at_inf p [@@ Comment "Write the base point (generator) in `p`. The outparam `p` is meant to be 15 limbs in size, i.e., uint64_t[15]."] val mk_base_point: p:P.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ P.point_inv h1 p /\ P.point_eval h1 p == S.g) let mk_base_point p = P.make_g p [@@ Comment "Write `-p` in `out` (point negation). The argument `p` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p` and `out` are either disjoint or equal"] val point_negate (p out:P.point) : Stack unit (requires fun h -> live h out /\ live h p /\ eq_or_disjoint out p /\ P.point_inv h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.point_negate (P.point_eval h0 p))
false
false
Hacl.EC.K256.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val point_negate (p out:P.point) : Stack unit (requires fun h -> live h out /\ live h p /\ eq_or_disjoint out p /\ P.point_inv h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.point_negate (P.point_eval h0 p))
[]
Hacl.EC.K256.point_negate
{ "file_name": "code/k256/Hacl.EC.K256.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: Hacl.Impl.K256.Point.point -> out: Hacl.Impl.K256.Point.point -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 22, "end_line": 265, "start_col": 2, "start_line": 265 }
FStar.HyperStack.ST.Stack
val point_add (p q out:P.point) : Stack unit (requires fun h -> live h out /\ live h p /\ live h q /\ eq_or_disjoint p out /\ eq_or_disjoint q out /\ eq_or_disjoint p q /\ P.point_inv h p /\ P.point_inv h q) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.point_add (P.point_eval h0 p) (P.point_eval h0 q))
[ { "abbrev": true, "full_module": "Hacl.Spec.K256.Field52.Lemmas", "short_module": "BL" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointMul", "short_module": "PM" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointDouble", "short_module": "PD" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointAdd", "short_module": "PA" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Point", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Finv", "short_module": "FI" }, { "abbrev": true, "full_module": "Hacl.K256.Scalar", "short_module": "Q" }, { "abbrev": true, "full_module": "Hacl.K256.Field", "short_module": "F" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let point_add p q out = PA.point_add out p q
val point_add (p q out:P.point) : Stack unit (requires fun h -> live h out /\ live h p /\ live h q /\ eq_or_disjoint p out /\ eq_or_disjoint q out /\ eq_or_disjoint p q /\ P.point_inv h p /\ P.point_inv h q) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.point_add (P.point_eval h0 p) (P.point_eval h0 q)) let point_add p q out =
true
null
false
PA.point_add out p q
{ "checked_file": "Hacl.EC.K256.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Field52.Lemmas.fsti.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.Field.fsti.checked", "Hacl.Impl.K256.PointMul.fsti.checked", "Hacl.Impl.K256.PointDouble.fst.checked", "Hacl.Impl.K256.PointAdd.fst.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Finv.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.K256.fst" }
[]
[ "Hacl.Impl.K256.Point.point", "Hacl.Impl.K256.PointAdd.point_add", "Prims.unit" ]
[]
module Hacl.EC.K256 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module BSeq = Lib.ByteSequence module S = Spec.K256 module F = Hacl.K256.Field module Q = Hacl.K256.Scalar module FI = Hacl.Impl.K256.Finv module P = Hacl.Impl.K256.Point module PA = Hacl.Impl.K256.PointAdd module PD = Hacl.Impl.K256.PointDouble module PM = Hacl.Impl.K256.PointMul module BL = Hacl.Spec.K256.Field52.Lemmas #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^256 - 0x1000003D1. This is a 64-bit optimized version, where a field element in radix-2^{52} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.zero) let mk_felem_zero f = Math.Lemmas.small_mod S.zero S.prime; F.set_zero f [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.one) let mk_felem_one f = Math.Lemmas.small_mod S.one S.prime; F.set_one f [@@ Comment "Write `a + b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_add (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fadd (F.feval h0 a) (F.feval h0 b)) let felem_add a b out = let h0 = ST.get () in BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b); F.fadd out a b; let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (2,2,2,2,4)); BL.normalize_weak5_lemma (2,2,2,2,4) (F.as_felem5 h1 out); F.fnormalize_weak out out [@@ Comment "Write `a - b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_sub (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fsub (F.feval h0 a) (F.feval h0 b)) let felem_sub a b out = let h0 = ST.get () in BL.fsub5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b) (u64 2); F.fsub out a b (u64 2); let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (5,5,5,5,6)); BL.normalize_weak5_lemma (5,5,5,5,6) (F.as_felem5 h1 out); F.fnormalize_weak out out [@@ Comment "Write `a * b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_mul (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 b)) let felem_mul a b out = F.fmul out a b [@@ Comment "Write `a * a mod p` in `out`. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are either disjoint or equal"] val felem_sqr (a out:F.felem) : Stack unit (requires fun h -> live h a /\ live h out /\ eq_or_disjoint out a /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 a)) let felem_sqr a out = F.fsqr out a [@@ Comment "Write `a ^ (p - 2) mod p` in `out`. The function computes modular multiplicative inverse if `a` <> zero. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_inv (a out:F.felem) : Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.finv (F.feval h0 a)) let felem_inv a out = FI.finv out a [@@ Comment "Load a bid-endian field element from memory. The argument `b` points to 32 bytes of valid memory, i.e., uint8_t[32]. The outparam `out` points to a field element of 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `b` and `out` are disjoint"] val felem_load: b:lbuffer uint8 32ul -> out:F.felem -> Stack unit (requires fun h -> live h b /\ live h out /\ disjoint b out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == BSeq.nat_from_bytes_be (as_seq h0 b) % S.prime) let felem_load b out = F.load_felem out b [@@ Comment "Serialize a field element into big-endian memory. The argument `a` points to a field element of 5 limbs in size, i.e., uint64_t[5]. The outparam `out` points to 32 bytes of valid memory, i.e., uint8_t[32]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_store: a:F.felem -> out:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == BSeq.nat_to_bytes_be 32 (F.feval h0 a)) let felem_store a out = push_frame (); let tmp = F.create_felem () in let h0 = ST.get () in BL.normalize5_lemma (1,1,1,1,2) (F.as_felem5 h0 a); F.fnormalize tmp a; F.store_felem out tmp; pop_frame () [@@ CPrologue "/******************************************************************************* Verified group operations for the secp256k1 curve of the form y^2 = x^3 + 7. This is a 64-bit optimized version, where a group element in projective coordinates is represented as an array of 15 unsigned 64-bit integers, i.e., uint64_t[15]. *******************************************************************************/\n"; Comment "Write the point at infinity (additive identity) in `p`. The outparam `p` is meant to be 15 limbs in size, i.e., uint64_t[15]."] val mk_point_at_inf: p:P.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ P.point_inv h1 p /\ S.to_aff_point (P.point_eval h1 p) == S.aff_point_at_inf) let mk_point_at_inf p = P.make_point_at_inf p [@@ Comment "Write the base point (generator) in `p`. The outparam `p` is meant to be 15 limbs in size, i.e., uint64_t[15]."] val mk_base_point: p:P.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ P.point_inv h1 p /\ P.point_eval h1 p == S.g) let mk_base_point p = P.make_g p [@@ Comment "Write `-p` in `out` (point negation). The argument `p` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p` and `out` are either disjoint or equal"] val point_negate (p out:P.point) : Stack unit (requires fun h -> live h out /\ live h p /\ eq_or_disjoint out p /\ P.point_inv h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.point_negate (P.point_eval h0 p)) let point_negate p out = P.point_negate out p [@@ Comment "Write `p + q` in `out` (point addition). The arguments `p`, `q` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p`, `q`, and `out` are either pairwise disjoint or equal"] val point_add (p q out:P.point) : Stack unit (requires fun h -> live h out /\ live h p /\ live h q /\ eq_or_disjoint p out /\ eq_or_disjoint q out /\ eq_or_disjoint p q /\ P.point_inv h p /\ P.point_inv h q) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.point_add (P.point_eval h0 p) (P.point_eval h0 q))
false
false
Hacl.EC.K256.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val point_add (p q out:P.point) : Stack unit (requires fun h -> live h out /\ live h p /\ live h q /\ eq_or_disjoint p out /\ eq_or_disjoint q out /\ eq_or_disjoint p q /\ P.point_inv h p /\ P.point_inv h q) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.point_add (P.point_eval h0 p) (P.point_eval h0 q))
[]
Hacl.EC.K256.point_add
{ "file_name": "code/k256/Hacl.EC.K256.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: Hacl.Impl.K256.Point.point -> q: Hacl.Impl.K256.Point.point -> out: Hacl.Impl.K256.Point.point -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 22, "end_line": 285, "start_col": 2, "start_line": 285 }
FStar.HyperStack.ST.Stack
val felem_load: b:lbuffer uint8 32ul -> out:F.felem -> Stack unit (requires fun h -> live h b /\ live h out /\ disjoint b out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == BSeq.nat_from_bytes_be (as_seq h0 b) % S.prime)
[ { "abbrev": true, "full_module": "Hacl.Spec.K256.Field52.Lemmas", "short_module": "BL" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointMul", "short_module": "PM" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointDouble", "short_module": "PD" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointAdd", "short_module": "PA" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Point", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Finv", "short_module": "FI" }, { "abbrev": true, "full_module": "Hacl.K256.Scalar", "short_module": "Q" }, { "abbrev": true, "full_module": "Hacl.K256.Field", "short_module": "F" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let felem_load b out = F.load_felem out b
val felem_load: b:lbuffer uint8 32ul -> out:F.felem -> Stack unit (requires fun h -> live h b /\ live h out /\ disjoint b out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == BSeq.nat_from_bytes_be (as_seq h0 b) % S.prime) let felem_load b out =
true
null
false
F.load_felem out b
{ "checked_file": "Hacl.EC.K256.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Field52.Lemmas.fsti.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.Field.fsti.checked", "Hacl.Impl.K256.PointMul.fsti.checked", "Hacl.Impl.K256.PointDouble.fst.checked", "Hacl.Impl.K256.PointAdd.fst.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Finv.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.K256.fst" }
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Hacl.K256.Field.felem", "Hacl.K256.Field.load_felem", "Prims.unit" ]
[]
module Hacl.EC.K256 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module BSeq = Lib.ByteSequence module S = Spec.K256 module F = Hacl.K256.Field module Q = Hacl.K256.Scalar module FI = Hacl.Impl.K256.Finv module P = Hacl.Impl.K256.Point module PA = Hacl.Impl.K256.PointAdd module PD = Hacl.Impl.K256.PointDouble module PM = Hacl.Impl.K256.PointMul module BL = Hacl.Spec.K256.Field52.Lemmas #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^256 - 0x1000003D1. This is a 64-bit optimized version, where a field element in radix-2^{52} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.zero) let mk_felem_zero f = Math.Lemmas.small_mod S.zero S.prime; F.set_zero f [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.one) let mk_felem_one f = Math.Lemmas.small_mod S.one S.prime; F.set_one f [@@ Comment "Write `a + b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_add (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fadd (F.feval h0 a) (F.feval h0 b)) let felem_add a b out = let h0 = ST.get () in BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b); F.fadd out a b; let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (2,2,2,2,4)); BL.normalize_weak5_lemma (2,2,2,2,4) (F.as_felem5 h1 out); F.fnormalize_weak out out [@@ Comment "Write `a - b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_sub (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fsub (F.feval h0 a) (F.feval h0 b)) let felem_sub a b out = let h0 = ST.get () in BL.fsub5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b) (u64 2); F.fsub out a b (u64 2); let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (5,5,5,5,6)); BL.normalize_weak5_lemma (5,5,5,5,6) (F.as_felem5 h1 out); F.fnormalize_weak out out [@@ Comment "Write `a * b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_mul (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 b)) let felem_mul a b out = F.fmul out a b [@@ Comment "Write `a * a mod p` in `out`. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are either disjoint or equal"] val felem_sqr (a out:F.felem) : Stack unit (requires fun h -> live h a /\ live h out /\ eq_or_disjoint out a /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 a)) let felem_sqr a out = F.fsqr out a [@@ Comment "Write `a ^ (p - 2) mod p` in `out`. The function computes modular multiplicative inverse if `a` <> zero. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_inv (a out:F.felem) : Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.finv (F.feval h0 a)) let felem_inv a out = FI.finv out a [@@ Comment "Load a bid-endian field element from memory. The argument `b` points to 32 bytes of valid memory, i.e., uint8_t[32]. The outparam `out` points to a field element of 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `b` and `out` are disjoint"] val felem_load: b:lbuffer uint8 32ul -> out:F.felem -> Stack unit (requires fun h -> live h b /\ live h out /\ disjoint b out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == BSeq.nat_from_bytes_be (as_seq h0 b) % S.prime)
false
false
Hacl.EC.K256.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val felem_load: b:lbuffer uint8 32ul -> out:F.felem -> Stack unit (requires fun h -> live h b /\ live h out /\ disjoint b out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == BSeq.nat_from_bytes_be (as_seq h0 b) % S.prime)
[]
Hacl.EC.K256.felem_load
{ "file_name": "code/k256/Hacl.EC.K256.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> out: Hacl.K256.Field.felem -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 20, "end_line": 189, "start_col": 2, "start_line": 189 }
FStar.HyperStack.ST.Stack
val point_load: b:lbuffer uint8 64ul -> out:P.point -> Stack unit (requires fun h -> live h out /\ live h b /\ disjoint b out /\ S.point_inv_bytes (as_seq h b)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.load_point_nocheck (as_seq h0 b))
[ { "abbrev": true, "full_module": "Hacl.Spec.K256.Field52.Lemmas", "short_module": "BL" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointMul", "short_module": "PM" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointDouble", "short_module": "PD" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointAdd", "short_module": "PA" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Point", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Finv", "short_module": "FI" }, { "abbrev": true, "full_module": "Hacl.K256.Scalar", "short_module": "Q" }, { "abbrev": true, "full_module": "Hacl.K256.Field", "short_module": "F" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let point_load b out = P.load_point_nocheck out b
val point_load: b:lbuffer uint8 64ul -> out:P.point -> Stack unit (requires fun h -> live h out /\ live h b /\ disjoint b out /\ S.point_inv_bytes (as_seq h b)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.load_point_nocheck (as_seq h0 b)) let point_load b out =
true
null
false
P.load_point_nocheck out b
{ "checked_file": "Hacl.EC.K256.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Field52.Lemmas.fsti.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.Field.fsti.checked", "Hacl.Impl.K256.PointMul.fsti.checked", "Hacl.Impl.K256.PointDouble.fst.checked", "Hacl.Impl.K256.PointAdd.fst.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Finv.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.K256.fst" }
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Hacl.Impl.K256.Point.point", "Hacl.Impl.K256.Point.load_point_nocheck", "Prims.unit" ]
[]
module Hacl.EC.K256 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module BSeq = Lib.ByteSequence module S = Spec.K256 module F = Hacl.K256.Field module Q = Hacl.K256.Scalar module FI = Hacl.Impl.K256.Finv module P = Hacl.Impl.K256.Point module PA = Hacl.Impl.K256.PointAdd module PD = Hacl.Impl.K256.PointDouble module PM = Hacl.Impl.K256.PointMul module BL = Hacl.Spec.K256.Field52.Lemmas #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^256 - 0x1000003D1. This is a 64-bit optimized version, where a field element in radix-2^{52} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.zero) let mk_felem_zero f = Math.Lemmas.small_mod S.zero S.prime; F.set_zero f [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.one) let mk_felem_one f = Math.Lemmas.small_mod S.one S.prime; F.set_one f [@@ Comment "Write `a + b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_add (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fadd (F.feval h0 a) (F.feval h0 b)) let felem_add a b out = let h0 = ST.get () in BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b); F.fadd out a b; let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (2,2,2,2,4)); BL.normalize_weak5_lemma (2,2,2,2,4) (F.as_felem5 h1 out); F.fnormalize_weak out out [@@ Comment "Write `a - b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_sub (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fsub (F.feval h0 a) (F.feval h0 b)) let felem_sub a b out = let h0 = ST.get () in BL.fsub5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b) (u64 2); F.fsub out a b (u64 2); let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (5,5,5,5,6)); BL.normalize_weak5_lemma (5,5,5,5,6) (F.as_felem5 h1 out); F.fnormalize_weak out out [@@ Comment "Write `a * b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_mul (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 b)) let felem_mul a b out = F.fmul out a b [@@ Comment "Write `a * a mod p` in `out`. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are either disjoint or equal"] val felem_sqr (a out:F.felem) : Stack unit (requires fun h -> live h a /\ live h out /\ eq_or_disjoint out a /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 a)) let felem_sqr a out = F.fsqr out a [@@ Comment "Write `a ^ (p - 2) mod p` in `out`. The function computes modular multiplicative inverse if `a` <> zero. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_inv (a out:F.felem) : Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.finv (F.feval h0 a)) let felem_inv a out = FI.finv out a [@@ Comment "Load a bid-endian field element from memory. The argument `b` points to 32 bytes of valid memory, i.e., uint8_t[32]. The outparam `out` points to a field element of 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `b` and `out` are disjoint"] val felem_load: b:lbuffer uint8 32ul -> out:F.felem -> Stack unit (requires fun h -> live h b /\ live h out /\ disjoint b out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == BSeq.nat_from_bytes_be (as_seq h0 b) % S.prime) let felem_load b out = F.load_felem out b [@@ Comment "Serialize a field element into big-endian memory. The argument `a` points to a field element of 5 limbs in size, i.e., uint64_t[5]. The outparam `out` points to 32 bytes of valid memory, i.e., uint8_t[32]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_store: a:F.felem -> out:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == BSeq.nat_to_bytes_be 32 (F.feval h0 a)) let felem_store a out = push_frame (); let tmp = F.create_felem () in let h0 = ST.get () in BL.normalize5_lemma (1,1,1,1,2) (F.as_felem5 h0 a); F.fnormalize tmp a; F.store_felem out tmp; pop_frame () [@@ CPrologue "/******************************************************************************* Verified group operations for the secp256k1 curve of the form y^2 = x^3 + 7. This is a 64-bit optimized version, where a group element in projective coordinates is represented as an array of 15 unsigned 64-bit integers, i.e., uint64_t[15]. *******************************************************************************/\n"; Comment "Write the point at infinity (additive identity) in `p`. The outparam `p` is meant to be 15 limbs in size, i.e., uint64_t[15]."] val mk_point_at_inf: p:P.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ P.point_inv h1 p /\ S.to_aff_point (P.point_eval h1 p) == S.aff_point_at_inf) let mk_point_at_inf p = P.make_point_at_inf p [@@ Comment "Write the base point (generator) in `p`. The outparam `p` is meant to be 15 limbs in size, i.e., uint64_t[15]."] val mk_base_point: p:P.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ P.point_inv h1 p /\ P.point_eval h1 p == S.g) let mk_base_point p = P.make_g p [@@ Comment "Write `-p` in `out` (point negation). The argument `p` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p` and `out` are either disjoint or equal"] val point_negate (p out:P.point) : Stack unit (requires fun h -> live h out /\ live h p /\ eq_or_disjoint out p /\ P.point_inv h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.point_negate (P.point_eval h0 p)) let point_negate p out = P.point_negate out p [@@ Comment "Write `p + q` in `out` (point addition). The arguments `p`, `q` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p`, `q`, and `out` are either pairwise disjoint or equal"] val point_add (p q out:P.point) : Stack unit (requires fun h -> live h out /\ live h p /\ live h q /\ eq_or_disjoint p out /\ eq_or_disjoint q out /\ eq_or_disjoint p q /\ P.point_inv h p /\ P.point_inv h q) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.point_add (P.point_eval h0 p) (P.point_eval h0 q)) let point_add p q out = PA.point_add out p q [@@ Comment "Write `p + p` in `out` (point doubling). The argument `p` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p` and `out` are either disjoint or equal"] val point_double (p out:P.point) : Stack unit (requires fun h -> live h out /\ live h p /\ eq_or_disjoint p out /\ P.point_inv h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.point_double (P.point_eval h0 p)) let point_double p out = PD.point_double out p [@@ Comment "Write `[scalar]p` in `out` (point multiplication or scalar multiplication). The argument `p` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15]. The argument `scalar` is meant to be 32 bytes in size, i.e., uint8_t[32]. The function first loads a bid-endian scalar element from `scalar` and then computes a point multiplication. Before calling this function, the caller will need to ensure that the following precondition is observed. • `scalar`, `p`, and `out` are pairwise disjoint"] val point_mul: scalar:lbuffer uint8 32ul -> p:P.point -> out:P.point -> Stack unit (requires fun h -> live h scalar /\ live h p /\ live h out /\ disjoint out p /\ disjoint out scalar /\ disjoint p scalar /\ P.point_inv h p /\ BSeq.nat_from_bytes_be (as_seq h scalar) < S.q) // it's still safe to invoke this function with scalar >= S.q (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ S.to_aff_point (P.point_eval h1 out) == S.to_aff_point (S.point_mul (BSeq.nat_from_bytes_be (as_seq h0 scalar)) (P.point_eval h0 p))) let point_mul scalar p out = push_frame (); let scalar_q = Q.create_qelem () in Q.load_qelem scalar_q scalar; PM.point_mul out scalar_q p; pop_frame () [@@ Comment "Convert a point from projective coordinates to its raw form. The argument `p` points to a point of 15 limbs in size, i.e., uint64_t[15]. The outparam `out` points to 64 bytes of valid memory, i.e., uint8_t[64]. The function first converts a given point `p` from projective to affine coordinates and then writes [ `x`; `y` ] in `out`. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p` and `out` are disjoint."] val point_store: p:P.point -> out:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h out /\ live h p /\ disjoint p out /\ P.point_inv h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == S.point_store (P.point_eval h0 p)) let point_store p out = P.point_store out p [@@ Comment "Convert a point to projective coordinates from its raw form. The argument `b` points to 64 bytes of valid memory, i.e., uint8_t[64]. The outparam `out` points to a point of 15 limbs in size, i.e., uint64_t[15]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `b` is valid point, i.e., x < prime and y < prime and (x, y) is on the curve • `b` and `out` are disjoint."] val point_load: b:lbuffer uint8 64ul -> out:P.point -> Stack unit (requires fun h -> live h out /\ live h b /\ disjoint b out /\ S.point_inv_bytes (as_seq h b)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.load_point_nocheck (as_seq h0 b))
false
false
Hacl.EC.K256.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val point_load: b:lbuffer uint8 64ul -> out:P.point -> Stack unit (requires fun h -> live h out /\ live h b /\ disjoint b out /\ S.point_inv_bytes (as_seq h b)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.load_point_nocheck (as_seq h0 b))
[]
Hacl.EC.K256.point_load
{ "file_name": "code/k256/Hacl.EC.K256.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 64ul -> out: Hacl.Impl.K256.Point.point -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 28, "end_line": 376, "start_col": 2, "start_line": 376 }
FStar.HyperStack.ST.Stack
val point_store: p:P.point -> out:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h out /\ live h p /\ disjoint p out /\ P.point_inv h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == S.point_store (P.point_eval h0 p))
[ { "abbrev": true, "full_module": "Hacl.Spec.K256.Field52.Lemmas", "short_module": "BL" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointMul", "short_module": "PM" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointDouble", "short_module": "PD" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointAdd", "short_module": "PA" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Point", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Finv", "short_module": "FI" }, { "abbrev": true, "full_module": "Hacl.K256.Scalar", "short_module": "Q" }, { "abbrev": true, "full_module": "Hacl.K256.Field", "short_module": "F" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let point_store p out = P.point_store out p
val point_store: p:P.point -> out:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h out /\ live h p /\ disjoint p out /\ P.point_inv h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == S.point_store (P.point_eval h0 p)) let point_store p out =
true
null
false
P.point_store out p
{ "checked_file": "Hacl.EC.K256.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Field52.Lemmas.fsti.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.Field.fsti.checked", "Hacl.Impl.K256.PointMul.fsti.checked", "Hacl.Impl.K256.PointDouble.fst.checked", "Hacl.Impl.K256.PointAdd.fst.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Finv.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.K256.fst" }
[]
[ "Hacl.Impl.K256.Point.point", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Hacl.Impl.K256.Point.point_store", "Prims.unit" ]
[]
module Hacl.EC.K256 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module BSeq = Lib.ByteSequence module S = Spec.K256 module F = Hacl.K256.Field module Q = Hacl.K256.Scalar module FI = Hacl.Impl.K256.Finv module P = Hacl.Impl.K256.Point module PA = Hacl.Impl.K256.PointAdd module PD = Hacl.Impl.K256.PointDouble module PM = Hacl.Impl.K256.PointMul module BL = Hacl.Spec.K256.Field52.Lemmas #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^256 - 0x1000003D1. This is a 64-bit optimized version, where a field element in radix-2^{52} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.zero) let mk_felem_zero f = Math.Lemmas.small_mod S.zero S.prime; F.set_zero f [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.one) let mk_felem_one f = Math.Lemmas.small_mod S.one S.prime; F.set_one f [@@ Comment "Write `a + b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_add (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fadd (F.feval h0 a) (F.feval h0 b)) let felem_add a b out = let h0 = ST.get () in BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b); F.fadd out a b; let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (2,2,2,2,4)); BL.normalize_weak5_lemma (2,2,2,2,4) (F.as_felem5 h1 out); F.fnormalize_weak out out [@@ Comment "Write `a - b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_sub (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fsub (F.feval h0 a) (F.feval h0 b)) let felem_sub a b out = let h0 = ST.get () in BL.fsub5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b) (u64 2); F.fsub out a b (u64 2); let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (5,5,5,5,6)); BL.normalize_weak5_lemma (5,5,5,5,6) (F.as_felem5 h1 out); F.fnormalize_weak out out [@@ Comment "Write `a * b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_mul (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 b)) let felem_mul a b out = F.fmul out a b [@@ Comment "Write `a * a mod p` in `out`. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are either disjoint or equal"] val felem_sqr (a out:F.felem) : Stack unit (requires fun h -> live h a /\ live h out /\ eq_or_disjoint out a /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 a)) let felem_sqr a out = F.fsqr out a [@@ Comment "Write `a ^ (p - 2) mod p` in `out`. The function computes modular multiplicative inverse if `a` <> zero. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_inv (a out:F.felem) : Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.finv (F.feval h0 a)) let felem_inv a out = FI.finv out a [@@ Comment "Load a bid-endian field element from memory. The argument `b` points to 32 bytes of valid memory, i.e., uint8_t[32]. The outparam `out` points to a field element of 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `b` and `out` are disjoint"] val felem_load: b:lbuffer uint8 32ul -> out:F.felem -> Stack unit (requires fun h -> live h b /\ live h out /\ disjoint b out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == BSeq.nat_from_bytes_be (as_seq h0 b) % S.prime) let felem_load b out = F.load_felem out b [@@ Comment "Serialize a field element into big-endian memory. The argument `a` points to a field element of 5 limbs in size, i.e., uint64_t[5]. The outparam `out` points to 32 bytes of valid memory, i.e., uint8_t[32]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_store: a:F.felem -> out:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == BSeq.nat_to_bytes_be 32 (F.feval h0 a)) let felem_store a out = push_frame (); let tmp = F.create_felem () in let h0 = ST.get () in BL.normalize5_lemma (1,1,1,1,2) (F.as_felem5 h0 a); F.fnormalize tmp a; F.store_felem out tmp; pop_frame () [@@ CPrologue "/******************************************************************************* Verified group operations for the secp256k1 curve of the form y^2 = x^3 + 7. This is a 64-bit optimized version, where a group element in projective coordinates is represented as an array of 15 unsigned 64-bit integers, i.e., uint64_t[15]. *******************************************************************************/\n"; Comment "Write the point at infinity (additive identity) in `p`. The outparam `p` is meant to be 15 limbs in size, i.e., uint64_t[15]."] val mk_point_at_inf: p:P.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ P.point_inv h1 p /\ S.to_aff_point (P.point_eval h1 p) == S.aff_point_at_inf) let mk_point_at_inf p = P.make_point_at_inf p [@@ Comment "Write the base point (generator) in `p`. The outparam `p` is meant to be 15 limbs in size, i.e., uint64_t[15]."] val mk_base_point: p:P.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ P.point_inv h1 p /\ P.point_eval h1 p == S.g) let mk_base_point p = P.make_g p [@@ Comment "Write `-p` in `out` (point negation). The argument `p` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p` and `out` are either disjoint or equal"] val point_negate (p out:P.point) : Stack unit (requires fun h -> live h out /\ live h p /\ eq_or_disjoint out p /\ P.point_inv h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.point_negate (P.point_eval h0 p)) let point_negate p out = P.point_negate out p [@@ Comment "Write `p + q` in `out` (point addition). The arguments `p`, `q` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p`, `q`, and `out` are either pairwise disjoint or equal"] val point_add (p q out:P.point) : Stack unit (requires fun h -> live h out /\ live h p /\ live h q /\ eq_or_disjoint p out /\ eq_or_disjoint q out /\ eq_or_disjoint p q /\ P.point_inv h p /\ P.point_inv h q) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.point_add (P.point_eval h0 p) (P.point_eval h0 q)) let point_add p q out = PA.point_add out p q [@@ Comment "Write `p + p` in `out` (point doubling). The argument `p` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p` and `out` are either disjoint or equal"] val point_double (p out:P.point) : Stack unit (requires fun h -> live h out /\ live h p /\ eq_or_disjoint p out /\ P.point_inv h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.point_double (P.point_eval h0 p)) let point_double p out = PD.point_double out p [@@ Comment "Write `[scalar]p` in `out` (point multiplication or scalar multiplication). The argument `p` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15]. The argument `scalar` is meant to be 32 bytes in size, i.e., uint8_t[32]. The function first loads a bid-endian scalar element from `scalar` and then computes a point multiplication. Before calling this function, the caller will need to ensure that the following precondition is observed. • `scalar`, `p`, and `out` are pairwise disjoint"] val point_mul: scalar:lbuffer uint8 32ul -> p:P.point -> out:P.point -> Stack unit (requires fun h -> live h scalar /\ live h p /\ live h out /\ disjoint out p /\ disjoint out scalar /\ disjoint p scalar /\ P.point_inv h p /\ BSeq.nat_from_bytes_be (as_seq h scalar) < S.q) // it's still safe to invoke this function with scalar >= S.q (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ S.to_aff_point (P.point_eval h1 out) == S.to_aff_point (S.point_mul (BSeq.nat_from_bytes_be (as_seq h0 scalar)) (P.point_eval h0 p))) let point_mul scalar p out = push_frame (); let scalar_q = Q.create_qelem () in Q.load_qelem scalar_q scalar; PM.point_mul out scalar_q p; pop_frame () [@@ Comment "Convert a point from projective coordinates to its raw form. The argument `p` points to a point of 15 limbs in size, i.e., uint64_t[15]. The outparam `out` points to 64 bytes of valid memory, i.e., uint8_t[64]. The function first converts a given point `p` from projective to affine coordinates and then writes [ `x`; `y` ] in `out`. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p` and `out` are disjoint."] val point_store: p:P.point -> out:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h out /\ live h p /\ disjoint p out /\ P.point_inv h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == S.point_store (P.point_eval h0 p))
false
false
Hacl.EC.K256.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val point_store: p:P.point -> out:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h out /\ live h p /\ disjoint p out /\ P.point_inv h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == S.point_store (P.point_eval h0 p))
[]
Hacl.EC.K256.point_store
{ "file_name": "code/k256/Hacl.EC.K256.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: Hacl.Impl.K256.Point.point -> out: Lib.Buffer.lbuffer Lib.IntTypes.uint8 64ul -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 21, "end_line": 355, "start_col": 2, "start_line": 355 }
FStar.HyperStack.ST.Stack
val felem_add (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fadd (F.feval h0 a) (F.feval h0 b))
[ { "abbrev": true, "full_module": "Hacl.Spec.K256.Field52.Lemmas", "short_module": "BL" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointMul", "short_module": "PM" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointDouble", "short_module": "PD" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointAdd", "short_module": "PA" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Point", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Finv", "short_module": "FI" }, { "abbrev": true, "full_module": "Hacl.K256.Scalar", "short_module": "Q" }, { "abbrev": true, "full_module": "Hacl.K256.Field", "short_module": "F" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let felem_add a b out = let h0 = ST.get () in BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b); F.fadd out a b; let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (2,2,2,2,4)); BL.normalize_weak5_lemma (2,2,2,2,4) (F.as_felem5 h1 out); F.fnormalize_weak out out
val felem_add (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fadd (F.feval h0 a) (F.feval h0 b)) let felem_add a b out =
true
null
false
let h0 = ST.get () in BL.fadd5_lemma (1, 1, 1, 1, 2) (1, 1, 1, 1, 2) (F.as_felem5 h0 a) (F.as_felem5 h0 b); F.fadd out a b; let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (2, 2, 2, 2, 4)); BL.normalize_weak5_lemma (2, 2, 2, 2, 4) (F.as_felem5 h1 out); F.fnormalize_weak out out
{ "checked_file": "Hacl.EC.K256.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Field52.Lemmas.fsti.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.Field.fsti.checked", "Hacl.Impl.K256.PointMul.fsti.checked", "Hacl.Impl.K256.PointDouble.fst.checked", "Hacl.Impl.K256.PointAdd.fst.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Finv.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.K256.fst" }
[]
[ "Hacl.K256.Field.felem", "Hacl.K256.Field.fnormalize_weak", "Prims.unit", "Hacl.Spec.K256.Field52.Lemmas.normalize_weak5_lemma", "FStar.Pervasives.Native.Mktuple5", "Prims.nat", "Hacl.K256.Field.as_felem5", "Prims._assert", "Hacl.Spec.K256.Field52.Definitions.felem_fits5", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.K256.Field.fadd", "Hacl.Spec.K256.Field52.Lemmas.fadd5_lemma" ]
[]
module Hacl.EC.K256 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module BSeq = Lib.ByteSequence module S = Spec.K256 module F = Hacl.K256.Field module Q = Hacl.K256.Scalar module FI = Hacl.Impl.K256.Finv module P = Hacl.Impl.K256.Point module PA = Hacl.Impl.K256.PointAdd module PD = Hacl.Impl.K256.PointDouble module PM = Hacl.Impl.K256.PointMul module BL = Hacl.Spec.K256.Field52.Lemmas #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^256 - 0x1000003D1. This is a 64-bit optimized version, where a field element in radix-2^{52} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.zero) let mk_felem_zero f = Math.Lemmas.small_mod S.zero S.prime; F.set_zero f [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.one) let mk_felem_one f = Math.Lemmas.small_mod S.one S.prime; F.set_one f [@@ Comment "Write `a + b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_add (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fadd (F.feval h0 a) (F.feval h0 b))
false
false
Hacl.EC.K256.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val felem_add (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fadd (F.feval h0 a) (F.feval h0 b))
[]
Hacl.EC.K256.felem_add
{ "file_name": "code/k256/Hacl.EC.K256.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.K256.Field.felem -> b: Hacl.K256.Field.felem -> out: Hacl.K256.Field.felem -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 27, "end_line": 85, "start_col": 23, "start_line": 78 }
FStar.HyperStack.ST.Stack
val felem_sqr (a out:F.felem) : Stack unit (requires fun h -> live h a /\ live h out /\ eq_or_disjoint out a /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 a))
[ { "abbrev": true, "full_module": "Hacl.Spec.K256.Field52.Lemmas", "short_module": "BL" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointMul", "short_module": "PM" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointDouble", "short_module": "PD" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointAdd", "short_module": "PA" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Point", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Finv", "short_module": "FI" }, { "abbrev": true, "full_module": "Hacl.K256.Scalar", "short_module": "Q" }, { "abbrev": true, "full_module": "Hacl.K256.Field", "short_module": "F" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let felem_sqr a out = F.fsqr out a
val felem_sqr (a out:F.felem) : Stack unit (requires fun h -> live h a /\ live h out /\ eq_or_disjoint out a /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 a)) let felem_sqr a out =
true
null
false
F.fsqr out a
{ "checked_file": "Hacl.EC.K256.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Field52.Lemmas.fsti.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.Field.fsti.checked", "Hacl.Impl.K256.PointMul.fsti.checked", "Hacl.Impl.K256.PointDouble.fst.checked", "Hacl.Impl.K256.PointAdd.fst.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Finv.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.K256.fst" }
[]
[ "Hacl.K256.Field.felem", "Hacl.K256.Field.fsqr", "Prims.unit" ]
[]
module Hacl.EC.K256 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module BSeq = Lib.ByteSequence module S = Spec.K256 module F = Hacl.K256.Field module Q = Hacl.K256.Scalar module FI = Hacl.Impl.K256.Finv module P = Hacl.Impl.K256.Point module PA = Hacl.Impl.K256.PointAdd module PD = Hacl.Impl.K256.PointDouble module PM = Hacl.Impl.K256.PointMul module BL = Hacl.Spec.K256.Field52.Lemmas #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^256 - 0x1000003D1. This is a 64-bit optimized version, where a field element in radix-2^{52} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.zero) let mk_felem_zero f = Math.Lemmas.small_mod S.zero S.prime; F.set_zero f [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.one) let mk_felem_one f = Math.Lemmas.small_mod S.one S.prime; F.set_one f [@@ Comment "Write `a + b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_add (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fadd (F.feval h0 a) (F.feval h0 b)) let felem_add a b out = let h0 = ST.get () in BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b); F.fadd out a b; let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (2,2,2,2,4)); BL.normalize_weak5_lemma (2,2,2,2,4) (F.as_felem5 h1 out); F.fnormalize_weak out out [@@ Comment "Write `a - b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_sub (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fsub (F.feval h0 a) (F.feval h0 b)) let felem_sub a b out = let h0 = ST.get () in BL.fsub5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b) (u64 2); F.fsub out a b (u64 2); let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (5,5,5,5,6)); BL.normalize_weak5_lemma (5,5,5,5,6) (F.as_felem5 h1 out); F.fnormalize_weak out out [@@ Comment "Write `a * b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_mul (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 b)) let felem_mul a b out = F.fmul out a b [@@ Comment "Write `a * a mod p` in `out`. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are either disjoint or equal"] val felem_sqr (a out:F.felem) : Stack unit (requires fun h -> live h a /\ live h out /\ eq_or_disjoint out a /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 a))
false
false
Hacl.EC.K256.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val felem_sqr (a out:F.felem) : Stack unit (requires fun h -> live h a /\ live h out /\ eq_or_disjoint out a /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 a))
[]
Hacl.EC.K256.felem_sqr
{ "file_name": "code/k256/Hacl.EC.K256.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.K256.Field.felem -> out: Hacl.K256.Field.felem -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 14, "end_line": 150, "start_col": 2, "start_line": 150 }
FStar.HyperStack.ST.Stack
val felem_mul (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 b))
[ { "abbrev": true, "full_module": "Hacl.Spec.K256.Field52.Lemmas", "short_module": "BL" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointMul", "short_module": "PM" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointDouble", "short_module": "PD" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointAdd", "short_module": "PA" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Point", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Finv", "short_module": "FI" }, { "abbrev": true, "full_module": "Hacl.K256.Scalar", "short_module": "Q" }, { "abbrev": true, "full_module": "Hacl.K256.Field", "short_module": "F" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let felem_mul a b out = F.fmul out a b
val felem_mul (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 b)) let felem_mul a b out =
true
null
false
F.fmul out a b
{ "checked_file": "Hacl.EC.K256.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Field52.Lemmas.fsti.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.Field.fsti.checked", "Hacl.Impl.K256.PointMul.fsti.checked", "Hacl.Impl.K256.PointDouble.fst.checked", "Hacl.Impl.K256.PointAdd.fst.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Finv.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.K256.fst" }
[]
[ "Hacl.K256.Field.felem", "Hacl.K256.Field.fmul", "Prims.unit" ]
[]
module Hacl.EC.K256 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module BSeq = Lib.ByteSequence module S = Spec.K256 module F = Hacl.K256.Field module Q = Hacl.K256.Scalar module FI = Hacl.Impl.K256.Finv module P = Hacl.Impl.K256.Point module PA = Hacl.Impl.K256.PointAdd module PD = Hacl.Impl.K256.PointDouble module PM = Hacl.Impl.K256.PointMul module BL = Hacl.Spec.K256.Field52.Lemmas #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^256 - 0x1000003D1. This is a 64-bit optimized version, where a field element in radix-2^{52} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.zero) let mk_felem_zero f = Math.Lemmas.small_mod S.zero S.prime; F.set_zero f [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.one) let mk_felem_one f = Math.Lemmas.small_mod S.one S.prime; F.set_one f [@@ Comment "Write `a + b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_add (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fadd (F.feval h0 a) (F.feval h0 b)) let felem_add a b out = let h0 = ST.get () in BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b); F.fadd out a b; let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (2,2,2,2,4)); BL.normalize_weak5_lemma (2,2,2,2,4) (F.as_felem5 h1 out); F.fnormalize_weak out out [@@ Comment "Write `a - b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_sub (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fsub (F.feval h0 a) (F.feval h0 b)) let felem_sub a b out = let h0 = ST.get () in BL.fsub5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b) (u64 2); F.fsub out a b (u64 2); let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (5,5,5,5,6)); BL.normalize_weak5_lemma (5,5,5,5,6) (F.as_felem5 h1 out); F.fnormalize_weak out out [@@ Comment "Write `a * b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_mul (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 b))
false
false
Hacl.EC.K256.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val felem_mul (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 b))
[]
Hacl.EC.K256.felem_mul
{ "file_name": "code/k256/Hacl.EC.K256.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.K256.Field.felem -> b: Hacl.K256.Field.felem -> out: Hacl.K256.Field.felem -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 16, "end_line": 131, "start_col": 2, "start_line": 131 }
FStar.HyperStack.ST.Stack
val felem_sub (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fsub (F.feval h0 a) (F.feval h0 b))
[ { "abbrev": true, "full_module": "Hacl.Spec.K256.Field52.Lemmas", "short_module": "BL" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointMul", "short_module": "PM" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointDouble", "short_module": "PD" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointAdd", "short_module": "PA" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Point", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Finv", "short_module": "FI" }, { "abbrev": true, "full_module": "Hacl.K256.Scalar", "short_module": "Q" }, { "abbrev": true, "full_module": "Hacl.K256.Field", "short_module": "F" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let felem_sub a b out = let h0 = ST.get () in BL.fsub5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b) (u64 2); F.fsub out a b (u64 2); let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (5,5,5,5,6)); BL.normalize_weak5_lemma (5,5,5,5,6) (F.as_felem5 h1 out); F.fnormalize_weak out out
val felem_sub (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fsub (F.feval h0 a) (F.feval h0 b)) let felem_sub a b out =
true
null
false
let h0 = ST.get () in BL.fsub5_lemma (1, 1, 1, 1, 2) (1, 1, 1, 1, 2) (F.as_felem5 h0 a) (F.as_felem5 h0 b) (u64 2); F.fsub out a b (u64 2); let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (5, 5, 5, 5, 6)); BL.normalize_weak5_lemma (5, 5, 5, 5, 6) (F.as_felem5 h1 out); F.fnormalize_weak out out
{ "checked_file": "Hacl.EC.K256.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Field52.Lemmas.fsti.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.Field.fsti.checked", "Hacl.Impl.K256.PointMul.fsti.checked", "Hacl.Impl.K256.PointDouble.fst.checked", "Hacl.Impl.K256.PointAdd.fst.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Finv.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.K256.fst" }
[]
[ "Hacl.K256.Field.felem", "Hacl.K256.Field.fnormalize_weak", "Prims.unit", "Hacl.Spec.K256.Field52.Lemmas.normalize_weak5_lemma", "FStar.Pervasives.Native.Mktuple5", "Prims.nat", "Hacl.K256.Field.as_felem5", "Prims._assert", "Hacl.Spec.K256.Field52.Definitions.felem_fits5", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.K256.Field.fsub", "Lib.IntTypes.u64", "Hacl.Spec.K256.Field52.Lemmas.fsub5_lemma" ]
[]
module Hacl.EC.K256 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module BSeq = Lib.ByteSequence module S = Spec.K256 module F = Hacl.K256.Field module Q = Hacl.K256.Scalar module FI = Hacl.Impl.K256.Finv module P = Hacl.Impl.K256.Point module PA = Hacl.Impl.K256.PointAdd module PD = Hacl.Impl.K256.PointDouble module PM = Hacl.Impl.K256.PointMul module BL = Hacl.Spec.K256.Field52.Lemmas #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^256 - 0x1000003D1. This is a 64-bit optimized version, where a field element in radix-2^{52} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.zero) let mk_felem_zero f = Math.Lemmas.small_mod S.zero S.prime; F.set_zero f [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.one) let mk_felem_one f = Math.Lemmas.small_mod S.one S.prime; F.set_one f [@@ Comment "Write `a + b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_add (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fadd (F.feval h0 a) (F.feval h0 b)) let felem_add a b out = let h0 = ST.get () in BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b); F.fadd out a b; let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (2,2,2,2,4)); BL.normalize_weak5_lemma (2,2,2,2,4) (F.as_felem5 h1 out); F.fnormalize_weak out out [@@ Comment "Write `a - b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_sub (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fsub (F.feval h0 a) (F.feval h0 b))
false
false
Hacl.EC.K256.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val felem_sub (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fsub (F.feval h0 a) (F.feval h0 b))
[]
Hacl.EC.K256.felem_sub
{ "file_name": "code/k256/Hacl.EC.K256.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.K256.Field.felem -> b: Hacl.K256.Field.felem -> out: Hacl.K256.Field.felem -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 27, "end_line": 111, "start_col": 23, "start_line": 104 }
FStar.HyperStack.ST.Stack
val is_point_valid: b:lbuffer uint8 64ul -> Stack bool (requires fun h -> live h b) (ensures fun h0 res h1 -> modifies0 h0 h1 /\ res <==> (S.point_inv_bytes (as_seq h0 b)))
[ { "abbrev": true, "full_module": "Hacl.Spec.K256.Field52.Lemmas", "short_module": "BL" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointMul", "short_module": "PM" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointDouble", "short_module": "PD" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointAdd", "short_module": "PA" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Point", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Finv", "short_module": "FI" }, { "abbrev": true, "full_module": "Hacl.K256.Scalar", "short_module": "Q" }, { "abbrev": true, "full_module": "Hacl.K256.Field", "short_module": "F" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let is_point_valid b = push_frame (); let p = P.create_aff_point () in let res = P.aff_point_load_vartime p b in pop_frame (); res
val is_point_valid: b:lbuffer uint8 64ul -> Stack bool (requires fun h -> live h b) (ensures fun h0 res h1 -> modifies0 h0 h1 /\ res <==> (S.point_inv_bytes (as_seq h0 b))) let is_point_valid b =
true
null
false
push_frame (); let p = P.create_aff_point () in let res = P.aff_point_load_vartime p b in pop_frame (); res
{ "checked_file": "Hacl.EC.K256.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Field52.Lemmas.fsti.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.Field.fsti.checked", "Hacl.Impl.K256.PointMul.fsti.checked", "Hacl.Impl.K256.PointDouble.fst.checked", "Hacl.Impl.K256.PointAdd.fst.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Finv.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.K256.fst" }
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Prims.bool", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Hacl.Impl.K256.Point.aff_point_load_vartime", "Hacl.Impl.K256.Point.aff_point", "Hacl.Impl.K256.Point.create_aff_point", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.EC.K256 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module BSeq = Lib.ByteSequence module S = Spec.K256 module F = Hacl.K256.Field module Q = Hacl.K256.Scalar module FI = Hacl.Impl.K256.Finv module P = Hacl.Impl.K256.Point module PA = Hacl.Impl.K256.PointAdd module PD = Hacl.Impl.K256.PointDouble module PM = Hacl.Impl.K256.PointMul module BL = Hacl.Spec.K256.Field52.Lemmas #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^256 - 0x1000003D1. This is a 64-bit optimized version, where a field element in radix-2^{52} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.zero) let mk_felem_zero f = Math.Lemmas.small_mod S.zero S.prime; F.set_zero f [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.one) let mk_felem_one f = Math.Lemmas.small_mod S.one S.prime; F.set_one f [@@ Comment "Write `a + b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_add (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fadd (F.feval h0 a) (F.feval h0 b)) let felem_add a b out = let h0 = ST.get () in BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b); F.fadd out a b; let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (2,2,2,2,4)); BL.normalize_weak5_lemma (2,2,2,2,4) (F.as_felem5 h1 out); F.fnormalize_weak out out [@@ Comment "Write `a - b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_sub (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fsub (F.feval h0 a) (F.feval h0 b)) let felem_sub a b out = let h0 = ST.get () in BL.fsub5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b) (u64 2); F.fsub out a b (u64 2); let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (5,5,5,5,6)); BL.normalize_weak5_lemma (5,5,5,5,6) (F.as_felem5 h1 out); F.fnormalize_weak out out [@@ Comment "Write `a * b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_mul (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 b)) let felem_mul a b out = F.fmul out a b [@@ Comment "Write `a * a mod p` in `out`. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are either disjoint or equal"] val felem_sqr (a out:F.felem) : Stack unit (requires fun h -> live h a /\ live h out /\ eq_or_disjoint out a /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 a)) let felem_sqr a out = F.fsqr out a [@@ Comment "Write `a ^ (p - 2) mod p` in `out`. The function computes modular multiplicative inverse if `a` <> zero. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_inv (a out:F.felem) : Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.finv (F.feval h0 a)) let felem_inv a out = FI.finv out a [@@ Comment "Load a bid-endian field element from memory. The argument `b` points to 32 bytes of valid memory, i.e., uint8_t[32]. The outparam `out` points to a field element of 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `b` and `out` are disjoint"] val felem_load: b:lbuffer uint8 32ul -> out:F.felem -> Stack unit (requires fun h -> live h b /\ live h out /\ disjoint b out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == BSeq.nat_from_bytes_be (as_seq h0 b) % S.prime) let felem_load b out = F.load_felem out b [@@ Comment "Serialize a field element into big-endian memory. The argument `a` points to a field element of 5 limbs in size, i.e., uint64_t[5]. The outparam `out` points to 32 bytes of valid memory, i.e., uint8_t[32]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_store: a:F.felem -> out:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == BSeq.nat_to_bytes_be 32 (F.feval h0 a)) let felem_store a out = push_frame (); let tmp = F.create_felem () in let h0 = ST.get () in BL.normalize5_lemma (1,1,1,1,2) (F.as_felem5 h0 a); F.fnormalize tmp a; F.store_felem out tmp; pop_frame () [@@ CPrologue "/******************************************************************************* Verified group operations for the secp256k1 curve of the form y^2 = x^3 + 7. This is a 64-bit optimized version, where a group element in projective coordinates is represented as an array of 15 unsigned 64-bit integers, i.e., uint64_t[15]. *******************************************************************************/\n"; Comment "Write the point at infinity (additive identity) in `p`. The outparam `p` is meant to be 15 limbs in size, i.e., uint64_t[15]."] val mk_point_at_inf: p:P.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ P.point_inv h1 p /\ S.to_aff_point (P.point_eval h1 p) == S.aff_point_at_inf) let mk_point_at_inf p = P.make_point_at_inf p [@@ Comment "Write the base point (generator) in `p`. The outparam `p` is meant to be 15 limbs in size, i.e., uint64_t[15]."] val mk_base_point: p:P.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ P.point_inv h1 p /\ P.point_eval h1 p == S.g) let mk_base_point p = P.make_g p [@@ Comment "Write `-p` in `out` (point negation). The argument `p` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p` and `out` are either disjoint or equal"] val point_negate (p out:P.point) : Stack unit (requires fun h -> live h out /\ live h p /\ eq_or_disjoint out p /\ P.point_inv h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.point_negate (P.point_eval h0 p)) let point_negate p out = P.point_negate out p [@@ Comment "Write `p + q` in `out` (point addition). The arguments `p`, `q` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p`, `q`, and `out` are either pairwise disjoint or equal"] val point_add (p q out:P.point) : Stack unit (requires fun h -> live h out /\ live h p /\ live h q /\ eq_or_disjoint p out /\ eq_or_disjoint q out /\ eq_or_disjoint p q /\ P.point_inv h p /\ P.point_inv h q) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.point_add (P.point_eval h0 p) (P.point_eval h0 q)) let point_add p q out = PA.point_add out p q [@@ Comment "Write `p + p` in `out` (point doubling). The argument `p` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p` and `out` are either disjoint or equal"] val point_double (p out:P.point) : Stack unit (requires fun h -> live h out /\ live h p /\ eq_or_disjoint p out /\ P.point_inv h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.point_double (P.point_eval h0 p)) let point_double p out = PD.point_double out p [@@ Comment "Write `[scalar]p` in `out` (point multiplication or scalar multiplication). The argument `p` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15]. The argument `scalar` is meant to be 32 bytes in size, i.e., uint8_t[32]. The function first loads a bid-endian scalar element from `scalar` and then computes a point multiplication. Before calling this function, the caller will need to ensure that the following precondition is observed. • `scalar`, `p`, and `out` are pairwise disjoint"] val point_mul: scalar:lbuffer uint8 32ul -> p:P.point -> out:P.point -> Stack unit (requires fun h -> live h scalar /\ live h p /\ live h out /\ disjoint out p /\ disjoint out scalar /\ disjoint p scalar /\ P.point_inv h p /\ BSeq.nat_from_bytes_be (as_seq h scalar) < S.q) // it's still safe to invoke this function with scalar >= S.q (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ S.to_aff_point (P.point_eval h1 out) == S.to_aff_point (S.point_mul (BSeq.nat_from_bytes_be (as_seq h0 scalar)) (P.point_eval h0 p))) let point_mul scalar p out = push_frame (); let scalar_q = Q.create_qelem () in Q.load_qelem scalar_q scalar; PM.point_mul out scalar_q p; pop_frame () [@@ Comment "Convert a point from projective coordinates to its raw form. The argument `p` points to a point of 15 limbs in size, i.e., uint64_t[15]. The outparam `out` points to 64 bytes of valid memory, i.e., uint8_t[64]. The function first converts a given point `p` from projective to affine coordinates and then writes [ `x`; `y` ] in `out`. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p` and `out` are disjoint."] val point_store: p:P.point -> out:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h out /\ live h p /\ disjoint p out /\ P.point_inv h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == S.point_store (P.point_eval h0 p)) let point_store p out = P.point_store out p [@@ Comment "Convert a point to projective coordinates from its raw form. The argument `b` points to 64 bytes of valid memory, i.e., uint8_t[64]. The outparam `out` points to a point of 15 limbs in size, i.e., uint64_t[15]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `b` is valid point, i.e., x < prime and y < prime and (x, y) is on the curve • `b` and `out` are disjoint."] val point_load: b:lbuffer uint8 64ul -> out:P.point -> Stack unit (requires fun h -> live h out /\ live h b /\ disjoint b out /\ S.point_inv_bytes (as_seq h b)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.load_point_nocheck (as_seq h0 b)) let point_load b out = P.load_point_nocheck out b [@@ Comment "Check whether a point is valid. The function returns `true` if a point is valid and `false` otherwise. The argument `b` points to 64 bytes of valid memory, i.e., uint8_t[64]. The point (x || y) is valid: • x < prime and y < prime • (x, y) is on the curve. This function is NOT constant-time."] val is_point_valid: b:lbuffer uint8 64ul -> Stack bool (requires fun h -> live h b) (ensures fun h0 res h1 -> modifies0 h0 h1 /\ res <==> (S.point_inv_bytes (as_seq h0 b)))
false
false
Hacl.EC.K256.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val is_point_valid: b:lbuffer uint8 64ul -> Stack bool (requires fun h -> live h b) (ensures fun h0 res h1 -> modifies0 h0 h1 /\ res <==> (S.point_inv_bytes (as_seq h0 b)))
[]
Hacl.EC.K256.is_point_valid
{ "file_name": "code/k256/Hacl.EC.K256.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 64ul -> FStar.HyperStack.ST.Stack Prims.bool
{ "end_col": 5, "end_line": 400, "start_col": 2, "start_line": 396 }
FStar.HyperStack.ST.Stack
val felem_store: a:F.felem -> out:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == BSeq.nat_to_bytes_be 32 (F.feval h0 a))
[ { "abbrev": true, "full_module": "Hacl.Spec.K256.Field52.Lemmas", "short_module": "BL" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointMul", "short_module": "PM" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointDouble", "short_module": "PD" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointAdd", "short_module": "PA" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Point", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Finv", "short_module": "FI" }, { "abbrev": true, "full_module": "Hacl.K256.Scalar", "short_module": "Q" }, { "abbrev": true, "full_module": "Hacl.K256.Field", "short_module": "F" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let felem_store a out = push_frame (); let tmp = F.create_felem () in let h0 = ST.get () in BL.normalize5_lemma (1,1,1,1,2) (F.as_felem5 h0 a); F.fnormalize tmp a; F.store_felem out tmp; pop_frame ()
val felem_store: a:F.felem -> out:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == BSeq.nat_to_bytes_be 32 (F.feval h0 a)) let felem_store a out =
true
null
false
push_frame (); let tmp = F.create_felem () in let h0 = ST.get () in BL.normalize5_lemma (1, 1, 1, 1, 2) (F.as_felem5 h0 a); F.fnormalize tmp a; F.store_felem out tmp; pop_frame ()
{ "checked_file": "Hacl.EC.K256.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Field52.Lemmas.fsti.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.Field.fsti.checked", "Hacl.Impl.K256.PointMul.fsti.checked", "Hacl.Impl.K256.PointDouble.fst.checked", "Hacl.Impl.K256.PointAdd.fst.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Finv.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.K256.fst" }
[]
[ "Hacl.K256.Field.felem", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.K256.Field.store_felem", "Hacl.K256.Field.fnormalize", "Hacl.Spec.K256.Field52.Lemmas.normalize5_lemma", "FStar.Pervasives.Native.Mktuple5", "Prims.nat", "Hacl.K256.Field.as_felem5", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.K256.Field.create_felem", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.EC.K256 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module BSeq = Lib.ByteSequence module S = Spec.K256 module F = Hacl.K256.Field module Q = Hacl.K256.Scalar module FI = Hacl.Impl.K256.Finv module P = Hacl.Impl.K256.Point module PA = Hacl.Impl.K256.PointAdd module PD = Hacl.Impl.K256.PointDouble module PM = Hacl.Impl.K256.PointMul module BL = Hacl.Spec.K256.Field52.Lemmas #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^256 - 0x1000003D1. This is a 64-bit optimized version, where a field element in radix-2^{52} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.zero) let mk_felem_zero f = Math.Lemmas.small_mod S.zero S.prime; F.set_zero f [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.one) let mk_felem_one f = Math.Lemmas.small_mod S.one S.prime; F.set_one f [@@ Comment "Write `a + b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_add (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fadd (F.feval h0 a) (F.feval h0 b)) let felem_add a b out = let h0 = ST.get () in BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b); F.fadd out a b; let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (2,2,2,2,4)); BL.normalize_weak5_lemma (2,2,2,2,4) (F.as_felem5 h1 out); F.fnormalize_weak out out [@@ Comment "Write `a - b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_sub (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fsub (F.feval h0 a) (F.feval h0 b)) let felem_sub a b out = let h0 = ST.get () in BL.fsub5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b) (u64 2); F.fsub out a b (u64 2); let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (5,5,5,5,6)); BL.normalize_weak5_lemma (5,5,5,5,6) (F.as_felem5 h1 out); F.fnormalize_weak out out [@@ Comment "Write `a * b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_mul (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 b)) let felem_mul a b out = F.fmul out a b [@@ Comment "Write `a * a mod p` in `out`. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are either disjoint or equal"] val felem_sqr (a out:F.felem) : Stack unit (requires fun h -> live h a /\ live h out /\ eq_or_disjoint out a /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 a)) let felem_sqr a out = F.fsqr out a [@@ Comment "Write `a ^ (p - 2) mod p` in `out`. The function computes modular multiplicative inverse if `a` <> zero. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_inv (a out:F.felem) : Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.finv (F.feval h0 a)) let felem_inv a out = FI.finv out a [@@ Comment "Load a bid-endian field element from memory. The argument `b` points to 32 bytes of valid memory, i.e., uint8_t[32]. The outparam `out` points to a field element of 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `b` and `out` are disjoint"] val felem_load: b:lbuffer uint8 32ul -> out:F.felem -> Stack unit (requires fun h -> live h b /\ live h out /\ disjoint b out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == BSeq.nat_from_bytes_be (as_seq h0 b) % S.prime) let felem_load b out = F.load_felem out b [@@ Comment "Serialize a field element into big-endian memory. The argument `a` points to a field element of 5 limbs in size, i.e., uint64_t[5]. The outparam `out` points to 32 bytes of valid memory, i.e., uint8_t[32]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_store: a:F.felem -> out:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == BSeq.nat_to_bytes_be 32 (F.feval h0 a))
false
false
Hacl.EC.K256.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val felem_store: a:F.felem -> out:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == BSeq.nat_to_bytes_be 32 (F.feval h0 a))
[]
Hacl.EC.K256.felem_store
{ "file_name": "code/k256/Hacl.EC.K256.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Hacl.K256.Field.felem -> out: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 14, "end_line": 214, "start_col": 2, "start_line": 208 }
FStar.HyperStack.ST.Stack
val point_mul: scalar:lbuffer uint8 32ul -> p:P.point -> out:P.point -> Stack unit (requires fun h -> live h scalar /\ live h p /\ live h out /\ disjoint out p /\ disjoint out scalar /\ disjoint p scalar /\ P.point_inv h p /\ BSeq.nat_from_bytes_be (as_seq h scalar) < S.q) // it's still safe to invoke this function with scalar >= S.q (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ S.to_aff_point (P.point_eval h1 out) == S.to_aff_point (S.point_mul (BSeq.nat_from_bytes_be (as_seq h0 scalar)) (P.point_eval h0 p)))
[ { "abbrev": true, "full_module": "Hacl.Spec.K256.Field52.Lemmas", "short_module": "BL" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointMul", "short_module": "PM" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointDouble", "short_module": "PD" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.PointAdd", "short_module": "PA" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Point", "short_module": "P" }, { "abbrev": true, "full_module": "Hacl.Impl.K256.Finv", "short_module": "FI" }, { "abbrev": true, "full_module": "Hacl.K256.Scalar", "short_module": "Q" }, { "abbrev": true, "full_module": "Hacl.K256.Field", "short_module": "F" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "Hacl.EC", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let point_mul scalar p out = push_frame (); let scalar_q = Q.create_qelem () in Q.load_qelem scalar_q scalar; PM.point_mul out scalar_q p; pop_frame ()
val point_mul: scalar:lbuffer uint8 32ul -> p:P.point -> out:P.point -> Stack unit (requires fun h -> live h scalar /\ live h p /\ live h out /\ disjoint out p /\ disjoint out scalar /\ disjoint p scalar /\ P.point_inv h p /\ BSeq.nat_from_bytes_be (as_seq h scalar) < S.q) // it's still safe to invoke this function with scalar >= S.q (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ S.to_aff_point (P.point_eval h1 out) == S.to_aff_point (S.point_mul (BSeq.nat_from_bytes_be (as_seq h0 scalar)) (P.point_eval h0 p))) let point_mul scalar p out =
true
null
false
push_frame (); let scalar_q = Q.create_qelem () in Q.load_qelem scalar_q scalar; PM.point_mul out scalar_q p; pop_frame ()
{ "checked_file": "Hacl.EC.K256.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.K256.Field52.Lemmas.fsti.checked", "Hacl.K256.Scalar.fsti.checked", "Hacl.K256.Field.fsti.checked", "Hacl.Impl.K256.PointMul.fsti.checked", "Hacl.Impl.K256.PointDouble.fst.checked", "Hacl.Impl.K256.PointAdd.fst.checked", "Hacl.Impl.K256.Point.fsti.checked", "Hacl.Impl.K256.Finv.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.EC.K256.fst" }
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Hacl.Impl.K256.Point.point", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Impl.K256.PointMul.point_mul", "Hacl.K256.Scalar.load_qelem", "Hacl.K256.Scalar.qelem", "Hacl.K256.Scalar.create_qelem", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.EC.K256 open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module BSeq = Lib.ByteSequence module S = Spec.K256 module F = Hacl.K256.Field module Q = Hacl.K256.Scalar module FI = Hacl.Impl.K256.Finv module P = Hacl.Impl.K256.Point module PA = Hacl.Impl.K256.PointAdd module PD = Hacl.Impl.K256.PointDouble module PM = Hacl.Impl.K256.PointMul module BL = Hacl.Spec.K256.Field52.Lemmas #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" [@@ CPrologue "/******************************************************************************* Verified field arithmetic modulo p = 2^256 - 0x1000003D1. This is a 64-bit optimized version, where a field element in radix-2^{52} is represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5]. *******************************************************************************/\n"; Comment "Write the additive identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_zero: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.zero) let mk_felem_zero f = Math.Lemmas.small_mod S.zero S.prime; F.set_zero f [@@ Comment "Write the multiplicative identity in `f`. The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."] val mk_felem_one: f:F.felem -> Stack unit (requires fun h -> live h f) (ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\ F.inv_lazy_reduced2 h1 f /\ F.feval h1 f == S.one) let mk_felem_one f = Math.Lemmas.small_mod S.one S.prime; F.set_one f [@@ Comment "Write `a + b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_add (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fadd (F.feval h0 a) (F.feval h0 b)) let felem_add a b out = let h0 = ST.get () in BL.fadd5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b); F.fadd out a b; let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (2,2,2,2,4)); BL.normalize_weak5_lemma (2,2,2,2,4) (F.as_felem5 h1 out); F.fnormalize_weak out out [@@ Comment "Write `a - b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_sub (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fsub (F.feval h0 a) (F.feval h0 b)) let felem_sub a b out = let h0 = ST.get () in BL.fsub5_lemma (1,1,1,1,2) (1,1,1,1,2) (F.as_felem5 h0 a) (F.as_felem5 h0 b) (u64 2); F.fsub out a b (u64 2); let h1 = ST.get () in assert (F.felem_fits5 (F.as_felem5 h1 out) (5,5,5,5,6)); BL.normalize_weak5_lemma (5,5,5,5,6) (F.as_felem5 h1 out); F.fnormalize_weak out out [@@ Comment "Write `a * b mod p` in `out`. The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a`, `b`, and `out` are either pairwise disjoint or equal"] val felem_mul (a b out:F.felem) : Stack unit (requires fun h -> live h a /\ live h b /\ live h out /\ eq_or_disjoint out a /\ eq_or_disjoint out b /\ eq_or_disjoint a b /\ F.inv_lazy_reduced2 h a /\ F.inv_lazy_reduced2 h b) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 b)) let felem_mul a b out = F.fmul out a b [@@ Comment "Write `a * a mod p` in `out`. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are either disjoint or equal"] val felem_sqr (a out:F.felem) : Stack unit (requires fun h -> live h a /\ live h out /\ eq_or_disjoint out a /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.fmul (F.feval h0 a) (F.feval h0 a)) let felem_sqr a out = F.fsqr out a [@@ Comment "Write `a ^ (p - 2) mod p` in `out`. The function computes modular multiplicative inverse if `a` <> zero. The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_inv (a out:F.felem) : Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == S.finv (F.feval h0 a)) let felem_inv a out = FI.finv out a [@@ Comment "Load a bid-endian field element from memory. The argument `b` points to 32 bytes of valid memory, i.e., uint8_t[32]. The outparam `out` points to a field element of 5 limbs in size, i.e., uint64_t[5]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `b` and `out` are disjoint"] val felem_load: b:lbuffer uint8 32ul -> out:F.felem -> Stack unit (requires fun h -> live h b /\ live h out /\ disjoint b out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F.inv_lazy_reduced2 h1 out /\ F.feval h1 out == BSeq.nat_from_bytes_be (as_seq h0 b) % S.prime) let felem_load b out = F.load_felem out b [@@ Comment "Serialize a field element into big-endian memory. The argument `a` points to a field element of 5 limbs in size, i.e., uint64_t[5]. The outparam `out` points to 32 bytes of valid memory, i.e., uint8_t[32]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `a` and `out` are disjoint"] val felem_store: a:F.felem -> out:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h a /\ live h out /\ disjoint a out /\ F.inv_lazy_reduced2 h a) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == BSeq.nat_to_bytes_be 32 (F.feval h0 a)) let felem_store a out = push_frame (); let tmp = F.create_felem () in let h0 = ST.get () in BL.normalize5_lemma (1,1,1,1,2) (F.as_felem5 h0 a); F.fnormalize tmp a; F.store_felem out tmp; pop_frame () [@@ CPrologue "/******************************************************************************* Verified group operations for the secp256k1 curve of the form y^2 = x^3 + 7. This is a 64-bit optimized version, where a group element in projective coordinates is represented as an array of 15 unsigned 64-bit integers, i.e., uint64_t[15]. *******************************************************************************/\n"; Comment "Write the point at infinity (additive identity) in `p`. The outparam `p` is meant to be 15 limbs in size, i.e., uint64_t[15]."] val mk_point_at_inf: p:P.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ P.point_inv h1 p /\ S.to_aff_point (P.point_eval h1 p) == S.aff_point_at_inf) let mk_point_at_inf p = P.make_point_at_inf p [@@ Comment "Write the base point (generator) in `p`. The outparam `p` is meant to be 15 limbs in size, i.e., uint64_t[15]."] val mk_base_point: p:P.point -> Stack unit (requires fun h -> live h p) (ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\ P.point_inv h1 p /\ P.point_eval h1 p == S.g) let mk_base_point p = P.make_g p [@@ Comment "Write `-p` in `out` (point negation). The argument `p` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p` and `out` are either disjoint or equal"] val point_negate (p out:P.point) : Stack unit (requires fun h -> live h out /\ live h p /\ eq_or_disjoint out p /\ P.point_inv h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.point_negate (P.point_eval h0 p)) let point_negate p out = P.point_negate out p [@@ Comment "Write `p + q` in `out` (point addition). The arguments `p`, `q` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p`, `q`, and `out` are either pairwise disjoint or equal"] val point_add (p q out:P.point) : Stack unit (requires fun h -> live h out /\ live h p /\ live h q /\ eq_or_disjoint p out /\ eq_or_disjoint q out /\ eq_or_disjoint p q /\ P.point_inv h p /\ P.point_inv h q) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.point_add (P.point_eval h0 p) (P.point_eval h0 q)) let point_add p q out = PA.point_add out p q [@@ Comment "Write `p + p` in `out` (point doubling). The argument `p` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15]. Before calling this function, the caller will need to ensure that the following precondition is observed. • `p` and `out` are either disjoint or equal"] val point_double (p out:P.point) : Stack unit (requires fun h -> live h out /\ live h p /\ eq_or_disjoint p out /\ P.point_inv h p) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ P.point_eval h1 out == S.point_double (P.point_eval h0 p)) let point_double p out = PD.point_double out p [@@ Comment "Write `[scalar]p` in `out` (point multiplication or scalar multiplication). The argument `p` and the outparam `out` are meant to be 15 limbs in size, i.e., uint64_t[15]. The argument `scalar` is meant to be 32 bytes in size, i.e., uint8_t[32]. The function first loads a bid-endian scalar element from `scalar` and then computes a point multiplication. Before calling this function, the caller will need to ensure that the following precondition is observed. • `scalar`, `p`, and `out` are pairwise disjoint"] val point_mul: scalar:lbuffer uint8 32ul -> p:P.point -> out:P.point -> Stack unit (requires fun h -> live h scalar /\ live h p /\ live h out /\ disjoint out p /\ disjoint out scalar /\ disjoint p scalar /\ P.point_inv h p /\ BSeq.nat_from_bytes_be (as_seq h scalar) < S.q) // it's still safe to invoke this function with scalar >= S.q (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ S.to_aff_point (P.point_eval h1 out) == S.to_aff_point (S.point_mul (BSeq.nat_from_bytes_be (as_seq h0 scalar)) (P.point_eval h0 p)))
false
false
Hacl.EC.K256.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val point_mul: scalar:lbuffer uint8 32ul -> p:P.point -> out:P.point -> Stack unit (requires fun h -> live h scalar /\ live h p /\ live h out /\ disjoint out p /\ disjoint out scalar /\ disjoint p scalar /\ P.point_inv h p /\ BSeq.nat_from_bytes_be (as_seq h scalar) < S.q) // it's still safe to invoke this function with scalar >= S.q (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ P.point_inv h1 out /\ S.to_aff_point (P.point_eval h1 out) == S.to_aff_point (S.point_mul (BSeq.nat_from_bytes_be (as_seq h0 scalar)) (P.point_eval h0 p)))
[]
Hacl.EC.K256.point_mul
{ "file_name": "code/k256/Hacl.EC.K256.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
scalar: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> p: Hacl.Impl.K256.Point.point -> out: Hacl.Impl.K256.Point.point -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 14, "end_line": 333, "start_col": 2, "start_line": 329 }
FStar.Pervasives.Lemma
val pow_eq: a:nat -> n:nat -> Lemma (Fermat.pow a n == Lib.NatMod.pow a n)
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.Math.Fermat", "short_module": "Fermat" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec pow_eq a n = if n = 0 then () else pow_eq a (n - 1)
val pow_eq: a:nat -> n:nat -> Lemma (Fermat.pow a n == Lib.NatMod.pow a n) let rec pow_eq a n =
false
null
true
if n = 0 then () else pow_eq a (n - 1)
{ "checked_file": "Hacl.Spec.Bignum.ModInv.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Math.Fermat.fsti.checked", "FStar.Math.Euclid.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Bignum.ModInv.fst" }
[ "lemma" ]
[ "Prims.nat", "Prims.op_Equality", "Prims.int", "Prims.bool", "Hacl.Spec.Bignum.ModInv.pow_eq", "Prims.op_Subtraction", "Prims.unit" ]
[]
module Hacl.Spec.Bignum.ModInv open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.LoopCombinators open Hacl.Spec.Bignum.Definitions open Hacl.Spec.Bignum module Fermat = FStar.Math.Fermat module Euclid = FStar.Math.Euclid module BE = Hacl.Spec.Bignum.Exponentiation module BM = Hacl.Spec.Bignum.Montgomery module BN = Hacl.Spec.Bignum #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" #push-options "--fuel 1" val pow_eq: a:nat -> n:nat -> Lemma (Fermat.pow a n == Lib.NatMod.pow a n)
false
false
Hacl.Spec.Bignum.ModInv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val pow_eq: a:nat -> n:nat -> Lemma (Fermat.pow a n == Lib.NatMod.pow a n)
[ "recursion" ]
Hacl.Spec.Bignum.ModInv.pow_eq
{ "file_name": "code/bignum/Hacl.Spec.Bignum.ModInv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Prims.nat -> n: Prims.nat -> FStar.Pervasives.Lemma (ensures FStar.Math.Fermat.pow a n == Lib.NatMod.pow a n)
{ "end_col": 23, "end_line": 25, "start_col": 2, "start_line": 24 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.Math.Fermat", "short_module": "Fermat" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_mod_inv_prime_pre (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) (a:lbignum t len) = bn_v n % 2 = 1 /\ 1 < bn_v n /\ 0 < bn_v a /\ bn_v a < bn_v n /\ Euclid.is_prime (bn_v n)
let bn_mod_inv_prime_pre (#t: limb_t) (#len: BN.bn_len t) (n a: lbignum t len) =
false
null
false
bn_v n % 2 = 1 /\ 1 < bn_v n /\ 0 < bn_v a /\ bn_v a < bn_v n /\ Euclid.is_prime (bn_v n)
{ "checked_file": "Hacl.Spec.Bignum.ModInv.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Math.Fermat.fsti.checked", "FStar.Math.Euclid.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Bignum.ModInv.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Hacl.Spec.Bignum.bn_len", "Hacl.Spec.Bignum.Definitions.lbignum", "Prims.l_and", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "Hacl.Spec.Bignum.Definitions.bn_v", "Prims.op_LessThan", "FStar.Math.Euclid.is_prime", "Prims.logical" ]
[]
module Hacl.Spec.Bignum.ModInv open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.LoopCombinators open Hacl.Spec.Bignum.Definitions open Hacl.Spec.Bignum module Fermat = FStar.Math.Fermat module Euclid = FStar.Math.Euclid module BE = Hacl.Spec.Bignum.Exponentiation module BM = Hacl.Spec.Bignum.Montgomery module BN = Hacl.Spec.Bignum #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" #push-options "--fuel 1" val pow_eq: a:nat -> n:nat -> Lemma (Fermat.pow a n == Lib.NatMod.pow a n) let rec pow_eq a n = if n = 0 then () else pow_eq a (n - 1) #pop-options val mod_inv_prime_lemma: n:nat{1 < n /\ Euclid.is_prime n} -> a:pos{a < n} -> Lemma (Lib.NatMod.pow_mod #n a (n - 2) * a % n = 1) let mod_inv_prime_lemma n a = Math.Lemmas.small_mod a n; assert (a == a % n); assert (a <> 0 /\ a % n <> 0); calc (==) { Lib.NatMod.pow_mod #n a (n - 2) * a % n; (==) { Lib.NatMod.lemma_pow_mod #n a (n - 2) } Lib.NatMod.pow a (n - 2) % n * a % n; (==) { Math.Lemmas.lemma_mod_mul_distr_l (Lib.NatMod.pow a (n - 2)) a n } Lib.NatMod.pow a (n - 2) * a % n; (==) { Lib.NatMod.lemma_pow1 a; Lib.NatMod.lemma_pow_add a (n - 2) 1 } Lib.NatMod.pow a (n - 1) % n; (==) { pow_eq a (n - 1) } Fermat.pow a (n - 1) % n; (==) { Fermat.fermat_alt n a } 1; } //pow2 nBits < bn_v n /\ Euclid.is_prime (bn_v n) are still needed to be checked val bn_check_mod_inv_prime: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> a:lbignum t len -> res:limb t{ let b = bn_v n % 2 = 1 && 1 < bn_v n && 0 < bn_v a && bn_v a < bn_v n in v res == (if b then v (ones t SEC) else v (zeros t SEC))} let bn_check_mod_inv_prime #t #len n a = let m0 = BM.bn_check_modulus n in let m1 = BN.bn_is_zero_mask a in BN.bn_is_zero_mask_lemma a; let m1' = lognot m1 in lognot_lemma m1; let m2 = BN.bn_lt_mask a n in BN.bn_lt_mask_lemma a n; logand_ones (m0 &. m1'); logand_zeros (m0 &. m1'); logand_ones m0; logand_zeros m0; m0 &. m1' &. m2 val bn_mod_inv_prime_n2: #t:limb_t -> #len:size_pos -> n:lbignum t len -> Pure (lbignum t len) (requires 1 < bn_v n) (ensures fun res -> bn_v res == bn_v n - 2) let bn_mod_inv_prime_n2 #t #len n = let c, n2 = bn_sub1 n (uint #t 2) in bn_sub1_lemma n (uint #t 2); assert (bn_v n2 - v c * pow2 (bits t * len) == bn_v n - 2); bn_eval_bound n2 len; bn_eval_bound n len; assert (v c = 0); assert (bn_v n2 == bn_v n - 2); n2 let bn_mod_inv_prime_pre (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) (a:lbignum t len)
false
false
Hacl.Spec.Bignum.ModInv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bn_mod_inv_prime_pre : n: Hacl.Spec.Bignum.Definitions.lbignum t len -> a: Hacl.Spec.Bignum.Definitions.lbignum t len -> Prims.logical
[]
Hacl.Spec.Bignum.ModInv.bn_mod_inv_prime_pre
{ "file_name": "code/bignum/Hacl.Spec.Bignum.ModInv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Hacl.Spec.Bignum.Definitions.lbignum t len -> a: Hacl.Spec.Bignum.Definitions.lbignum t len -> Prims.logical
{ "end_col": 26, "end_line": 105, "start_col": 2, "start_line": 103 }
Prims.Pure
val bn_mod_inv_prime_n2: #t:limb_t -> #len:size_pos -> n:lbignum t len -> Pure (lbignum t len) (requires 1 < bn_v n) (ensures fun res -> bn_v res == bn_v n - 2)
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.Math.Fermat", "short_module": "Fermat" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_mod_inv_prime_n2 #t #len n = let c, n2 = bn_sub1 n (uint #t 2) in bn_sub1_lemma n (uint #t 2); assert (bn_v n2 - v c * pow2 (bits t * len) == bn_v n - 2); bn_eval_bound n2 len; bn_eval_bound n len; assert (v c = 0); assert (bn_v n2 == bn_v n - 2); n2
val bn_mod_inv_prime_n2: #t:limb_t -> #len:size_pos -> n:lbignum t len -> Pure (lbignum t len) (requires 1 < bn_v n) (ensures fun res -> bn_v res == bn_v n - 2) let bn_mod_inv_prime_n2 #t #len n =
false
null
false
let c, n2 = bn_sub1 n (uint #t 2) in bn_sub1_lemma n (uint #t 2); assert (bn_v n2 - v c * pow2 (bits t * len) == bn_v n - 2); bn_eval_bound n2 len; bn_eval_bound n len; assert (v c = 0); assert (bn_v n2 == bn_v n - 2); n2
{ "checked_file": "Hacl.Spec.Bignum.ModInv.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Math.Fermat.fsti.checked", "FStar.Math.Euclid.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Bignum.ModInv.fst" }
[]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Lib.IntTypes.size_pos", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Base.carry", "Prims.unit", "Prims._assert", "Prims.eq2", "Prims.int", "Hacl.Spec.Bignum.Definitions.bn_v", "Prims.op_Subtraction", "Prims.b2t", "Prims.op_Equality", "Lib.IntTypes.v", "Lib.IntTypes.SEC", "Hacl.Spec.Bignum.Definitions.bn_eval_bound", "FStar.Mul.op_Star", "Prims.pow2", "Lib.IntTypes.bits", "Hacl.Spec.Bignum.bn_sub1_lemma", "Lib.IntTypes.uint", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Bignum.bn_sub1" ]
[]
module Hacl.Spec.Bignum.ModInv open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.LoopCombinators open Hacl.Spec.Bignum.Definitions open Hacl.Spec.Bignum module Fermat = FStar.Math.Fermat module Euclid = FStar.Math.Euclid module BE = Hacl.Spec.Bignum.Exponentiation module BM = Hacl.Spec.Bignum.Montgomery module BN = Hacl.Spec.Bignum #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" #push-options "--fuel 1" val pow_eq: a:nat -> n:nat -> Lemma (Fermat.pow a n == Lib.NatMod.pow a n) let rec pow_eq a n = if n = 0 then () else pow_eq a (n - 1) #pop-options val mod_inv_prime_lemma: n:nat{1 < n /\ Euclid.is_prime n} -> a:pos{a < n} -> Lemma (Lib.NatMod.pow_mod #n a (n - 2) * a % n = 1) let mod_inv_prime_lemma n a = Math.Lemmas.small_mod a n; assert (a == a % n); assert (a <> 0 /\ a % n <> 0); calc (==) { Lib.NatMod.pow_mod #n a (n - 2) * a % n; (==) { Lib.NatMod.lemma_pow_mod #n a (n - 2) } Lib.NatMod.pow a (n - 2) % n * a % n; (==) { Math.Lemmas.lemma_mod_mul_distr_l (Lib.NatMod.pow a (n - 2)) a n } Lib.NatMod.pow a (n - 2) * a % n; (==) { Lib.NatMod.lemma_pow1 a; Lib.NatMod.lemma_pow_add a (n - 2) 1 } Lib.NatMod.pow a (n - 1) % n; (==) { pow_eq a (n - 1) } Fermat.pow a (n - 1) % n; (==) { Fermat.fermat_alt n a } 1; } //pow2 nBits < bn_v n /\ Euclid.is_prime (bn_v n) are still needed to be checked val bn_check_mod_inv_prime: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> a:lbignum t len -> res:limb t{ let b = bn_v n % 2 = 1 && 1 < bn_v n && 0 < bn_v a && bn_v a < bn_v n in v res == (if b then v (ones t SEC) else v (zeros t SEC))} let bn_check_mod_inv_prime #t #len n a = let m0 = BM.bn_check_modulus n in let m1 = BN.bn_is_zero_mask a in BN.bn_is_zero_mask_lemma a; let m1' = lognot m1 in lognot_lemma m1; let m2 = BN.bn_lt_mask a n in BN.bn_lt_mask_lemma a n; logand_ones (m0 &. m1'); logand_zeros (m0 &. m1'); logand_ones m0; logand_zeros m0; m0 &. m1' &. m2 val bn_mod_inv_prime_n2: #t:limb_t -> #len:size_pos -> n:lbignum t len -> Pure (lbignum t len) (requires 1 < bn_v n) (ensures fun res -> bn_v res == bn_v n - 2)
false
false
Hacl.Spec.Bignum.ModInv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bn_mod_inv_prime_n2: #t:limb_t -> #len:size_pos -> n:lbignum t len -> Pure (lbignum t len) (requires 1 < bn_v n) (ensures fun res -> bn_v res == bn_v n - 2)
[]
Hacl.Spec.Bignum.ModInv.bn_mod_inv_prime_n2
{ "file_name": "code/bignum/Hacl.Spec.Bignum.ModInv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Hacl.Spec.Bignum.Definitions.lbignum t len -> Prims.Pure (Hacl.Spec.Bignum.Definitions.lbignum t len)
{ "end_col": 4, "end_line": 94, "start_col": 35, "start_line": 86 }
Prims.Tot
val bn_check_mod_inv_prime: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> a:lbignum t len -> res:limb t{ let b = bn_v n % 2 = 1 && 1 < bn_v n && 0 < bn_v a && bn_v a < bn_v n in v res == (if b then v (ones t SEC) else v (zeros t SEC))}
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.Math.Fermat", "short_module": "Fermat" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_check_mod_inv_prime #t #len n a = let m0 = BM.bn_check_modulus n in let m1 = BN.bn_is_zero_mask a in BN.bn_is_zero_mask_lemma a; let m1' = lognot m1 in lognot_lemma m1; let m2 = BN.bn_lt_mask a n in BN.bn_lt_mask_lemma a n; logand_ones (m0 &. m1'); logand_zeros (m0 &. m1'); logand_ones m0; logand_zeros m0; m0 &. m1' &. m2
val bn_check_mod_inv_prime: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> a:lbignum t len -> res:limb t{ let b = bn_v n % 2 = 1 && 1 < bn_v n && 0 < bn_v a && bn_v a < bn_v n in v res == (if b then v (ones t SEC) else v (zeros t SEC))} let bn_check_mod_inv_prime #t #len n a =
false
null
false
let m0 = BM.bn_check_modulus n in let m1 = BN.bn_is_zero_mask a in BN.bn_is_zero_mask_lemma a; let m1' = lognot m1 in lognot_lemma m1; let m2 = BN.bn_lt_mask a n in BN.bn_lt_mask_lemma a n; logand_ones (m0 &. m1'); logand_zeros (m0 &. m1'); logand_ones m0; logand_zeros m0; m0 &. m1' &. m2
{ "checked_file": "Hacl.Spec.Bignum.ModInv.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Math.Fermat.fsti.checked", "FStar.Math.Euclid.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Bignum.ModInv.fst" }
[ "total" ]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Hacl.Spec.Bignum.bn_len", "Hacl.Spec.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Amp_Dot", "Lib.IntTypes.SEC", "Prims.unit", "Lib.IntTypes.logand_zeros", "Lib.IntTypes.logand_ones", "Hacl.Spec.Bignum.bn_lt_mask_lemma", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.bn_lt_mask", "Lib.IntTypes.lognot_lemma", "Lib.IntTypes.int_t", "Lib.IntTypes.lognot", "Hacl.Spec.Bignum.bn_is_zero_mask_lemma", "Hacl.Spec.Bignum.bn_is_zero_mask", "Prims.eq2", "Prims.int", "Lib.IntTypes.range", "Lib.IntTypes.v", "Prims.op_AmpAmp", "Prims.op_Equality", "Prims.op_Modulus", "Hacl.Spec.Bignum.Definitions.bn_v", "Prims.op_LessThan", "Lib.IntTypes.ones", "Prims.bool", "Lib.IntTypes.zeros", "Hacl.Spec.Bignum.Montgomery.bn_check_modulus", "Lib.IntTypes.range_t" ]
[]
module Hacl.Spec.Bignum.ModInv open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.LoopCombinators open Hacl.Spec.Bignum.Definitions open Hacl.Spec.Bignum module Fermat = FStar.Math.Fermat module Euclid = FStar.Math.Euclid module BE = Hacl.Spec.Bignum.Exponentiation module BM = Hacl.Spec.Bignum.Montgomery module BN = Hacl.Spec.Bignum #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" #push-options "--fuel 1" val pow_eq: a:nat -> n:nat -> Lemma (Fermat.pow a n == Lib.NatMod.pow a n) let rec pow_eq a n = if n = 0 then () else pow_eq a (n - 1) #pop-options val mod_inv_prime_lemma: n:nat{1 < n /\ Euclid.is_prime n} -> a:pos{a < n} -> Lemma (Lib.NatMod.pow_mod #n a (n - 2) * a % n = 1) let mod_inv_prime_lemma n a = Math.Lemmas.small_mod a n; assert (a == a % n); assert (a <> 0 /\ a % n <> 0); calc (==) { Lib.NatMod.pow_mod #n a (n - 2) * a % n; (==) { Lib.NatMod.lemma_pow_mod #n a (n - 2) } Lib.NatMod.pow a (n - 2) % n * a % n; (==) { Math.Lemmas.lemma_mod_mul_distr_l (Lib.NatMod.pow a (n - 2)) a n } Lib.NatMod.pow a (n - 2) * a % n; (==) { Lib.NatMod.lemma_pow1 a; Lib.NatMod.lemma_pow_add a (n - 2) 1 } Lib.NatMod.pow a (n - 1) % n; (==) { pow_eq a (n - 1) } Fermat.pow a (n - 1) % n; (==) { Fermat.fermat_alt n a } 1; } //pow2 nBits < bn_v n /\ Euclid.is_prime (bn_v n) are still needed to be checked val bn_check_mod_inv_prime: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> a:lbignum t len -> res:limb t{ let b = bn_v n % 2 = 1 && 1 < bn_v n && 0 < bn_v a && bn_v a < bn_v n in v res == (if b then v (ones t SEC) else v (zeros t SEC))}
false
false
Hacl.Spec.Bignum.ModInv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bn_check_mod_inv_prime: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> a:lbignum t len -> res:limb t{ let b = bn_v n % 2 = 1 && 1 < bn_v n && 0 < bn_v a && bn_v a < bn_v n in v res == (if b then v (ones t SEC) else v (zeros t SEC))}
[]
Hacl.Spec.Bignum.ModInv.bn_check_mod_inv_prime
{ "file_name": "code/bignum/Hacl.Spec.Bignum.ModInv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Hacl.Spec.Bignum.Definitions.lbignum t len -> a: Hacl.Spec.Bignum.Definitions.lbignum t len -> res: Hacl.Spec.Bignum.Definitions.limb t { let b = Hacl.Spec.Bignum.Definitions.bn_v n % 2 = 1 && 1 < Hacl.Spec.Bignum.Definitions.bn_v n && 0 < Hacl.Spec.Bignum.Definitions.bn_v a && Hacl.Spec.Bignum.Definitions.bn_v a < Hacl.Spec.Bignum.Definitions.bn_v n in Lib.IntTypes.v res == (match b with | true -> Lib.IntTypes.v (Lib.IntTypes.ones t Lib.IntTypes.SEC) | _ -> Lib.IntTypes.v (Lib.IntTypes.zeros t Lib.IntTypes.SEC)) }
{ "end_col": 17, "end_line": 74, "start_col": 40, "start_line": 62 }
Prims.Pure
val bn_mod_inv_prime: #t:limb_t -> #len:BN.bn_len t -> nBits:size_nat -> n:lbignum t len -> a:lbignum t len -> Pure (lbignum t len) (requires bn_mod_inv_prime_pre n a /\ nBits / bits t < len /\ pow2 nBits < bn_v n) (ensures fun res -> bn_v res * bn_v a % bn_v n = 1)
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.Math.Fermat", "short_module": "Fermat" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_mod_inv_prime #t #len nBits n a = let r2, mu = BM.bn_mont_precomp nBits n in let res = bn_mod_inv_prime_precomp #t #len n mu r2 a in mod_inv_prime_lemma (bn_v n) (bn_v a); res
val bn_mod_inv_prime: #t:limb_t -> #len:BN.bn_len t -> nBits:size_nat -> n:lbignum t len -> a:lbignum t len -> Pure (lbignum t len) (requires bn_mod_inv_prime_pre n a /\ nBits / bits t < len /\ pow2 nBits < bn_v n) (ensures fun res -> bn_v res * bn_v a % bn_v n = 1) let bn_mod_inv_prime #t #len nBits n a =
false
null
false
let r2, mu = BM.bn_mont_precomp nBits n in let res = bn_mod_inv_prime_precomp #t #len n mu r2 a in mod_inv_prime_lemma (bn_v n) (bn_v a); res
{ "checked_file": "Hacl.Spec.Bignum.ModInv.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Math.Fermat.fsti.checked", "FStar.Math.Euclid.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Bignum.ModInv.fst" }
[]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Hacl.Spec.Bignum.bn_len", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Definitions.limb", "Prims.unit", "Hacl.Spec.Bignum.ModInv.mod_inv_prime_lemma", "Hacl.Spec.Bignum.Definitions.bn_v", "Hacl.Spec.Bignum.ModInv.bn_mod_inv_prime_precomp", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Bignum.Montgomery.bn_mont_precomp" ]
[]
module Hacl.Spec.Bignum.ModInv open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.LoopCombinators open Hacl.Spec.Bignum.Definitions open Hacl.Spec.Bignum module Fermat = FStar.Math.Fermat module Euclid = FStar.Math.Euclid module BE = Hacl.Spec.Bignum.Exponentiation module BM = Hacl.Spec.Bignum.Montgomery module BN = Hacl.Spec.Bignum #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" #push-options "--fuel 1" val pow_eq: a:nat -> n:nat -> Lemma (Fermat.pow a n == Lib.NatMod.pow a n) let rec pow_eq a n = if n = 0 then () else pow_eq a (n - 1) #pop-options val mod_inv_prime_lemma: n:nat{1 < n /\ Euclid.is_prime n} -> a:pos{a < n} -> Lemma (Lib.NatMod.pow_mod #n a (n - 2) * a % n = 1) let mod_inv_prime_lemma n a = Math.Lemmas.small_mod a n; assert (a == a % n); assert (a <> 0 /\ a % n <> 0); calc (==) { Lib.NatMod.pow_mod #n a (n - 2) * a % n; (==) { Lib.NatMod.lemma_pow_mod #n a (n - 2) } Lib.NatMod.pow a (n - 2) % n * a % n; (==) { Math.Lemmas.lemma_mod_mul_distr_l (Lib.NatMod.pow a (n - 2)) a n } Lib.NatMod.pow a (n - 2) * a % n; (==) { Lib.NatMod.lemma_pow1 a; Lib.NatMod.lemma_pow_add a (n - 2) 1 } Lib.NatMod.pow a (n - 1) % n; (==) { pow_eq a (n - 1) } Fermat.pow a (n - 1) % n; (==) { Fermat.fermat_alt n a } 1; } //pow2 nBits < bn_v n /\ Euclid.is_prime (bn_v n) are still needed to be checked val bn_check_mod_inv_prime: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> a:lbignum t len -> res:limb t{ let b = bn_v n % 2 = 1 && 1 < bn_v n && 0 < bn_v a && bn_v a < bn_v n in v res == (if b then v (ones t SEC) else v (zeros t SEC))} let bn_check_mod_inv_prime #t #len n a = let m0 = BM.bn_check_modulus n in let m1 = BN.bn_is_zero_mask a in BN.bn_is_zero_mask_lemma a; let m1' = lognot m1 in lognot_lemma m1; let m2 = BN.bn_lt_mask a n in BN.bn_lt_mask_lemma a n; logand_ones (m0 &. m1'); logand_zeros (m0 &. m1'); logand_ones m0; logand_zeros m0; m0 &. m1' &. m2 val bn_mod_inv_prime_n2: #t:limb_t -> #len:size_pos -> n:lbignum t len -> Pure (lbignum t len) (requires 1 < bn_v n) (ensures fun res -> bn_v res == bn_v n - 2) let bn_mod_inv_prime_n2 #t #len n = let c, n2 = bn_sub1 n (uint #t 2) in bn_sub1_lemma n (uint #t 2); assert (bn_v n2 - v c * pow2 (bits t * len) == bn_v n - 2); bn_eval_bound n2 len; bn_eval_bound n len; assert (v c = 0); assert (bn_v n2 == bn_v n - 2); n2 let bn_mod_inv_prime_pre (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) (a:lbignum t len) = bn_v n % 2 = 1 /\ 1 < bn_v n /\ 0 < bn_v a /\ bn_v a < bn_v n /\ Euclid.is_prime (bn_v n) val bn_mod_inv_prime_precomp: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t -> r2:lbignum t len -> a:lbignum t len -> Pure (lbignum t len) (requires bn_mod_inv_prime_pre n a /\ bn_v r2 == pow2 (2 * bits t * len) % bn_v n /\ (1 + bn_v n * v mu) % pow2 (bits t) == 0) (ensures fun res -> bn_v res * bn_v a % bn_v n = 1) let bn_mod_inv_prime_precomp #t #len n mu r2 a = let n2 = bn_mod_inv_prime_n2 n in bn_eval_bound n len; let res = BE.bn_mod_exp_vartime_precompr2 len n r2 a (bits t * len) n2 in assert (bn_v res == Lib.NatMod.pow_mod #(bn_v n) (bn_v a) (bn_v n2)); mod_inv_prime_lemma (bn_v n) (bn_v a); res val bn_mod_inv_prime: #t:limb_t -> #len:BN.bn_len t -> nBits:size_nat -> n:lbignum t len -> a:lbignum t len -> Pure (lbignum t len) (requires bn_mod_inv_prime_pre n a /\ nBits / bits t < len /\ pow2 nBits < bn_v n) (ensures fun res -> bn_v res * bn_v a % bn_v n = 1)
false
false
Hacl.Spec.Bignum.ModInv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bn_mod_inv_prime: #t:limb_t -> #len:BN.bn_len t -> nBits:size_nat -> n:lbignum t len -> a:lbignum t len -> Pure (lbignum t len) (requires bn_mod_inv_prime_pre n a /\ nBits / bits t < len /\ pow2 nBits < bn_v n) (ensures fun res -> bn_v res * bn_v a % bn_v n = 1)
[]
Hacl.Spec.Bignum.ModInv.bn_mod_inv_prime
{ "file_name": "code/bignum/Hacl.Spec.Bignum.ModInv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
nBits: Lib.IntTypes.size_nat -> n: Hacl.Spec.Bignum.Definitions.lbignum t len -> a: Hacl.Spec.Bignum.Definitions.lbignum t len -> Prims.Pure (Hacl.Spec.Bignum.Definitions.lbignum t len)
{ "end_col": 5, "end_line": 149, "start_col": 40, "start_line": 145 }
Prims.Pure
val bn_mod_inv_prime_precomp: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t -> r2:lbignum t len -> a:lbignum t len -> Pure (lbignum t len) (requires bn_mod_inv_prime_pre n a /\ bn_v r2 == pow2 (2 * bits t * len) % bn_v n /\ (1 + bn_v n * v mu) % pow2 (bits t) == 0) (ensures fun res -> bn_v res * bn_v a % bn_v n = 1)
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.Math.Fermat", "short_module": "Fermat" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_mod_inv_prime_precomp #t #len n mu r2 a = let n2 = bn_mod_inv_prime_n2 n in bn_eval_bound n len; let res = BE.bn_mod_exp_vartime_precompr2 len n r2 a (bits t * len) n2 in assert (bn_v res == Lib.NatMod.pow_mod #(bn_v n) (bn_v a) (bn_v n2)); mod_inv_prime_lemma (bn_v n) (bn_v a); res
val bn_mod_inv_prime_precomp: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t -> r2:lbignum t len -> a:lbignum t len -> Pure (lbignum t len) (requires bn_mod_inv_prime_pre n a /\ bn_v r2 == pow2 (2 * bits t * len) % bn_v n /\ (1 + bn_v n * v mu) % pow2 (bits t) == 0) (ensures fun res -> bn_v res * bn_v a % bn_v n = 1) let bn_mod_inv_prime_precomp #t #len n mu r2 a =
false
null
false
let n2 = bn_mod_inv_prime_n2 n in bn_eval_bound n len; let res = BE.bn_mod_exp_vartime_precompr2 len n r2 a (bits t * len) n2 in assert (bn_v res == Lib.NatMod.pow_mod #(bn_v n) (bn_v a) (bn_v n2)); mod_inv_prime_lemma (bn_v n) (bn_v a); res
{ "checked_file": "Hacl.Spec.Bignum.ModInv.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Math.Fermat.fsti.checked", "FStar.Math.Euclid.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Bignum.ModInv.fst" }
[]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Hacl.Spec.Bignum.bn_len", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Definitions.limb", "Prims.unit", "Hacl.Spec.Bignum.ModInv.mod_inv_prime_lemma", "Hacl.Spec.Bignum.Definitions.bn_v", "Prims._assert", "Prims.eq2", "Prims.nat", "Lib.NatMod.pow_mod", "Hacl.Spec.Bignum.Exponentiation.bn_mod_exp_vartime_precompr2", "FStar.Mul.op_Star", "Lib.IntTypes.bits", "Hacl.Spec.Bignum.Definitions.bn_eval_bound", "Hacl.Spec.Bignum.ModInv.bn_mod_inv_prime_n2" ]
[]
module Hacl.Spec.Bignum.ModInv open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.LoopCombinators open Hacl.Spec.Bignum.Definitions open Hacl.Spec.Bignum module Fermat = FStar.Math.Fermat module Euclid = FStar.Math.Euclid module BE = Hacl.Spec.Bignum.Exponentiation module BM = Hacl.Spec.Bignum.Montgomery module BN = Hacl.Spec.Bignum #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" #push-options "--fuel 1" val pow_eq: a:nat -> n:nat -> Lemma (Fermat.pow a n == Lib.NatMod.pow a n) let rec pow_eq a n = if n = 0 then () else pow_eq a (n - 1) #pop-options val mod_inv_prime_lemma: n:nat{1 < n /\ Euclid.is_prime n} -> a:pos{a < n} -> Lemma (Lib.NatMod.pow_mod #n a (n - 2) * a % n = 1) let mod_inv_prime_lemma n a = Math.Lemmas.small_mod a n; assert (a == a % n); assert (a <> 0 /\ a % n <> 0); calc (==) { Lib.NatMod.pow_mod #n a (n - 2) * a % n; (==) { Lib.NatMod.lemma_pow_mod #n a (n - 2) } Lib.NatMod.pow a (n - 2) % n * a % n; (==) { Math.Lemmas.lemma_mod_mul_distr_l (Lib.NatMod.pow a (n - 2)) a n } Lib.NatMod.pow a (n - 2) * a % n; (==) { Lib.NatMod.lemma_pow1 a; Lib.NatMod.lemma_pow_add a (n - 2) 1 } Lib.NatMod.pow a (n - 1) % n; (==) { pow_eq a (n - 1) } Fermat.pow a (n - 1) % n; (==) { Fermat.fermat_alt n a } 1; } //pow2 nBits < bn_v n /\ Euclid.is_prime (bn_v n) are still needed to be checked val bn_check_mod_inv_prime: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> a:lbignum t len -> res:limb t{ let b = bn_v n % 2 = 1 && 1 < bn_v n && 0 < bn_v a && bn_v a < bn_v n in v res == (if b then v (ones t SEC) else v (zeros t SEC))} let bn_check_mod_inv_prime #t #len n a = let m0 = BM.bn_check_modulus n in let m1 = BN.bn_is_zero_mask a in BN.bn_is_zero_mask_lemma a; let m1' = lognot m1 in lognot_lemma m1; let m2 = BN.bn_lt_mask a n in BN.bn_lt_mask_lemma a n; logand_ones (m0 &. m1'); logand_zeros (m0 &. m1'); logand_ones m0; logand_zeros m0; m0 &. m1' &. m2 val bn_mod_inv_prime_n2: #t:limb_t -> #len:size_pos -> n:lbignum t len -> Pure (lbignum t len) (requires 1 < bn_v n) (ensures fun res -> bn_v res == bn_v n - 2) let bn_mod_inv_prime_n2 #t #len n = let c, n2 = bn_sub1 n (uint #t 2) in bn_sub1_lemma n (uint #t 2); assert (bn_v n2 - v c * pow2 (bits t * len) == bn_v n - 2); bn_eval_bound n2 len; bn_eval_bound n len; assert (v c = 0); assert (bn_v n2 == bn_v n - 2); n2 let bn_mod_inv_prime_pre (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) (a:lbignum t len) = bn_v n % 2 = 1 /\ 1 < bn_v n /\ 0 < bn_v a /\ bn_v a < bn_v n /\ Euclid.is_prime (bn_v n) val bn_mod_inv_prime_precomp: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t -> r2:lbignum t len -> a:lbignum t len -> Pure (lbignum t len) (requires bn_mod_inv_prime_pre n a /\ bn_v r2 == pow2 (2 * bits t * len) % bn_v n /\ (1 + bn_v n * v mu) % pow2 (bits t) == 0) (ensures fun res -> bn_v res * bn_v a % bn_v n = 1)
false
false
Hacl.Spec.Bignum.ModInv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bn_mod_inv_prime_precomp: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t -> r2:lbignum t len -> a:lbignum t len -> Pure (lbignum t len) (requires bn_mod_inv_prime_pre n a /\ bn_v r2 == pow2 (2 * bits t * len) % bn_v n /\ (1 + bn_v n * v mu) % pow2 (bits t) == 0) (ensures fun res -> bn_v res * bn_v a % bn_v n = 1)
[]
Hacl.Spec.Bignum.ModInv.bn_mod_inv_prime_precomp
{ "file_name": "code/bignum/Hacl.Spec.Bignum.ModInv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Hacl.Spec.Bignum.Definitions.lbignum t len -> mu: Hacl.Spec.Bignum.Definitions.limb t -> r2: Hacl.Spec.Bignum.Definitions.lbignum t len -> a: Hacl.Spec.Bignum.Definitions.lbignum t len -> Prims.Pure (Hacl.Spec.Bignum.Definitions.lbignum t len)
{ "end_col": 5, "end_line": 129, "start_col": 48, "start_line": 123 }
FStar.Pervasives.Lemma
val mod_inv_prime_lemma: n:nat{1 < n /\ Euclid.is_prime n} -> a:pos{a < n} -> Lemma (Lib.NatMod.pow_mod #n a (n - 2) * a % n = 1)
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.Math.Fermat", "short_module": "Fermat" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mod_inv_prime_lemma n a = Math.Lemmas.small_mod a n; assert (a == a % n); assert (a <> 0 /\ a % n <> 0); calc (==) { Lib.NatMod.pow_mod #n a (n - 2) * a % n; (==) { Lib.NatMod.lemma_pow_mod #n a (n - 2) } Lib.NatMod.pow a (n - 2) % n * a % n; (==) { Math.Lemmas.lemma_mod_mul_distr_l (Lib.NatMod.pow a (n - 2)) a n } Lib.NatMod.pow a (n - 2) * a % n; (==) { Lib.NatMod.lemma_pow1 a; Lib.NatMod.lemma_pow_add a (n - 2) 1 } Lib.NatMod.pow a (n - 1) % n; (==) { pow_eq a (n - 1) } Fermat.pow a (n - 1) % n; (==) { Fermat.fermat_alt n a } 1; }
val mod_inv_prime_lemma: n:nat{1 < n /\ Euclid.is_prime n} -> a:pos{a < n} -> Lemma (Lib.NatMod.pow_mod #n a (n - 2) * a % n = 1) let mod_inv_prime_lemma n a =
false
null
true
Math.Lemmas.small_mod a n; assert (a == a % n); assert (a <> 0 /\ a % n <> 0); calc ( == ) { Lib.NatMod.pow_mod #n a (n - 2) * a % n; ( == ) { Lib.NatMod.lemma_pow_mod #n a (n - 2) } (Lib.NatMod.pow a (n - 2) % n) * a % n; ( == ) { Math.Lemmas.lemma_mod_mul_distr_l (Lib.NatMod.pow a (n - 2)) a n } Lib.NatMod.pow a (n - 2) * a % n; ( == ) { (Lib.NatMod.lemma_pow1 a; Lib.NatMod.lemma_pow_add a (n - 2) 1) } Lib.NatMod.pow a (n - 1) % n; ( == ) { pow_eq a (n - 1) } Fermat.pow a (n - 1) % n; ( == ) { Fermat.fermat_alt n a } 1; }
{ "checked_file": "Hacl.Spec.Bignum.ModInv.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Math.Fermat.fsti.checked", "FStar.Math.Euclid.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Bignum.ModInv.fst" }
[ "lemma" ]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.Math.Euclid.is_prime", "Prims.pos", "FStar.Calc.calc_finish", "Prims.int", "Prims.eq2", "Prims.op_Modulus", "FStar.Mul.op_Star", "Lib.NatMod.pow_mod", "Prims.op_Subtraction", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "FStar.Math.Fermat.pow", "Lib.NatMod.pow", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Lib.NatMod.lemma_pow_mod", "Prims.squash", "FStar.Math.Lemmas.lemma_mod_mul_distr_l", "Lib.NatMod.lemma_pow_add", "Lib.NatMod.lemma_pow1", "Hacl.Spec.Bignum.ModInv.pow_eq", "FStar.Math.Fermat.fermat_alt", "Prims._assert", "Prims.op_disEquality", "FStar.Math.Lemmas.small_mod" ]
[]
module Hacl.Spec.Bignum.ModInv open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.LoopCombinators open Hacl.Spec.Bignum.Definitions open Hacl.Spec.Bignum module Fermat = FStar.Math.Fermat module Euclid = FStar.Math.Euclid module BE = Hacl.Spec.Bignum.Exponentiation module BM = Hacl.Spec.Bignum.Montgomery module BN = Hacl.Spec.Bignum #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" #push-options "--fuel 1" val pow_eq: a:nat -> n:nat -> Lemma (Fermat.pow a n == Lib.NatMod.pow a n) let rec pow_eq a n = if n = 0 then () else pow_eq a (n - 1) #pop-options val mod_inv_prime_lemma: n:nat{1 < n /\ Euclid.is_prime n} -> a:pos{a < n} -> Lemma (Lib.NatMod.pow_mod #n a (n - 2) * a % n = 1)
false
false
Hacl.Spec.Bignum.ModInv.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mod_inv_prime_lemma: n:nat{1 < n /\ Euclid.is_prime n} -> a:pos{a < n} -> Lemma (Lib.NatMod.pow_mod #n a (n - 2) * a % n = 1)
[]
Hacl.Spec.Bignum.ModInv.mod_inv_prime_lemma
{ "file_name": "code/bignum/Hacl.Spec.Bignum.ModInv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
n: Prims.nat{1 < n /\ FStar.Math.Euclid.is_prime n} -> a: Prims.pos{a < n} -> FStar.Pervasives.Lemma (ensures Lib.NatMod.pow_mod a (n - 2) * a % n = 1)
{ "end_col": 5, "end_line": 48, "start_col": 2, "start_line": 32 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "S" }, { "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", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let one_st (t:Type) (to:to_comm_monoid t) = unit -> Pure t (requires True) (ensures fun one -> to.refl one == to.comm_monoid.S.one)
let one_st (t: Type) (to: to_comm_monoid t) =
false
null
false
unit -> Pure t (requires True) (ensures fun one -> to.refl one == to.comm_monoid.S.one)
{ "checked_file": "Spec.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Exponentiation.fsti" }
[ "total" ]
[ "Spec.Exponentiation.to_comm_monoid", "Prims.unit", "Prims.l_True", "Prims.eq2", "Spec.Exponentiation.__proj__Mkto_comm_monoid__item__a_spec", "Spec.Exponentiation.__proj__Mkto_comm_monoid__item__refl", "Lib.Exponentiation.Definition.__proj__Mkcomm_monoid__item__one", "Spec.Exponentiation.__proj__Mkto_comm_monoid__item__comm_monoid" ]
[]
module Spec.Exponentiation open FStar.Mul open Lib.IntTypes open Lib.Sequence module S = Lib.Exponentiation module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" (** This is a specification for generic exponentiation defined as a repeated application of a commutative monoid operation. • Modular Exponentiation: repeated modular multiplication • Elliptic Curve Scalar Multiplication: repeated point addition In hacl-star, in order to obtain a verified C implementation, we split our proofs into three steps: • high-level specification (lib/Lib.Exponentiation) • low-level specification (specs/Spec.Exponentiation) • low-star implementation (code/bignum/Hacl.Impl.Exponentiation) For example, to efficiently compute the EC scalar multiplication for Ed25519, we use point addition and doubling formulas in projective coordinates (see specs/Spec.Ed25519). • we first prove that (points on the curve, aff_point_add) forms a commutative monoid (`mk_ed25519_comm_monoid`) • we then prove the relation between point addition and doubling formulas in projective and affine coordinates (`mk_ed25519_concrete_ops`) • finally, we can obtain any implementation of exponentiation, e.g., a double fixed-window method, by providing the corresponding instance of the `concrete_ops` type class (`point_mul_double`) Another example is using Montgomery arithmetic (code/bignum) to compute a modular exponentiation (lib/Lib.NatMod). *) inline_for_extraction class to_comm_monoid (t:Type) = { a_spec: Type; comm_monoid: S.comm_monoid a_spec; refl: x:t -> a_spec; }
false
false
Spec.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val one_st : t: Type -> to: Spec.Exponentiation.to_comm_monoid t -> Type
[]
Spec.Exponentiation.one_st
{ "file_name": "specs/Spec.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Type -> to: Spec.Exponentiation.to_comm_monoid t -> Type
{ "end_col": 40, "end_line": 55, "start_col": 44, "start_line": 52 }
Prims.Tot
val exp_rl (#t: Type) (k: concrete_ops t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) : t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "S" }, { "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", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_rl (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let one = k.one () in let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc
val exp_rl (#t: Type) (k: concrete_ops t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) : t let exp_rl (#t: Type) (k: concrete_ops t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) : t =
false
null
false
let one = k.one () in let acc, c = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc
{ "checked_file": "Spec.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Exponentiation.fsti" }
[ "total" ]
[ "Spec.Exponentiation.concrete_ops", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "FStar.Pervasives.Native.tuple2", "Lib.LoopCombinators.repeati", "Spec.Exponentiation.exp_rl_f", "FStar.Pervasives.Native.Mktuple2", "Spec.Exponentiation.__proj__Mkconcrete_ops__item__one" ]
[]
module Spec.Exponentiation open FStar.Mul open Lib.IntTypes open Lib.Sequence module S = Lib.Exponentiation module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" (** This is a specification for generic exponentiation defined as a repeated application of a commutative monoid operation. • Modular Exponentiation: repeated modular multiplication • Elliptic Curve Scalar Multiplication: repeated point addition In hacl-star, in order to obtain a verified C implementation, we split our proofs into three steps: • high-level specification (lib/Lib.Exponentiation) • low-level specification (specs/Spec.Exponentiation) • low-star implementation (code/bignum/Hacl.Impl.Exponentiation) For example, to efficiently compute the EC scalar multiplication for Ed25519, we use point addition and doubling formulas in projective coordinates (see specs/Spec.Ed25519). • we first prove that (points on the curve, aff_point_add) forms a commutative monoid (`mk_ed25519_comm_monoid`) • we then prove the relation between point addition and doubling formulas in projective and affine coordinates (`mk_ed25519_concrete_ops`) • finally, we can obtain any implementation of exponentiation, e.g., a double fixed-window method, by providing the corresponding instance of the `concrete_ops` type class (`point_mul_double`) Another example is using Montgomery arithmetic (code/bignum) to compute a modular exponentiation (lib/Lib.NatMod). *) inline_for_extraction class to_comm_monoid (t:Type) = { a_spec: Type; comm_monoid: S.comm_monoid a_spec; refl: x:t -> a_spec; } inline_for_extraction let one_st (t:Type) (to:to_comm_monoid t) = unit -> Pure t (requires True) (ensures fun one -> to.refl one == to.comm_monoid.S.one) inline_for_extraction let mul_st (t:Type) (to:to_comm_monoid t) = x:t -> y:t -> Pure t (requires True) (ensures fun xy -> to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl y)) inline_for_extraction let sqr_st (t:Type) (to:to_comm_monoid t) = x:t -> Pure t (requires True) (ensures fun xy -> to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl x)) inline_for_extraction class concrete_ops (t:Type) = { to: to_comm_monoid t; one: one_st t to; mul: mul_st t to; sqr: sqr_st t to; } let exp_rl_f (#t:Type) (k:concrete_ops t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (S.get_ith_bit bBits b i = 0) then acc else k.mul acc c in let c = k.sqr c in (acc, c)
false
false
Spec.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val exp_rl (#t: Type) (k: concrete_ops t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) : t
[]
Spec.Exponentiation.exp_rl
{ "file_name": "specs/Spec.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Spec.Exponentiation.concrete_ops t -> a: t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> t
{ "end_col": 5, "end_line": 93, "start_col": 87, "start_line": 90 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "S" }, { "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", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sqr_st (t:Type) (to:to_comm_monoid t) = x:t -> Pure t (requires True) (ensures fun xy -> to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl x))
let sqr_st (t: Type) (to: to_comm_monoid t) =
false
null
false
x: t -> Pure t (requires True) (ensures fun xy -> to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl x))
{ "checked_file": "Spec.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Exponentiation.fsti" }
[ "total" ]
[ "Spec.Exponentiation.to_comm_monoid", "Prims.l_True", "Prims.eq2", "Spec.Exponentiation.__proj__Mkto_comm_monoid__item__a_spec", "Spec.Exponentiation.__proj__Mkto_comm_monoid__item__refl", "Lib.Exponentiation.Definition.__proj__Mkcomm_monoid__item__mul", "Spec.Exponentiation.__proj__Mkto_comm_monoid__item__comm_monoid" ]
[]
module Spec.Exponentiation open FStar.Mul open Lib.IntTypes open Lib.Sequence module S = Lib.Exponentiation module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" (** This is a specification for generic exponentiation defined as a repeated application of a commutative monoid operation. • Modular Exponentiation: repeated modular multiplication • Elliptic Curve Scalar Multiplication: repeated point addition In hacl-star, in order to obtain a verified C implementation, we split our proofs into three steps: • high-level specification (lib/Lib.Exponentiation) • low-level specification (specs/Spec.Exponentiation) • low-star implementation (code/bignum/Hacl.Impl.Exponentiation) For example, to efficiently compute the EC scalar multiplication for Ed25519, we use point addition and doubling formulas in projective coordinates (see specs/Spec.Ed25519). • we first prove that (points on the curve, aff_point_add) forms a commutative monoid (`mk_ed25519_comm_monoid`) • we then prove the relation between point addition and doubling formulas in projective and affine coordinates (`mk_ed25519_concrete_ops`) • finally, we can obtain any implementation of exponentiation, e.g., a double fixed-window method, by providing the corresponding instance of the `concrete_ops` type class (`point_mul_double`) Another example is using Montgomery arithmetic (code/bignum) to compute a modular exponentiation (lib/Lib.NatMod). *) inline_for_extraction class to_comm_monoid (t:Type) = { a_spec: Type; comm_monoid: S.comm_monoid a_spec; refl: x:t -> a_spec; } inline_for_extraction let one_st (t:Type) (to:to_comm_monoid t) = unit -> Pure t (requires True) (ensures fun one -> to.refl one == to.comm_monoid.S.one) inline_for_extraction let mul_st (t:Type) (to:to_comm_monoid t) = x:t -> y:t -> Pure t (requires True) (ensures fun xy -> to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl y))
false
false
Spec.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sqr_st : t: Type -> to: Spec.Exponentiation.to_comm_monoid t -> Type
[]
Spec.Exponentiation.sqr_st
{ "file_name": "specs/Spec.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Type -> to: Spec.Exponentiation.to_comm_monoid t -> Type
{ "end_col": 63, "end_line": 69, "start_col": 44, "start_line": 66 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "S" }, { "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", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_rl_f (#t:Type) (k:concrete_ops t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (S.get_ith_bit bBits b i = 0) then acc else k.mul acc c in let c = k.sqr c in (acc, c)
let exp_rl_f (#t: Type) (k: concrete_ops t) (bBits: nat) (b: nat{b < pow2 bBits}) (i: nat{i < bBits}) (acc, c: tuple2 t t) : tuple2 t t =
false
null
false
let acc = if (S.get_ith_bit bBits b i = 0) then acc else k.mul acc c in let c = k.sqr c in (acc, c)
{ "checked_file": "Spec.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Exponentiation.fsti" }
[ "total" ]
[ "Spec.Exponentiation.concrete_ops", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "Spec.Exponentiation.__proj__Mkconcrete_ops__item__sqr", "Prims.op_Equality", "Prims.int", "Lib.Exponentiation.get_ith_bit", "Prims.bool", "Spec.Exponentiation.__proj__Mkconcrete_ops__item__mul" ]
[]
module Spec.Exponentiation open FStar.Mul open Lib.IntTypes open Lib.Sequence module S = Lib.Exponentiation module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" (** This is a specification for generic exponentiation defined as a repeated application of a commutative monoid operation. • Modular Exponentiation: repeated modular multiplication • Elliptic Curve Scalar Multiplication: repeated point addition In hacl-star, in order to obtain a verified C implementation, we split our proofs into three steps: • high-level specification (lib/Lib.Exponentiation) • low-level specification (specs/Spec.Exponentiation) • low-star implementation (code/bignum/Hacl.Impl.Exponentiation) For example, to efficiently compute the EC scalar multiplication for Ed25519, we use point addition and doubling formulas in projective coordinates (see specs/Spec.Ed25519). • we first prove that (points on the curve, aff_point_add) forms a commutative monoid (`mk_ed25519_comm_monoid`) • we then prove the relation between point addition and doubling formulas in projective and affine coordinates (`mk_ed25519_concrete_ops`) • finally, we can obtain any implementation of exponentiation, e.g., a double fixed-window method, by providing the corresponding instance of the `concrete_ops` type class (`point_mul_double`) Another example is using Montgomery arithmetic (code/bignum) to compute a modular exponentiation (lib/Lib.NatMod). *) inline_for_extraction class to_comm_monoid (t:Type) = { a_spec: Type; comm_monoid: S.comm_monoid a_spec; refl: x:t -> a_spec; } inline_for_extraction let one_st (t:Type) (to:to_comm_monoid t) = unit -> Pure t (requires True) (ensures fun one -> to.refl one == to.comm_monoid.S.one) inline_for_extraction let mul_st (t:Type) (to:to_comm_monoid t) = x:t -> y:t -> Pure t (requires True) (ensures fun xy -> to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl y)) inline_for_extraction let sqr_st (t:Type) (to:to_comm_monoid t) = x:t -> Pure t (requires True) (ensures fun xy -> to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl x)) inline_for_extraction class concrete_ops (t:Type) = { to: to_comm_monoid t; one: one_st t to; mul: mul_st t to; sqr: sqr_st t to; } let exp_rl_f (#t:Type) (k:concrete_ops t) (bBits:nat) (b:nat{b < pow2 bBits})
false
false
Spec.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val exp_rl_f : k: Spec.Exponentiation.concrete_ops t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> i: Prims.nat{i < bBits} -> _: (t * t) -> t * t
[]
Spec.Exponentiation.exp_rl_f
{ "file_name": "specs/Spec.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Spec.Exponentiation.concrete_ops t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> i: Prims.nat{i < bBits} -> _: (t * t) -> t * t
{ "end_col": 10, "end_line": 87, "start_col": 2, "start_line": 84 }
Prims.Tot
val exp_mont_ladder_swap (#t: Type) (k: concrete_ops t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) : t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "S" }, { "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", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_mont_ladder_swap (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1, sw) = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one (), a, 0) in let (r0, r1) = S.cswap sw r0 r1 in r0
val exp_mont_ladder_swap (#t: Type) (k: concrete_ops t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) : t let exp_mont_ladder_swap (#t: Type) (k: concrete_ops t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) : t =
false
null
false
let r0, r1, sw = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one (), a, 0) in let r0, r1 = S.cswap sw r0 r1 in r0
{ "checked_file": "Spec.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Exponentiation.fsti" }
[ "total" ]
[ "Spec.Exponentiation.concrete_ops", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "FStar.Pervasives.Native.tuple2", "Lib.Exponentiation.cswap", "FStar.Pervasives.Native.tuple3", "Lib.LoopCombinators.repeati", "Spec.Exponentiation.exp_mont_ladder_swap_f", "FStar.Pervasives.Native.Mktuple3", "Spec.Exponentiation.one" ]
[]
module Spec.Exponentiation open FStar.Mul open Lib.IntTypes open Lib.Sequence module S = Lib.Exponentiation module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" (** This is a specification for generic exponentiation defined as a repeated application of a commutative monoid operation. • Modular Exponentiation: repeated modular multiplication • Elliptic Curve Scalar Multiplication: repeated point addition In hacl-star, in order to obtain a verified C implementation, we split our proofs into three steps: • high-level specification (lib/Lib.Exponentiation) • low-level specification (specs/Spec.Exponentiation) • low-star implementation (code/bignum/Hacl.Impl.Exponentiation) For example, to efficiently compute the EC scalar multiplication for Ed25519, we use point addition and doubling formulas in projective coordinates (see specs/Spec.Ed25519). • we first prove that (points on the curve, aff_point_add) forms a commutative monoid (`mk_ed25519_comm_monoid`) • we then prove the relation between point addition and doubling formulas in projective and affine coordinates (`mk_ed25519_concrete_ops`) • finally, we can obtain any implementation of exponentiation, e.g., a double fixed-window method, by providing the corresponding instance of the `concrete_ops` type class (`point_mul_double`) Another example is using Montgomery arithmetic (code/bignum) to compute a modular exponentiation (lib/Lib.NatMod). *) inline_for_extraction class to_comm_monoid (t:Type) = { a_spec: Type; comm_monoid: S.comm_monoid a_spec; refl: x:t -> a_spec; } inline_for_extraction let one_st (t:Type) (to:to_comm_monoid t) = unit -> Pure t (requires True) (ensures fun one -> to.refl one == to.comm_monoid.S.one) inline_for_extraction let mul_st (t:Type) (to:to_comm_monoid t) = x:t -> y:t -> Pure t (requires True) (ensures fun xy -> to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl y)) inline_for_extraction let sqr_st (t:Type) (to:to_comm_monoid t) = x:t -> Pure t (requires True) (ensures fun xy -> to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl x)) inline_for_extraction class concrete_ops (t:Type) = { to: to_comm_monoid t; one: one_st t to; mul: mul_st t to; sqr: sqr_st t to; } let exp_rl_f (#t:Type) (k:concrete_ops t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (S.get_ith_bit bBits b i = 0) then acc else k.mul acc c in let c = k.sqr c in (acc, c) let exp_rl (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let one = k.one () in let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc val exp_rl_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (k.to.refl (exp_rl k a bBits b) == S.exp_rl k.to.comm_monoid (k.to.refl a) bBits b) let exp_mont_ladder_swap_f (#t:Type) (k:concrete_ops t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat = let bit = S.get_ith_bit bBits b (bBits - 1 - i) in let sw = (bit + privbit) % 2 in let r0, r1 = S.cswap sw r0 r1 in let r0, r1 = (k.sqr r0, k.mul r1 r0) in (r0, r1, bit)
false
false
Spec.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val exp_mont_ladder_swap (#t: Type) (k: concrete_ops t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) : t
[]
Spec.Exponentiation.exp_mont_ladder_swap
{ "file_name": "specs/Spec.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Spec.Exponentiation.concrete_ops t -> a: t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> t
{ "end_col": 4, "end_line": 114, "start_col": 101, "start_line": 111 }
Prims.Tot
val exp_pow2 (#t: Type) (k: concrete_ops t) (a: t) (b: nat) : t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "S" }, { "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", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_pow2 (#t:Type) (k:concrete_ops t) (a:t) (b:nat) : t = Loops.repeat b k.sqr a
val exp_pow2 (#t: Type) (k: concrete_ops t) (a: t) (b: nat) : t let exp_pow2 (#t: Type) (k: concrete_ops t) (a: t) (b: nat) : t =
false
null
false
Loops.repeat b k.sqr a
{ "checked_file": "Spec.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Exponentiation.fsti" }
[ "total" ]
[ "Spec.Exponentiation.concrete_ops", "Prims.nat", "Lib.LoopCombinators.repeat", "Spec.Exponentiation.__proj__Mkconcrete_ops__item__sqr" ]
[]
module Spec.Exponentiation open FStar.Mul open Lib.IntTypes open Lib.Sequence module S = Lib.Exponentiation module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" (** This is a specification for generic exponentiation defined as a repeated application of a commutative monoid operation. • Modular Exponentiation: repeated modular multiplication • Elliptic Curve Scalar Multiplication: repeated point addition In hacl-star, in order to obtain a verified C implementation, we split our proofs into three steps: • high-level specification (lib/Lib.Exponentiation) • low-level specification (specs/Spec.Exponentiation) • low-star implementation (code/bignum/Hacl.Impl.Exponentiation) For example, to efficiently compute the EC scalar multiplication for Ed25519, we use point addition and doubling formulas in projective coordinates (see specs/Spec.Ed25519). • we first prove that (points on the curve, aff_point_add) forms a commutative monoid (`mk_ed25519_comm_monoid`) • we then prove the relation between point addition and doubling formulas in projective and affine coordinates (`mk_ed25519_concrete_ops`) • finally, we can obtain any implementation of exponentiation, e.g., a double fixed-window method, by providing the corresponding instance of the `concrete_ops` type class (`point_mul_double`) Another example is using Montgomery arithmetic (code/bignum) to compute a modular exponentiation (lib/Lib.NatMod). *) inline_for_extraction class to_comm_monoid (t:Type) = { a_spec: Type; comm_monoid: S.comm_monoid a_spec; refl: x:t -> a_spec; } inline_for_extraction let one_st (t:Type) (to:to_comm_monoid t) = unit -> Pure t (requires True) (ensures fun one -> to.refl one == to.comm_monoid.S.one) inline_for_extraction let mul_st (t:Type) (to:to_comm_monoid t) = x:t -> y:t -> Pure t (requires True) (ensures fun xy -> to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl y)) inline_for_extraction let sqr_st (t:Type) (to:to_comm_monoid t) = x:t -> Pure t (requires True) (ensures fun xy -> to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl x)) inline_for_extraction class concrete_ops (t:Type) = { to: to_comm_monoid t; one: one_st t to; mul: mul_st t to; sqr: sqr_st t to; } let exp_rl_f (#t:Type) (k:concrete_ops t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (S.get_ith_bit bBits b i = 0) then acc else k.mul acc c in let c = k.sqr c in (acc, c) let exp_rl (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let one = k.one () in let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc val exp_rl_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (k.to.refl (exp_rl k a bBits b) == S.exp_rl k.to.comm_monoid (k.to.refl a) bBits b) let exp_mont_ladder_swap_f (#t:Type) (k:concrete_ops t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat = let bit = S.get_ith_bit bBits b (bBits - 1 - i) in let sw = (bit + privbit) % 2 in let r0, r1 = S.cswap sw r0 r1 in let r0, r1 = (k.sqr r0, k.mul r1 r0) in (r0, r1, bit) let exp_mont_ladder_swap (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1, sw) = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one (), a, 0) in let (r0, r1) = S.cswap sw r0 r1 in r0 val exp_mont_ladder_swap_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (k.to.refl (exp_mont_ladder_swap k a bBits b) == S.exp_mont_ladder_swap k.to.comm_monoid (k.to.refl a) bBits b)
false
false
Spec.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val exp_pow2 (#t: Type) (k: concrete_ops t) (a: t) (b: nat) : t
[]
Spec.Exponentiation.exp_pow2
{ "file_name": "specs/Spec.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Spec.Exponentiation.concrete_ops t -> a: t -> b: Prims.nat -> t
{ "end_col": 24, "end_line": 122, "start_col": 2, "start_line": 122 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "S" }, { "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", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mul_st (t:Type) (to:to_comm_monoid t) = x:t -> y:t -> Pure t (requires True) (ensures fun xy -> to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl y))
let mul_st (t: Type) (to: to_comm_monoid t) =
false
null
false
x: t -> y: t -> Pure t (requires True) (ensures fun xy -> to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl y))
{ "checked_file": "Spec.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Exponentiation.fsti" }
[ "total" ]
[ "Spec.Exponentiation.to_comm_monoid", "Prims.l_True", "Prims.eq2", "Spec.Exponentiation.__proj__Mkto_comm_monoid__item__a_spec", "Spec.Exponentiation.__proj__Mkto_comm_monoid__item__refl", "Lib.Exponentiation.Definition.__proj__Mkcomm_monoid__item__mul", "Spec.Exponentiation.__proj__Mkto_comm_monoid__item__comm_monoid" ]
[]
module Spec.Exponentiation open FStar.Mul open Lib.IntTypes open Lib.Sequence module S = Lib.Exponentiation module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" (** This is a specification for generic exponentiation defined as a repeated application of a commutative monoid operation. • Modular Exponentiation: repeated modular multiplication • Elliptic Curve Scalar Multiplication: repeated point addition In hacl-star, in order to obtain a verified C implementation, we split our proofs into three steps: • high-level specification (lib/Lib.Exponentiation) • low-level specification (specs/Spec.Exponentiation) • low-star implementation (code/bignum/Hacl.Impl.Exponentiation) For example, to efficiently compute the EC scalar multiplication for Ed25519, we use point addition and doubling formulas in projective coordinates (see specs/Spec.Ed25519). • we first prove that (points on the curve, aff_point_add) forms a commutative monoid (`mk_ed25519_comm_monoid`) • we then prove the relation between point addition and doubling formulas in projective and affine coordinates (`mk_ed25519_concrete_ops`) • finally, we can obtain any implementation of exponentiation, e.g., a double fixed-window method, by providing the corresponding instance of the `concrete_ops` type class (`point_mul_double`) Another example is using Montgomery arithmetic (code/bignum) to compute a modular exponentiation (lib/Lib.NatMod). *) inline_for_extraction class to_comm_monoid (t:Type) = { a_spec: Type; comm_monoid: S.comm_monoid a_spec; refl: x:t -> a_spec; } inline_for_extraction let one_st (t:Type) (to:to_comm_monoid t) = unit -> Pure t (requires True) (ensures fun one -> to.refl one == to.comm_monoid.S.one)
false
false
Spec.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mul_st : t: Type -> to: Spec.Exponentiation.to_comm_monoid t -> Type
[]
Spec.Exponentiation.mul_st
{ "file_name": "specs/Spec.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Type -> to: Spec.Exponentiation.to_comm_monoid t -> Type
{ "end_col": 63, "end_line": 62, "start_col": 44, "start_line": 59 }
Prims.Tot
val exp_fw_f (#t: Type) (k: concrete_ops t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "S" }, { "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", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_fw_f (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let acc1 = exp_pow2 k acc l in mul_acc_pow_a_bits_l k a bBits b l i acc1
val exp_fw_f (#t: Type) (k: concrete_ops t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t let exp_fw_f (#t: Type) (k: concrete_ops t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t =
false
null
false
let acc1 = exp_pow2 k acc l in mul_acc_pow_a_bits_l k a bBits b l i acc1
{ "checked_file": "Spec.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Exponentiation.fsti" }
[ "total" ]
[ "Spec.Exponentiation.concrete_ops", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.pos", "Prims.op_Division", "Spec.Exponentiation.mul_acc_pow_a_bits_l", "Spec.Exponentiation.exp_pow2" ]
[]
module Spec.Exponentiation open FStar.Mul open Lib.IntTypes open Lib.Sequence module S = Lib.Exponentiation module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" (** This is a specification for generic exponentiation defined as a repeated application of a commutative monoid operation. • Modular Exponentiation: repeated modular multiplication • Elliptic Curve Scalar Multiplication: repeated point addition In hacl-star, in order to obtain a verified C implementation, we split our proofs into three steps: • high-level specification (lib/Lib.Exponentiation) • low-level specification (specs/Spec.Exponentiation) • low-star implementation (code/bignum/Hacl.Impl.Exponentiation) For example, to efficiently compute the EC scalar multiplication for Ed25519, we use point addition and doubling formulas in projective coordinates (see specs/Spec.Ed25519). • we first prove that (points on the curve, aff_point_add) forms a commutative monoid (`mk_ed25519_comm_monoid`) • we then prove the relation between point addition and doubling formulas in projective and affine coordinates (`mk_ed25519_concrete_ops`) • finally, we can obtain any implementation of exponentiation, e.g., a double fixed-window method, by providing the corresponding instance of the `concrete_ops` type class (`point_mul_double`) Another example is using Montgomery arithmetic (code/bignum) to compute a modular exponentiation (lib/Lib.NatMod). *) inline_for_extraction class to_comm_monoid (t:Type) = { a_spec: Type; comm_monoid: S.comm_monoid a_spec; refl: x:t -> a_spec; } inline_for_extraction let one_st (t:Type) (to:to_comm_monoid t) = unit -> Pure t (requires True) (ensures fun one -> to.refl one == to.comm_monoid.S.one) inline_for_extraction let mul_st (t:Type) (to:to_comm_monoid t) = x:t -> y:t -> Pure t (requires True) (ensures fun xy -> to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl y)) inline_for_extraction let sqr_st (t:Type) (to:to_comm_monoid t) = x:t -> Pure t (requires True) (ensures fun xy -> to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl x)) inline_for_extraction class concrete_ops (t:Type) = { to: to_comm_monoid t; one: one_st t to; mul: mul_st t to; sqr: sqr_st t to; } let exp_rl_f (#t:Type) (k:concrete_ops t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (S.get_ith_bit bBits b i = 0) then acc else k.mul acc c in let c = k.sqr c in (acc, c) let exp_rl (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let one = k.one () in let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc val exp_rl_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (k.to.refl (exp_rl k a bBits b) == S.exp_rl k.to.comm_monoid (k.to.refl a) bBits b) let exp_mont_ladder_swap_f (#t:Type) (k:concrete_ops t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat = let bit = S.get_ith_bit bBits b (bBits - 1 - i) in let sw = (bit + privbit) % 2 in let r0, r1 = S.cswap sw r0 r1 in let r0, r1 = (k.sqr r0, k.mul r1 r0) in (r0, r1, bit) let exp_mont_ladder_swap (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1, sw) = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one (), a, 0) in let (r0, r1) = S.cswap sw r0 r1 in r0 val exp_mont_ladder_swap_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (k.to.refl (exp_mont_ladder_swap k a bBits b) == S.exp_mont_ladder_swap k.to.comm_monoid (k.to.refl a) bBits b) let exp_pow2 (#t:Type) (k:concrete_ops t) (a:t) (b:nat) : t = Loops.repeat b k.sqr a val exp_pow2_lemma: #t:Type -> k:concrete_ops t -> a:t -> b:nat -> Lemma (k.to.refl (exp_pow2 k a b) == S.exp_pow2 k.to.comm_monoid (k.to.refl a) b) [@(strict_on_arguments [3])] let rec pow (#t:Type) (k:concrete_ops t) (a:t) (b:nat) : t = if b = 0 then k.one () else k.mul a (pow k a (b - 1)) val pow_eq0: #t:Type -> k:concrete_ops t -> a:t -> Lemma (pow k a 0 == k.one ()) val pow_unfold: #t:Type -> k:concrete_ops t -> a:t -> i:pos -> Lemma (pow k a i == k.mul a (pow k a (i - 1))) val pow_lemma: #t:Type -> k:concrete_ops t -> a:t -> b:nat -> Lemma (k.to.refl (pow k a b) == S.pow k.to.comm_monoid (k.to.refl a) b) let exp_fw_acc0 (#t:Type0) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos{bBits % l <> 0}) : t = let bits_c = S.get_ith_lbits bBits b (bBits / l * l) l in pow k a bits_c let mul_acc_pow_a_bits_l (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let bits_l = S.get_bits_l bBits b l i in k.mul acc (pow k a bits_l) let exp_fw_f (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos)
false
false
Spec.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val exp_fw_f (#t: Type) (k: concrete_ops t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t
[]
Spec.Exponentiation.exp_fw_f
{ "file_name": "specs/Spec.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Spec.Exponentiation.concrete_ops t -> a: t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> l: Prims.pos -> i: Prims.nat{i < bBits / l} -> acc: t -> t
{ "end_col": 43, "end_line": 164, "start_col": 2, "start_line": 162 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "S" }, { "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", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_mont_ladder_swap_f (#t:Type) (k:concrete_ops t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat = let bit = S.get_ith_bit bBits b (bBits - 1 - i) in let sw = (bit + privbit) % 2 in let r0, r1 = S.cswap sw r0 r1 in let r0, r1 = (k.sqr r0, k.mul r1 r0) in (r0, r1, bit)
let exp_mont_ladder_swap_f (#t: Type) (k: concrete_ops t) (bBits: nat) (b: nat{b < pow2 bBits}) (i: nat{i < bBits}) (r0, r1, privbit: tuple3 t t nat) : tuple3 t t nat =
false
null
false
let bit = S.get_ith_bit bBits b (bBits - 1 - i) in let sw = (bit + privbit) % 2 in let r0, r1 = S.cswap sw r0 r1 in let r0, r1 = (k.sqr r0, k.mul r1 r0) in (r0, r1, bit)
{ "checked_file": "Spec.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Exponentiation.fsti" }
[ "total" ]
[ "Spec.Exponentiation.concrete_ops", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.Mktuple3", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "Spec.Exponentiation.__proj__Mkconcrete_ops__item__sqr", "Spec.Exponentiation.__proj__Mkconcrete_ops__item__mul", "Lib.Exponentiation.cswap", "Prims.int", "Prims.op_Modulus", "Prims.op_Addition", "Lib.Exponentiation.get_ith_bit", "Prims.op_Subtraction" ]
[]
module Spec.Exponentiation open FStar.Mul open Lib.IntTypes open Lib.Sequence module S = Lib.Exponentiation module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" (** This is a specification for generic exponentiation defined as a repeated application of a commutative monoid operation. • Modular Exponentiation: repeated modular multiplication • Elliptic Curve Scalar Multiplication: repeated point addition In hacl-star, in order to obtain a verified C implementation, we split our proofs into three steps: • high-level specification (lib/Lib.Exponentiation) • low-level specification (specs/Spec.Exponentiation) • low-star implementation (code/bignum/Hacl.Impl.Exponentiation) For example, to efficiently compute the EC scalar multiplication for Ed25519, we use point addition and doubling formulas in projective coordinates (see specs/Spec.Ed25519). • we first prove that (points on the curve, aff_point_add) forms a commutative monoid (`mk_ed25519_comm_monoid`) • we then prove the relation between point addition and doubling formulas in projective and affine coordinates (`mk_ed25519_concrete_ops`) • finally, we can obtain any implementation of exponentiation, e.g., a double fixed-window method, by providing the corresponding instance of the `concrete_ops` type class (`point_mul_double`) Another example is using Montgomery arithmetic (code/bignum) to compute a modular exponentiation (lib/Lib.NatMod). *) inline_for_extraction class to_comm_monoid (t:Type) = { a_spec: Type; comm_monoid: S.comm_monoid a_spec; refl: x:t -> a_spec; } inline_for_extraction let one_st (t:Type) (to:to_comm_monoid t) = unit -> Pure t (requires True) (ensures fun one -> to.refl one == to.comm_monoid.S.one) inline_for_extraction let mul_st (t:Type) (to:to_comm_monoid t) = x:t -> y:t -> Pure t (requires True) (ensures fun xy -> to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl y)) inline_for_extraction let sqr_st (t:Type) (to:to_comm_monoid t) = x:t -> Pure t (requires True) (ensures fun xy -> to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl x)) inline_for_extraction class concrete_ops (t:Type) = { to: to_comm_monoid t; one: one_st t to; mul: mul_st t to; sqr: sqr_st t to; } let exp_rl_f (#t:Type) (k:concrete_ops t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (S.get_ith_bit bBits b i = 0) then acc else k.mul acc c in let c = k.sqr c in (acc, c) let exp_rl (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let one = k.one () in let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc val exp_rl_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (k.to.refl (exp_rl k a bBits b) == S.exp_rl k.to.comm_monoid (k.to.refl a) bBits b) let exp_mont_ladder_swap_f (#t:Type) (k:concrete_ops t) (bBits:nat) (b:nat{b < pow2 bBits})
false
false
Spec.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val exp_mont_ladder_swap_f : k: Spec.Exponentiation.concrete_ops t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> i: Prims.nat{i < bBits} -> _: ((t * t) * Prims.nat) -> (t * t) * Prims.nat
[]
Spec.Exponentiation.exp_mont_ladder_swap_f
{ "file_name": "specs/Spec.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Spec.Exponentiation.concrete_ops t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> i: Prims.nat{i < bBits} -> _: ((t * t) * Prims.nat) -> (t * t) * Prims.nat
{ "end_col": 15, "end_line": 108, "start_col": 2, "start_line": 103 }
Prims.Tot
val pow (#t: Type) (k: concrete_ops t) (a: t) (b: nat) : t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "S" }, { "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", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec pow (#t:Type) (k:concrete_ops t) (a:t) (b:nat) : t = if b = 0 then k.one () else k.mul a (pow k a (b - 1))
val pow (#t: Type) (k: concrete_ops t) (a: t) (b: nat) : t let rec pow (#t: Type) (k: concrete_ops t) (a: t) (b: nat) : t =
false
null
false
if b = 0 then k.one () else k.mul a (pow k a (b - 1))
{ "checked_file": "Spec.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Exponentiation.fsti" }
[ "total" ]
[ "Spec.Exponentiation.concrete_ops", "Prims.nat", "Prims.op_Equality", "Prims.int", "Spec.Exponentiation.__proj__Mkconcrete_ops__item__one", "Prims.bool", "Spec.Exponentiation.__proj__Mkconcrete_ops__item__mul", "Spec.Exponentiation.pow", "Prims.op_Subtraction" ]
[]
module Spec.Exponentiation open FStar.Mul open Lib.IntTypes open Lib.Sequence module S = Lib.Exponentiation module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" (** This is a specification for generic exponentiation defined as a repeated application of a commutative monoid operation. • Modular Exponentiation: repeated modular multiplication • Elliptic Curve Scalar Multiplication: repeated point addition In hacl-star, in order to obtain a verified C implementation, we split our proofs into three steps: • high-level specification (lib/Lib.Exponentiation) • low-level specification (specs/Spec.Exponentiation) • low-star implementation (code/bignum/Hacl.Impl.Exponentiation) For example, to efficiently compute the EC scalar multiplication for Ed25519, we use point addition and doubling formulas in projective coordinates (see specs/Spec.Ed25519). • we first prove that (points on the curve, aff_point_add) forms a commutative monoid (`mk_ed25519_comm_monoid`) • we then prove the relation between point addition and doubling formulas in projective and affine coordinates (`mk_ed25519_concrete_ops`) • finally, we can obtain any implementation of exponentiation, e.g., a double fixed-window method, by providing the corresponding instance of the `concrete_ops` type class (`point_mul_double`) Another example is using Montgomery arithmetic (code/bignum) to compute a modular exponentiation (lib/Lib.NatMod). *) inline_for_extraction class to_comm_monoid (t:Type) = { a_spec: Type; comm_monoid: S.comm_monoid a_spec; refl: x:t -> a_spec; } inline_for_extraction let one_st (t:Type) (to:to_comm_monoid t) = unit -> Pure t (requires True) (ensures fun one -> to.refl one == to.comm_monoid.S.one) inline_for_extraction let mul_st (t:Type) (to:to_comm_monoid t) = x:t -> y:t -> Pure t (requires True) (ensures fun xy -> to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl y)) inline_for_extraction let sqr_st (t:Type) (to:to_comm_monoid t) = x:t -> Pure t (requires True) (ensures fun xy -> to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl x)) inline_for_extraction class concrete_ops (t:Type) = { to: to_comm_monoid t; one: one_st t to; mul: mul_st t to; sqr: sqr_st t to; } let exp_rl_f (#t:Type) (k:concrete_ops t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (S.get_ith_bit bBits b i = 0) then acc else k.mul acc c in let c = k.sqr c in (acc, c) let exp_rl (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let one = k.one () in let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc val exp_rl_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (k.to.refl (exp_rl k a bBits b) == S.exp_rl k.to.comm_monoid (k.to.refl a) bBits b) let exp_mont_ladder_swap_f (#t:Type) (k:concrete_ops t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat = let bit = S.get_ith_bit bBits b (bBits - 1 - i) in let sw = (bit + privbit) % 2 in let r0, r1 = S.cswap sw r0 r1 in let r0, r1 = (k.sqr r0, k.mul r1 r0) in (r0, r1, bit) let exp_mont_ladder_swap (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1, sw) = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one (), a, 0) in let (r0, r1) = S.cswap sw r0 r1 in r0 val exp_mont_ladder_swap_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (k.to.refl (exp_mont_ladder_swap k a bBits b) == S.exp_mont_ladder_swap k.to.comm_monoid (k.to.refl a) bBits b) let exp_pow2 (#t:Type) (k:concrete_ops t) (a:t) (b:nat) : t = Loops.repeat b k.sqr a val exp_pow2_lemma: #t:Type -> k:concrete_ops t -> a:t -> b:nat -> Lemma (k.to.refl (exp_pow2 k a b) == S.exp_pow2 k.to.comm_monoid (k.to.refl a) b) [@(strict_on_arguments [3])]
false
false
Spec.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val pow (#t: Type) (k: concrete_ops t) (a: t) (b: nat) : t
[ "recursion" ]
Spec.Exponentiation.pow
{ "file_name": "specs/Spec.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Spec.Exponentiation.concrete_ops t -> a: t -> b: Prims.nat -> t
{ "end_col": 32, "end_line": 132, "start_col": 2, "start_line": 131 }
Prims.Tot
val exp_double_fw_f (#t: Type) (k: concrete_ops t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "S" }, { "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", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_double_fw_f (#t:Type) (k:concrete_ops t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let acc1 = exp_fw_f k a2 bBits b2 l i acc in mul_acc_pow_a_bits_l k a1 bBits b1 l i acc1
val exp_double_fw_f (#t: Type) (k: concrete_ops t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t let exp_double_fw_f (#t: Type) (k: concrete_ops t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t =
false
null
false
let acc1 = exp_fw_f k a2 bBits b2 l i acc in mul_acc_pow_a_bits_l k a1 bBits b1 l i acc1
{ "checked_file": "Spec.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Exponentiation.fsti" }
[ "total" ]
[ "Spec.Exponentiation.concrete_ops", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.pos", "Prims.op_Division", "Spec.Exponentiation.mul_acc_pow_a_bits_l", "Spec.Exponentiation.exp_fw_f" ]
[]
module Spec.Exponentiation open FStar.Mul open Lib.IntTypes open Lib.Sequence module S = Lib.Exponentiation module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" (** This is a specification for generic exponentiation defined as a repeated application of a commutative monoid operation. • Modular Exponentiation: repeated modular multiplication • Elliptic Curve Scalar Multiplication: repeated point addition In hacl-star, in order to obtain a verified C implementation, we split our proofs into three steps: • high-level specification (lib/Lib.Exponentiation) • low-level specification (specs/Spec.Exponentiation) • low-star implementation (code/bignum/Hacl.Impl.Exponentiation) For example, to efficiently compute the EC scalar multiplication for Ed25519, we use point addition and doubling formulas in projective coordinates (see specs/Spec.Ed25519). • we first prove that (points on the curve, aff_point_add) forms a commutative monoid (`mk_ed25519_comm_monoid`) • we then prove the relation between point addition and doubling formulas in projective and affine coordinates (`mk_ed25519_concrete_ops`) • finally, we can obtain any implementation of exponentiation, e.g., a double fixed-window method, by providing the corresponding instance of the `concrete_ops` type class (`point_mul_double`) Another example is using Montgomery arithmetic (code/bignum) to compute a modular exponentiation (lib/Lib.NatMod). *) inline_for_extraction class to_comm_monoid (t:Type) = { a_spec: Type; comm_monoid: S.comm_monoid a_spec; refl: x:t -> a_spec; } inline_for_extraction let one_st (t:Type) (to:to_comm_monoid t) = unit -> Pure t (requires True) (ensures fun one -> to.refl one == to.comm_monoid.S.one) inline_for_extraction let mul_st (t:Type) (to:to_comm_monoid t) = x:t -> y:t -> Pure t (requires True) (ensures fun xy -> to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl y)) inline_for_extraction let sqr_st (t:Type) (to:to_comm_monoid t) = x:t -> Pure t (requires True) (ensures fun xy -> to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl x)) inline_for_extraction class concrete_ops (t:Type) = { to: to_comm_monoid t; one: one_st t to; mul: mul_st t to; sqr: sqr_st t to; } let exp_rl_f (#t:Type) (k:concrete_ops t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (S.get_ith_bit bBits b i = 0) then acc else k.mul acc c in let c = k.sqr c in (acc, c) let exp_rl (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let one = k.one () in let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc val exp_rl_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (k.to.refl (exp_rl k a bBits b) == S.exp_rl k.to.comm_monoid (k.to.refl a) bBits b) let exp_mont_ladder_swap_f (#t:Type) (k:concrete_ops t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat = let bit = S.get_ith_bit bBits b (bBits - 1 - i) in let sw = (bit + privbit) % 2 in let r0, r1 = S.cswap sw r0 r1 in let r0, r1 = (k.sqr r0, k.mul r1 r0) in (r0, r1, bit) let exp_mont_ladder_swap (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1, sw) = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one (), a, 0) in let (r0, r1) = S.cswap sw r0 r1 in r0 val exp_mont_ladder_swap_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (k.to.refl (exp_mont_ladder_swap k a bBits b) == S.exp_mont_ladder_swap k.to.comm_monoid (k.to.refl a) bBits b) let exp_pow2 (#t:Type) (k:concrete_ops t) (a:t) (b:nat) : t = Loops.repeat b k.sqr a val exp_pow2_lemma: #t:Type -> k:concrete_ops t -> a:t -> b:nat -> Lemma (k.to.refl (exp_pow2 k a b) == S.exp_pow2 k.to.comm_monoid (k.to.refl a) b) [@(strict_on_arguments [3])] let rec pow (#t:Type) (k:concrete_ops t) (a:t) (b:nat) : t = if b = 0 then k.one () else k.mul a (pow k a (b - 1)) val pow_eq0: #t:Type -> k:concrete_ops t -> a:t -> Lemma (pow k a 0 == k.one ()) val pow_unfold: #t:Type -> k:concrete_ops t -> a:t -> i:pos -> Lemma (pow k a i == k.mul a (pow k a (i - 1))) val pow_lemma: #t:Type -> k:concrete_ops t -> a:t -> b:nat -> Lemma (k.to.refl (pow k a b) == S.pow k.to.comm_monoid (k.to.refl a) b) let exp_fw_acc0 (#t:Type0) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos{bBits % l <> 0}) : t = let bits_c = S.get_ith_lbits bBits b (bBits / l * l) l in pow k a bits_c let mul_acc_pow_a_bits_l (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let bits_l = S.get_bits_l bBits b l i in k.mul acc (pow k a bits_l) let exp_fw_f (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let acc1 = exp_pow2 k acc l in mul_acc_pow_a_bits_l k a bBits b l i acc1 let exp_fw (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) : t = let acc0 = if bBits % l = 0 then one () else exp_fw_acc0 k a bBits b l in Loops.repeati (bBits / l) (exp_fw_f k a bBits b l) acc0 val exp_fw_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> Lemma (k.to.refl (exp_fw k a bBits b l) == S.exp_fw k.to.comm_monoid (k.to.refl a) bBits b l) /// Multi-Exponentiation // Double exponentiation [a1^b1 `mul` a2^b2] //------------------------------------------- let exp_double_fw_acc0 (#t:Type) (k:concrete_ops t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (l:pos{bBits % l <> 0}) : t = let acc_a1 = exp_fw_acc0 k a1 bBits b1 l in let acc_a2 = exp_fw_acc0 k a2 bBits b2 l in k.mul acc_a1 acc_a2 let exp_double_fw_f (#t:Type) (k:concrete_ops t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (l:pos)
false
false
Spec.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val exp_double_fw_f (#t: Type) (k: concrete_ops t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t
[]
Spec.Exponentiation.exp_double_fw_f
{ "file_name": "specs/Spec.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Spec.Exponentiation.concrete_ops t -> a1: t -> bBits: Prims.nat -> b1: Prims.nat{b1 < Prims.pow2 bBits} -> a2: t -> b2: Prims.nat{b2 < Prims.pow2 bBits} -> l: Prims.pos -> i: Prims.nat{i < bBits / l} -> acc: t -> t
{ "end_col": 45, "end_line": 196, "start_col": 2, "start_line": 194 }
Prims.Tot
val mul_acc_pow_a_bits_l (#t: Type) (k: concrete_ops t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "S" }, { "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", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mul_acc_pow_a_bits_l (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let bits_l = S.get_bits_l bBits b l i in k.mul acc (pow k a bits_l)
val mul_acc_pow_a_bits_l (#t: Type) (k: concrete_ops t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t let mul_acc_pow_a_bits_l (#t: Type) (k: concrete_ops t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t =
false
null
false
let bits_l = S.get_bits_l bBits b l i in k.mul acc (pow k a bits_l)
{ "checked_file": "Spec.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Exponentiation.fsti" }
[ "total" ]
[ "Spec.Exponentiation.concrete_ops", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.pos", "Prims.op_Division", "Spec.Exponentiation.__proj__Mkconcrete_ops__item__mul", "Spec.Exponentiation.pow", "Lib.Exponentiation.get_bits_l" ]
[]
module Spec.Exponentiation open FStar.Mul open Lib.IntTypes open Lib.Sequence module S = Lib.Exponentiation module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" (** This is a specification for generic exponentiation defined as a repeated application of a commutative monoid operation. • Modular Exponentiation: repeated modular multiplication • Elliptic Curve Scalar Multiplication: repeated point addition In hacl-star, in order to obtain a verified C implementation, we split our proofs into three steps: • high-level specification (lib/Lib.Exponentiation) • low-level specification (specs/Spec.Exponentiation) • low-star implementation (code/bignum/Hacl.Impl.Exponentiation) For example, to efficiently compute the EC scalar multiplication for Ed25519, we use point addition and doubling formulas in projective coordinates (see specs/Spec.Ed25519). • we first prove that (points on the curve, aff_point_add) forms a commutative monoid (`mk_ed25519_comm_monoid`) • we then prove the relation between point addition and doubling formulas in projective and affine coordinates (`mk_ed25519_concrete_ops`) • finally, we can obtain any implementation of exponentiation, e.g., a double fixed-window method, by providing the corresponding instance of the `concrete_ops` type class (`point_mul_double`) Another example is using Montgomery arithmetic (code/bignum) to compute a modular exponentiation (lib/Lib.NatMod). *) inline_for_extraction class to_comm_monoid (t:Type) = { a_spec: Type; comm_monoid: S.comm_monoid a_spec; refl: x:t -> a_spec; } inline_for_extraction let one_st (t:Type) (to:to_comm_monoid t) = unit -> Pure t (requires True) (ensures fun one -> to.refl one == to.comm_monoid.S.one) inline_for_extraction let mul_st (t:Type) (to:to_comm_monoid t) = x:t -> y:t -> Pure t (requires True) (ensures fun xy -> to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl y)) inline_for_extraction let sqr_st (t:Type) (to:to_comm_monoid t) = x:t -> Pure t (requires True) (ensures fun xy -> to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl x)) inline_for_extraction class concrete_ops (t:Type) = { to: to_comm_monoid t; one: one_st t to; mul: mul_st t to; sqr: sqr_st t to; } let exp_rl_f (#t:Type) (k:concrete_ops t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (S.get_ith_bit bBits b i = 0) then acc else k.mul acc c in let c = k.sqr c in (acc, c) let exp_rl (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let one = k.one () in let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc val exp_rl_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (k.to.refl (exp_rl k a bBits b) == S.exp_rl k.to.comm_monoid (k.to.refl a) bBits b) let exp_mont_ladder_swap_f (#t:Type) (k:concrete_ops t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat = let bit = S.get_ith_bit bBits b (bBits - 1 - i) in let sw = (bit + privbit) % 2 in let r0, r1 = S.cswap sw r0 r1 in let r0, r1 = (k.sqr r0, k.mul r1 r0) in (r0, r1, bit) let exp_mont_ladder_swap (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1, sw) = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one (), a, 0) in let (r0, r1) = S.cswap sw r0 r1 in r0 val exp_mont_ladder_swap_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (k.to.refl (exp_mont_ladder_swap k a bBits b) == S.exp_mont_ladder_swap k.to.comm_monoid (k.to.refl a) bBits b) let exp_pow2 (#t:Type) (k:concrete_ops t) (a:t) (b:nat) : t = Loops.repeat b k.sqr a val exp_pow2_lemma: #t:Type -> k:concrete_ops t -> a:t -> b:nat -> Lemma (k.to.refl (exp_pow2 k a b) == S.exp_pow2 k.to.comm_monoid (k.to.refl a) b) [@(strict_on_arguments [3])] let rec pow (#t:Type) (k:concrete_ops t) (a:t) (b:nat) : t = if b = 0 then k.one () else k.mul a (pow k a (b - 1)) val pow_eq0: #t:Type -> k:concrete_ops t -> a:t -> Lemma (pow k a 0 == k.one ()) val pow_unfold: #t:Type -> k:concrete_ops t -> a:t -> i:pos -> Lemma (pow k a i == k.mul a (pow k a (i - 1))) val pow_lemma: #t:Type -> k:concrete_ops t -> a:t -> b:nat -> Lemma (k.to.refl (pow k a b) == S.pow k.to.comm_monoid (k.to.refl a) b) let exp_fw_acc0 (#t:Type0) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos{bBits % l <> 0}) : t = let bits_c = S.get_ith_lbits bBits b (bBits / l * l) l in pow k a bits_c let mul_acc_pow_a_bits_l (#t:Type) (k:concrete_ops t) (a:t)
false
false
Spec.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mul_acc_pow_a_bits_l (#t: Type) (k: concrete_ops t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t
[]
Spec.Exponentiation.mul_acc_pow_a_bits_l
{ "file_name": "specs/Spec.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Spec.Exponentiation.concrete_ops t -> a: t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> l: Prims.pos -> i: Prims.nat{i < bBits / l} -> acc: t -> t
{ "end_col": 28, "end_line": 156, "start_col": 2, "start_line": 154 }
Prims.Tot
val exp_four_fw_f (#t: Type) (k: concrete_ops t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (a3: t) (b3: nat{b3 < pow2 bBits}) (a4: t) (b4: nat{b4 < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "S" }, { "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", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_four_fw_f (#t:Type) (k:concrete_ops t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (a3:t) (b3:nat{b3 < pow2 bBits}) (a4:t) (b4:nat{b4 < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let acc = exp_fw_f k a4 bBits b4 l i acc in let acc = mul_acc_pow_a_bits_l k a3 bBits b3 l i acc in let acc = mul_acc_pow_a_bits_l k a2 bBits b2 l i acc in let acc = mul_acc_pow_a_bits_l k a1 bBits b1 l i acc in acc
val exp_four_fw_f (#t: Type) (k: concrete_ops t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (a3: t) (b3: nat{b3 < pow2 bBits}) (a4: t) (b4: nat{b4 < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t let exp_four_fw_f (#t: Type) (k: concrete_ops t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (a3: t) (b3: nat{b3 < pow2 bBits}) (a4: t) (b4: nat{b4 < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t =
false
null
false
let acc = exp_fw_f k a4 bBits b4 l i acc in let acc = mul_acc_pow_a_bits_l k a3 bBits b3 l i acc in let acc = mul_acc_pow_a_bits_l k a2 bBits b2 l i acc in let acc = mul_acc_pow_a_bits_l k a1 bBits b1 l i acc in acc
{ "checked_file": "Spec.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Exponentiation.fsti" }
[ "total" ]
[ "Spec.Exponentiation.concrete_ops", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.pos", "Prims.op_Division", "Spec.Exponentiation.mul_acc_pow_a_bits_l", "Spec.Exponentiation.exp_fw_f" ]
[]
module Spec.Exponentiation open FStar.Mul open Lib.IntTypes open Lib.Sequence module S = Lib.Exponentiation module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" (** This is a specification for generic exponentiation defined as a repeated application of a commutative monoid operation. • Modular Exponentiation: repeated modular multiplication • Elliptic Curve Scalar Multiplication: repeated point addition In hacl-star, in order to obtain a verified C implementation, we split our proofs into three steps: • high-level specification (lib/Lib.Exponentiation) • low-level specification (specs/Spec.Exponentiation) • low-star implementation (code/bignum/Hacl.Impl.Exponentiation) For example, to efficiently compute the EC scalar multiplication for Ed25519, we use point addition and doubling formulas in projective coordinates (see specs/Spec.Ed25519). • we first prove that (points on the curve, aff_point_add) forms a commutative monoid (`mk_ed25519_comm_monoid`) • we then prove the relation between point addition and doubling formulas in projective and affine coordinates (`mk_ed25519_concrete_ops`) • finally, we can obtain any implementation of exponentiation, e.g., a double fixed-window method, by providing the corresponding instance of the `concrete_ops` type class (`point_mul_double`) Another example is using Montgomery arithmetic (code/bignum) to compute a modular exponentiation (lib/Lib.NatMod). *) inline_for_extraction class to_comm_monoid (t:Type) = { a_spec: Type; comm_monoid: S.comm_monoid a_spec; refl: x:t -> a_spec; } inline_for_extraction let one_st (t:Type) (to:to_comm_monoid t) = unit -> Pure t (requires True) (ensures fun one -> to.refl one == to.comm_monoid.S.one) inline_for_extraction let mul_st (t:Type) (to:to_comm_monoid t) = x:t -> y:t -> Pure t (requires True) (ensures fun xy -> to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl y)) inline_for_extraction let sqr_st (t:Type) (to:to_comm_monoid t) = x:t -> Pure t (requires True) (ensures fun xy -> to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl x)) inline_for_extraction class concrete_ops (t:Type) = { to: to_comm_monoid t; one: one_st t to; mul: mul_st t to; sqr: sqr_st t to; } let exp_rl_f (#t:Type) (k:concrete_ops t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (S.get_ith_bit bBits b i = 0) then acc else k.mul acc c in let c = k.sqr c in (acc, c) let exp_rl (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let one = k.one () in let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc val exp_rl_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (k.to.refl (exp_rl k a bBits b) == S.exp_rl k.to.comm_monoid (k.to.refl a) bBits b) let exp_mont_ladder_swap_f (#t:Type) (k:concrete_ops t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat = let bit = S.get_ith_bit bBits b (bBits - 1 - i) in let sw = (bit + privbit) % 2 in let r0, r1 = S.cswap sw r0 r1 in let r0, r1 = (k.sqr r0, k.mul r1 r0) in (r0, r1, bit) let exp_mont_ladder_swap (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1, sw) = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one (), a, 0) in let (r0, r1) = S.cswap sw r0 r1 in r0 val exp_mont_ladder_swap_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (k.to.refl (exp_mont_ladder_swap k a bBits b) == S.exp_mont_ladder_swap k.to.comm_monoid (k.to.refl a) bBits b) let exp_pow2 (#t:Type) (k:concrete_ops t) (a:t) (b:nat) : t = Loops.repeat b k.sqr a val exp_pow2_lemma: #t:Type -> k:concrete_ops t -> a:t -> b:nat -> Lemma (k.to.refl (exp_pow2 k a b) == S.exp_pow2 k.to.comm_monoid (k.to.refl a) b) [@(strict_on_arguments [3])] let rec pow (#t:Type) (k:concrete_ops t) (a:t) (b:nat) : t = if b = 0 then k.one () else k.mul a (pow k a (b - 1)) val pow_eq0: #t:Type -> k:concrete_ops t -> a:t -> Lemma (pow k a 0 == k.one ()) val pow_unfold: #t:Type -> k:concrete_ops t -> a:t -> i:pos -> Lemma (pow k a i == k.mul a (pow k a (i - 1))) val pow_lemma: #t:Type -> k:concrete_ops t -> a:t -> b:nat -> Lemma (k.to.refl (pow k a b) == S.pow k.to.comm_monoid (k.to.refl a) b) let exp_fw_acc0 (#t:Type0) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos{bBits % l <> 0}) : t = let bits_c = S.get_ith_lbits bBits b (bBits / l * l) l in pow k a bits_c let mul_acc_pow_a_bits_l (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let bits_l = S.get_bits_l bBits b l i in k.mul acc (pow k a bits_l) let exp_fw_f (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let acc1 = exp_pow2 k acc l in mul_acc_pow_a_bits_l k a bBits b l i acc1 let exp_fw (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos) : t = let acc0 = if bBits % l = 0 then one () else exp_fw_acc0 k a bBits b l in Loops.repeati (bBits / l) (exp_fw_f k a bBits b l) acc0 val exp_fw_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> l:pos -> Lemma (k.to.refl (exp_fw k a bBits b l) == S.exp_fw k.to.comm_monoid (k.to.refl a) bBits b l) /// Multi-Exponentiation // Double exponentiation [a1^b1 `mul` a2^b2] //------------------------------------------- let exp_double_fw_acc0 (#t:Type) (k:concrete_ops t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (l:pos{bBits % l <> 0}) : t = let acc_a1 = exp_fw_acc0 k a1 bBits b1 l in let acc_a2 = exp_fw_acc0 k a2 bBits b2 l in k.mul acc_a1 acc_a2 let exp_double_fw_f (#t:Type) (k:concrete_ops t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (l:pos) (i:nat{i < bBits / l}) (acc:t) : t = let acc1 = exp_fw_f k a2 bBits b2 l i acc in mul_acc_pow_a_bits_l k a1 bBits b1 l i acc1 let exp_double_fw (#t:Type) (k:concrete_ops t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (l:pos) : t = let acc0 = if bBits % l = 0 then one () else exp_double_fw_acc0 k a1 bBits b1 a2 b2 l in Loops.repeati (bBits / l) (exp_double_fw_f k a1 bBits b1 a2 b2 l) acc0 val exp_double_fw_lemma: #t:Type -> k:concrete_ops t -> a1:t -> bBits:nat -> b1:nat{b1 < pow2 bBits} -> a2:t -> b2:nat{b2 < pow2 bBits} -> l:pos -> Lemma (k.to.refl (exp_double_fw k a1 bBits b1 a2 b2 l) == S.exp_double_fw k.to.comm_monoid (k.to.refl a1) bBits b1 (k.to.refl a2) b2 l) // [a1^b1 `mul` a2^b2 `mul` a3^b3 `mul` a4^b4] //---------------------------------------------- let exp_four_fw_acc0 (#t:Type) (k:concrete_ops t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (a3:t) (b3:nat{b3 < pow2 bBits}) (a4:t) (b4:nat{b4 < pow2 bBits}) (l:pos{bBits % l <> 0}) : t = let acc_a12 = exp_double_fw_acc0 k a1 bBits b1 a2 b2 l in let acc_a34 = exp_double_fw_acc0 k a3 bBits b3 a4 b4 l in k.mul acc_a12 acc_a34 let exp_four_fw_f (#t:Type) (k:concrete_ops t) (a1:t) (bBits:nat) (b1:nat{b1 < pow2 bBits}) (a2:t) (b2:nat{b2 < pow2 bBits}) (a3:t) (b3:nat{b3 < pow2 bBits}) (a4:t) (b4:nat{b4 < pow2 bBits})
false
false
Spec.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val exp_four_fw_f (#t: Type) (k: concrete_ops t) (a1: t) (bBits: nat) (b1: nat{b1 < pow2 bBits}) (a2: t) (b2: nat{b2 < pow2 bBits}) (a3: t) (b3: nat{b3 < pow2 bBits}) (a4: t) (b4: nat{b4 < pow2 bBits}) (l: pos) (i: nat{i < bBits / l}) (acc: t) : t
[]
Spec.Exponentiation.exp_four_fw_f
{ "file_name": "specs/Spec.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Spec.Exponentiation.concrete_ops t -> a1: t -> bBits: Prims.nat -> b1: Prims.nat{b1 < Prims.pow2 bBits} -> a2: t -> b2: Prims.nat{b2 < Prims.pow2 bBits} -> a3: t -> b3: Prims.nat{b3 < Prims.pow2 bBits} -> a4: t -> b4: Prims.nat{b4 < Prims.pow2 bBits} -> l: Prims.pos -> i: Prims.nat{i < bBits / l} -> acc: t -> t
{ "end_col": 5, "end_line": 243, "start_col": 2, "start_line": 238 }
Prims.Tot
val exp_fw_acc0 (#t: Type0) (k: concrete_ops t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos{bBits % l <> 0}) : t
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "S" }, { "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", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let exp_fw_acc0 (#t:Type0) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) (l:pos{bBits % l <> 0}) : t = let bits_c = S.get_ith_lbits bBits b (bBits / l * l) l in pow k a bits_c
val exp_fw_acc0 (#t: Type0) (k: concrete_ops t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos{bBits % l <> 0}) : t let exp_fw_acc0 (#t: Type0) (k: concrete_ops t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos{bBits % l <> 0}) : t =
false
null
false
let bits_c = S.get_ith_lbits bBits b ((bBits / l) * l) l in pow k a bits_c
{ "checked_file": "Spec.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Exponentiation.fsti" }
[ "total" ]
[ "Spec.Exponentiation.concrete_ops", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.pos", "Prims.op_disEquality", "Prims.int", "Prims.op_Modulus", "Spec.Exponentiation.pow", "Lib.Exponentiation.get_ith_lbits", "FStar.Mul.op_Star", "Prims.op_Division" ]
[]
module Spec.Exponentiation open FStar.Mul open Lib.IntTypes open Lib.Sequence module S = Lib.Exponentiation module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" (** This is a specification for generic exponentiation defined as a repeated application of a commutative monoid operation. • Modular Exponentiation: repeated modular multiplication • Elliptic Curve Scalar Multiplication: repeated point addition In hacl-star, in order to obtain a verified C implementation, we split our proofs into three steps: • high-level specification (lib/Lib.Exponentiation) • low-level specification (specs/Spec.Exponentiation) • low-star implementation (code/bignum/Hacl.Impl.Exponentiation) For example, to efficiently compute the EC scalar multiplication for Ed25519, we use point addition and doubling formulas in projective coordinates (see specs/Spec.Ed25519). • we first prove that (points on the curve, aff_point_add) forms a commutative monoid (`mk_ed25519_comm_monoid`) • we then prove the relation between point addition and doubling formulas in projective and affine coordinates (`mk_ed25519_concrete_ops`) • finally, we can obtain any implementation of exponentiation, e.g., a double fixed-window method, by providing the corresponding instance of the `concrete_ops` type class (`point_mul_double`) Another example is using Montgomery arithmetic (code/bignum) to compute a modular exponentiation (lib/Lib.NatMod). *) inline_for_extraction class to_comm_monoid (t:Type) = { a_spec: Type; comm_monoid: S.comm_monoid a_spec; refl: x:t -> a_spec; } inline_for_extraction let one_st (t:Type) (to:to_comm_monoid t) = unit -> Pure t (requires True) (ensures fun one -> to.refl one == to.comm_monoid.S.one) inline_for_extraction let mul_st (t:Type) (to:to_comm_monoid t) = x:t -> y:t -> Pure t (requires True) (ensures fun xy -> to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl y)) inline_for_extraction let sqr_st (t:Type) (to:to_comm_monoid t) = x:t -> Pure t (requires True) (ensures fun xy -> to.refl xy == to.comm_monoid.S.mul (to.refl x) (to.refl x)) inline_for_extraction class concrete_ops (t:Type) = { to: to_comm_monoid t; one: one_st t to; mul: mul_st t to; sqr: sqr_st t to; } let exp_rl_f (#t:Type) (k:concrete_ops t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((acc, c) : tuple2 t t) : tuple2 t t = let acc = if (S.get_ith_bit bBits b i = 0) then acc else k.mul acc c in let c = k.sqr c in (acc, c) let exp_rl (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let one = k.one () in let (acc, c) = Loops.repeati bBits (exp_rl_f k bBits b) (one, a) in acc val exp_rl_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (k.to.refl (exp_rl k a bBits b) == S.exp_rl k.to.comm_monoid (k.to.refl a) bBits b) let exp_mont_ladder_swap_f (#t:Type) (k:concrete_ops t) (bBits:nat) (b:nat{b < pow2 bBits}) (i:nat{i < bBits}) ((r0, r1, privbit) : tuple3 t t nat) : tuple3 t t nat = let bit = S.get_ith_bit bBits b (bBits - 1 - i) in let sw = (bit + privbit) % 2 in let r0, r1 = S.cswap sw r0 r1 in let r0, r1 = (k.sqr r0, k.mul r1 r0) in (r0, r1, bit) let exp_mont_ladder_swap (#t:Type) (k:concrete_ops t) (a:t) (bBits:nat) (b:nat{b < pow2 bBits}) : t = let (r0, r1, sw) = Loops.repeati bBits (exp_mont_ladder_swap_f k bBits b) (one (), a, 0) in let (r0, r1) = S.cswap sw r0 r1 in r0 val exp_mont_ladder_swap_lemma: #t:Type -> k:concrete_ops t -> a:t -> bBits:nat -> b:nat{b < pow2 bBits} -> Lemma (k.to.refl (exp_mont_ladder_swap k a bBits b) == S.exp_mont_ladder_swap k.to.comm_monoid (k.to.refl a) bBits b) let exp_pow2 (#t:Type) (k:concrete_ops t) (a:t) (b:nat) : t = Loops.repeat b k.sqr a val exp_pow2_lemma: #t:Type -> k:concrete_ops t -> a:t -> b:nat -> Lemma (k.to.refl (exp_pow2 k a b) == S.exp_pow2 k.to.comm_monoid (k.to.refl a) b) [@(strict_on_arguments [3])] let rec pow (#t:Type) (k:concrete_ops t) (a:t) (b:nat) : t = if b = 0 then k.one () else k.mul a (pow k a (b - 1)) val pow_eq0: #t:Type -> k:concrete_ops t -> a:t -> Lemma (pow k a 0 == k.one ()) val pow_unfold: #t:Type -> k:concrete_ops t -> a:t -> i:pos -> Lemma (pow k a i == k.mul a (pow k a (i - 1))) val pow_lemma: #t:Type -> k:concrete_ops t -> a:t -> b:nat -> Lemma (k.to.refl (pow k a b) == S.pow k.to.comm_monoid (k.to.refl a) b) let exp_fw_acc0 (#t:Type0) (k:concrete_ops t) (a:t)
false
false
Spec.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val exp_fw_acc0 (#t: Type0) (k: concrete_ops t) (a: t) (bBits: nat) (b: nat{b < pow2 bBits}) (l: pos{bBits % l <> 0}) : t
[]
Spec.Exponentiation.exp_fw_acc0
{ "file_name": "specs/Spec.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Spec.Exponentiation.concrete_ops t -> a: t -> bBits: Prims.nat -> b: Prims.nat{b < Prims.pow2 bBits} -> l: Prims.pos{bBits % l <> 0} -> t
{ "end_col": 16, "end_line": 149, "start_col": 2, "start_line": 147 }
FStar.Tactics.Effect.Tac
[ { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let int_canon = fun _ -> norm [delta; zeta; iota]; int_semiring ()
let int_canon =
true
null
false
fun _ -> norm [delta; zeta; iota]; int_semiring ()
{ "checked_file": "Vale.Curve25519.FastUtil_helpers.fsti.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.Fast_defs.fst.checked", "prims.fst.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Curve25519.FastUtil_helpers.fsti" }
[]
[ "FStar.Tactics.CanonCommSemiring.int_semiring", "Prims.unit", "FStar.Tactics.V1.Builtins.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta", "FStar.Pervasives.zeta", "FStar.Pervasives.iota", "Prims.Nil" ]
[]
module Vale.Curve25519.FastUtil_helpers open Vale.Def.Words_s open Vale.Def.Types_s open FStar.Mul open FStar.Tactics open FStar.Tactics.CanonCommSemiring open Vale.Curve25519.Fast_defs
false
false
Vale.Curve25519.FastUtil_helpers.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val int_canon : _: _ -> FStar.Tactics.Effect.Tac Prims.unit
[]
Vale.Curve25519.FastUtil_helpers.int_canon
{ "file_name": "vale/code/crypto/ecc/curve25519/Vale.Curve25519.FastUtil_helpers.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: _ -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 66, "end_line": 10, "start_col": 16, "start_line": 10 }
Prims.Tot
val sub_carry (x y: nat64) (c: bit) : nat64 & bit
[ { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sub_carry (x y:nat64) (c:bit) : nat64 & bit = if x - (y + c) < 0 then (x - (y + c) + pow2_64, 1) else (x - (y + c)), 0
val sub_carry (x y: nat64) (c: bit) : nat64 & bit let sub_carry (x y: nat64) (c: bit) : nat64 & bit =
false
null
false
if x - (y + c) < 0 then (x - (y + c) + pow2_64, 1) else (x - (y + c)), 0
{ "checked_file": "Vale.Curve25519.FastUtil_helpers.fsti.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.Fast_defs.fst.checked", "prims.fst.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Curve25519.FastUtil_helpers.fsti" }
[ "total" ]
[ "Vale.Def.Types_s.nat64", "Vale.Curve25519.Fast_defs.bit", "Prims.op_LessThan", "Prims.op_Subtraction", "Prims.op_Addition", "FStar.Pervasives.Native.Mktuple2", "Vale.Def.Words_s.pow2_64", "Prims.bool", "FStar.Pervasives.Native.tuple2" ]
[]
module Vale.Curve25519.FastUtil_helpers open Vale.Def.Words_s open Vale.Def.Types_s open FStar.Mul open FStar.Tactics open FStar.Tactics.CanonCommSemiring open Vale.Curve25519.Fast_defs let int_canon = fun _ -> norm [delta; zeta; iota]; int_semiring () //; dump "Final" let sub_carry (x y:nat64) (c:bit) : nat64 & bit
false
true
Vale.Curve25519.FastUtil_helpers.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sub_carry (x y: nat64) (c: bit) : nat64 & bit
[]
Vale.Curve25519.FastUtil_helpers.sub_carry
{ "file_name": "vale/code/crypto/ecc/curve25519/Vale.Curve25519.FastUtil_helpers.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Vale.Def.Types_s.nat64 -> y: Vale.Def.Types_s.nat64 -> c: Vale.Curve25519.Fast_defs.bit -> Vale.Def.Types_s.nat64 * Vale.Curve25519.Fast_defs.bit
{ "end_col": 20, "end_line": 17, "start_col": 2, "start_line": 14 }
Prims.Tot
val ptr_of (#elt: Type) (a: array elt) : Tot (ptr elt)
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": true, "full_module": "FStar.PtrdiffT", "short_module": "UP" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "P" }, { "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 } ]
false
let ptr_of (#elt: Type) (a: array elt) : Tot (ptr elt) = match a with // dfst is not marked inline_for_extraction, so we need to reimplement it | (| p, _ |) -> p
val ptr_of (#elt: Type) (a: array elt) : Tot (ptr elt) let ptr_of (#elt: Type) (a: array elt) : Tot (ptr elt) =
false
null
false
match a with | (| p , _ |) -> p
{ "checked_file": "Steel.ST.Array.fsti.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.PtrdiffT.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.Array.fsti" }
[ "total" ]
[ "Steel.ST.Array.array", "Steel.ST.Array.ptr", "FStar.Ghost.erased", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Steel.ST.Array.offset", "FStar.Ghost.reveal", "Steel.ST.Array.base_len", "Steel.ST.Array.base" ]
[]
(* Copyright 2020, 2021, 2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.ST.Array /// C arrays of universe 0 elements, with selectors. module P = Steel.FractionalPermission module US = FStar.SizeT module UP = FStar.PtrdiffT open Steel.ST.Util /// NOTE: This module is defined on top of Steel.HigherArray, so its /// definitions are all meant to be inlined and benefit from the /// latter module's primitive extraction. We seal it under an /// interface to avoid unpleasantly leaking the lifting of values /// of lower universes into the SMT context. Due to this interface, /// cross-module inlining must be enabled using F*'s --cmi option. /// An abstract type to represent a base array (whole allocation /// unit), exposed for proof purposes only [@@erasable] val base_t (elt: Type0) : Tot Type0 val base_len (#elt: Type) (b: base_t elt) : GTot nat /// An abstract type to represent a C pointer, as a base and an offset /// into its base inline_for_extraction [@@noextract_to "krml"] val ptr ([@@@unused] elt: Type0) : Type0 inline_for_extraction [@@noextract_to "krml"] val null_ptr (elt: Type0) : ptr elt // TODO: turn into a stateful operation to avoid comparing dangling pointers inline_for_extraction [@@noextract_to "krml"] val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null_ptr elt)) val base (#elt: Type) (p: ptr elt) : Tot (base_t elt) val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p))) val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma (requires ( base p1 == base p2 /\ offset p1 == offset p2 )) (ensures ( p1 == p2 )) val base_len_null_ptr (elt: Type0) : Lemma (base_len (base (null_ptr elt)) == 0) [SMTPat (base_len (base (null_ptr elt)))] /// A concrete type to represent a C array, as a C pointer and a ghost /// array length. By virtue of the length being ghost, Karamel will /// extract this type as just ptr, but to inline the definition of /// this type, we use standard dependent pairs instead of a custom /// record type. inline_for_extraction [@@noextract_to "krml"] let array ([@@@strictly_positive] elt: Type0) : Tot Type0 = (p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)})) inline_for_extraction [@@noextract_to "krml"] let null (#a: Type0) : array a = (| null_ptr a, Ghost.hide 0 |) /// This will extract to "let p = a" inline_for_extraction [@@noextract_to "krml"] let ptr_of (#elt: Type) (a: array elt)
false
false
Steel.ST.Array.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ptr_of (#elt: Type) (a: array elt) : Tot (ptr elt)
[]
Steel.ST.Array.ptr_of
{ "file_name": "lib/steel/Steel.ST.Array.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
a: Steel.ST.Array.array elt -> Steel.ST.Array.ptr elt
{ "end_col": 19, "end_line": 91, "start_col": 2, "start_line": 90 }
Prims.GTot
val length (#elt: Type) (a: array elt) : GTot nat
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": true, "full_module": "FStar.PtrdiffT", "short_module": "UP" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "P" }, { "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 } ]
false
let length (#elt: Type) (a: array elt) : GTot nat = dsnd a
val length (#elt: Type) (a: array elt) : GTot nat let length (#elt: Type) (a: array elt) : GTot nat =
false
null
false
dsnd a
{ "checked_file": "Steel.ST.Array.fsti.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.PtrdiffT.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.Array.fsti" }
[ "sometrivial" ]
[ "Steel.ST.Array.array", "FStar.Ghost.reveal", "Prims.nat", "FStar.Pervasives.dsnd", "Steel.ST.Array.ptr", "FStar.Ghost.erased", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Steel.ST.Array.offset", "Steel.ST.Array.base_len", "Steel.ST.Array.base" ]
[]
(* Copyright 2020, 2021, 2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.ST.Array /// C arrays of universe 0 elements, with selectors. module P = Steel.FractionalPermission module US = FStar.SizeT module UP = FStar.PtrdiffT open Steel.ST.Util /// NOTE: This module is defined on top of Steel.HigherArray, so its /// definitions are all meant to be inlined and benefit from the /// latter module's primitive extraction. We seal it under an /// interface to avoid unpleasantly leaking the lifting of values /// of lower universes into the SMT context. Due to this interface, /// cross-module inlining must be enabled using F*'s --cmi option. /// An abstract type to represent a base array (whole allocation /// unit), exposed for proof purposes only [@@erasable] val base_t (elt: Type0) : Tot Type0 val base_len (#elt: Type) (b: base_t elt) : GTot nat /// An abstract type to represent a C pointer, as a base and an offset /// into its base inline_for_extraction [@@noextract_to "krml"] val ptr ([@@@unused] elt: Type0) : Type0 inline_for_extraction [@@noextract_to "krml"] val null_ptr (elt: Type0) : ptr elt // TODO: turn into a stateful operation to avoid comparing dangling pointers inline_for_extraction [@@noextract_to "krml"] val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null_ptr elt)) val base (#elt: Type) (p: ptr elt) : Tot (base_t elt) val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p))) val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma (requires ( base p1 == base p2 /\ offset p1 == offset p2 )) (ensures ( p1 == p2 )) val base_len_null_ptr (elt: Type0) : Lemma (base_len (base (null_ptr elt)) == 0) [SMTPat (base_len (base (null_ptr elt)))] /// A concrete type to represent a C array, as a C pointer and a ghost /// array length. By virtue of the length being ghost, Karamel will /// extract this type as just ptr, but to inline the definition of /// this type, we use standard dependent pairs instead of a custom /// record type. inline_for_extraction [@@noextract_to "krml"] let array ([@@@strictly_positive] elt: Type0) : Tot Type0 = (p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)})) inline_for_extraction [@@noextract_to "krml"] let null (#a: Type0) : array a = (| null_ptr a, Ghost.hide 0 |) /// This will extract to "let p = a" inline_for_extraction [@@noextract_to "krml"] let ptr_of (#elt: Type) (a: array elt) : Tot (ptr elt) = match a with // dfst is not marked inline_for_extraction, so we need to reimplement it | (| p, _ |) -> p inline_for_extraction [@@noextract_to "krml"] let is_null (#a: Type0) (p: array a) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null)) = is_null_ptr (ptr_of p) /// Returns the length of the array. Usable for specification and proof purposes, /// as modeled by the GTot effect
false
false
Steel.ST.Array.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val length (#elt: Type) (a: array elt) : GTot nat
[]
Steel.ST.Array.length
{ "file_name": "lib/steel/Steel.ST.Array.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
a: Steel.ST.Array.array elt -> Prims.GTot Prims.nat
{ "end_col": 8, "end_line": 103, "start_col": 2, "start_line": 103 }
Steel.ST.Effect.ST
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": true, "full_module": "FStar.PtrdiffT", "short_module": "UP" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "P" }, { "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 } ]
false
let alloc #elt = malloc #elt
let alloc #elt =
true
null
false
malloc #elt
{ "checked_file": "Steel.ST.Array.fsti.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.PtrdiffT.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.Array.fsti" }
[]
[ "Steel.ST.Array.malloc", "FStar.SizeT.t", "Steel.ST.Array.array", "Steel.Effect.Common.emp", "Steel.ST.Array.pts_to", "Steel.FractionalPermission.full_perm", "FStar.Seq.Base.create", "FStar.SizeT.v", "Steel.Effect.Common.vprop", "Prims.l_True", "Prims.l_and", "Prims.eq2", "Prims.nat", "Steel.ST.Array.length", "Steel.ST.Array.is_full_array" ]
[]
(* Copyright 2020, 2021, 2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.ST.Array /// C arrays of universe 0 elements, with selectors. module P = Steel.FractionalPermission module US = FStar.SizeT module UP = FStar.PtrdiffT open Steel.ST.Util /// NOTE: This module is defined on top of Steel.HigherArray, so its /// definitions are all meant to be inlined and benefit from the /// latter module's primitive extraction. We seal it under an /// interface to avoid unpleasantly leaking the lifting of values /// of lower universes into the SMT context. Due to this interface, /// cross-module inlining must be enabled using F*'s --cmi option. /// An abstract type to represent a base array (whole allocation /// unit), exposed for proof purposes only [@@erasable] val base_t (elt: Type0) : Tot Type0 val base_len (#elt: Type) (b: base_t elt) : GTot nat /// An abstract type to represent a C pointer, as a base and an offset /// into its base inline_for_extraction [@@noextract_to "krml"] val ptr ([@@@unused] elt: Type0) : Type0 inline_for_extraction [@@noextract_to "krml"] val null_ptr (elt: Type0) : ptr elt // TODO: turn into a stateful operation to avoid comparing dangling pointers inline_for_extraction [@@noextract_to "krml"] val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null_ptr elt)) val base (#elt: Type) (p: ptr elt) : Tot (base_t elt) val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p))) val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma (requires ( base p1 == base p2 /\ offset p1 == offset p2 )) (ensures ( p1 == p2 )) val base_len_null_ptr (elt: Type0) : Lemma (base_len (base (null_ptr elt)) == 0) [SMTPat (base_len (base (null_ptr elt)))] /// A concrete type to represent a C array, as a C pointer and a ghost /// array length. By virtue of the length being ghost, Karamel will /// extract this type as just ptr, but to inline the definition of /// this type, we use standard dependent pairs instead of a custom /// record type. inline_for_extraction [@@noextract_to "krml"] let array ([@@@strictly_positive] elt: Type0) : Tot Type0 = (p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)})) inline_for_extraction [@@noextract_to "krml"] let null (#a: Type0) : array a = (| null_ptr a, Ghost.hide 0 |) /// This will extract to "let p = a" inline_for_extraction [@@noextract_to "krml"] let ptr_of (#elt: Type) (a: array elt) : Tot (ptr elt) = match a with // dfst is not marked inline_for_extraction, so we need to reimplement it | (| p, _ |) -> p inline_for_extraction [@@noextract_to "krml"] let is_null (#a: Type0) (p: array a) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null)) = is_null_ptr (ptr_of p) /// Returns the length of the array. Usable for specification and proof purposes, /// as modeled by the GTot effect let length (#elt: Type) (a: array elt) : GTot nat = dsnd a val length_fits (#elt: Type) (a: array elt) : Lemma (US.fits (length a)) /// An abbreviation refining an array by its length inline_for_extraction [@@noextract_to "krml"] let larray (t:Type) (n:nat) = a:array t{ length a = n } /// The main representation predicate: /// A Steel separation logic heap predicate to describe that an array /// a points to some element sequence s with some permission p. /// /// A big design decision in this library was whether the second index /// of this predicate should be a [lseq t (length a)] or just a [seq t]. /// /// Making it an [lseq] forces every specification to be strongly /// typed, in the sense that the logical representation of an array /// has to be a sequence of the right length. This can be a little /// cumbersome in specifications, particularly as the refinement appears /// in some cases beneath the [erased] constructor. /// /// So, we opted instead to let the index be just a [seq t], and /// requiring length refinements on it in certain functions, only when /// necessary. val pts_to (#elt: Type0) (a: array elt) (p: P.perm) ([@@@ smt_fallback ] s: Seq.seq elt) : Tot vprop /// A stateful lemma to relate the size of an array with the size /// of the element sequence it points to /// This ghost function proves that an array always points to a /// sequence of the appropriate length val pts_to_length (#opened: _) (#elt: Type0) (#p: P.perm) (a: array elt) (s: Seq.seq elt) : STGhost unit opened (pts_to a p s) (fun _ -> pts_to a p s) (True) (fun _ -> Seq.length s == length a) val pts_to_not_null (#opened: _) (#elt: Type0) (#p: P.perm) (a: array elt) (s: Seq.seq elt) : STGhost unit opened (pts_to a p s) (fun _ -> pts_to a p s) (True) (fun _ -> a =!= null) /// An injectivity property, needed only to define a selector. Such a /// selector can be only defined in universe 0, and universes are not /// cumulative, so we need to define a separate module for arrays of /// universe 0 elements with selectors, reusing definitions from this /// interface, but we do not want to use `friend`. val pts_to_inj (#elt: Type0) (a: array elt) (p1: P.perm) (s1: Seq.seq elt) (p2: P.perm) (s2: Seq.seq elt) (m: mem) : Lemma (requires ( interp (hp_of (pts_to a p1 s1)) m /\ interp (hp_of (pts_to a p2 s2)) m )) (ensures ( s1 == s2 )) /// Allocating a new array of size n, where each cell is initialized /// with value x. We define the non-selector version of this operation /// (and others) with a _pt suffix in the name. let is_full_array (#elt: Type) (a: array elt) : Tot prop = length a == base_len (base (ptr_of a)) inline_for_extraction [@@noextract_to "krml"] val malloc (#elt: Type) (x: elt) (n: US.t) : ST (array elt) emp (fun a -> pts_to a P.full_perm (Seq.create (US.v n) x)) (True) (fun a -> length a == US.v n /\ is_full_array a ) inline_for_extraction
false
false
Steel.ST.Array.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val alloc : x: elt -> n: FStar.SizeT.t -> Steel.ST.Effect.ST (Steel.ST.Array.array elt)
[]
Steel.ST.Array.alloc
{ "file_name": "lib/steel/Steel.ST.Array.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
x: elt -> n: FStar.SizeT.t -> Steel.ST.Effect.ST (Steel.ST.Array.array elt)
{ "end_col": 28, "end_line": 207, "start_col": 17, "start_line": 207 }
Steel.ST.Effect.ST
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": true, "full_module": "FStar.PtrdiffT", "short_module": "UP" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "P" }, { "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 } ]
false
let read #t #p = index #t #p
let read #t #p =
true
null
false
index #t #p
{ "checked_file": "Steel.ST.Array.fsti.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.PtrdiffT.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.Array.fsti" }
[]
[ "Steel.FractionalPermission.perm", "Steel.ST.Array.index", "Steel.ST.Array.array", "FStar.Ghost.erased", "FStar.Seq.Base.seq", "FStar.SizeT.t", "Steel.ST.Array.pts_to", "FStar.Ghost.reveal", "Steel.Effect.Common.vprop", "Prims.l_or", "Prims.b2t", "Prims.op_LessThan", "FStar.SizeT.v", "Steel.ST.Array.length", "FStar.Seq.Base.length", "Prims.l_True", "Prims.l_and", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.index" ]
[]
(* Copyright 2020, 2021, 2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.ST.Array /// C arrays of universe 0 elements, with selectors. module P = Steel.FractionalPermission module US = FStar.SizeT module UP = FStar.PtrdiffT open Steel.ST.Util /// NOTE: This module is defined on top of Steel.HigherArray, so its /// definitions are all meant to be inlined and benefit from the /// latter module's primitive extraction. We seal it under an /// interface to avoid unpleasantly leaking the lifting of values /// of lower universes into the SMT context. Due to this interface, /// cross-module inlining must be enabled using F*'s --cmi option. /// An abstract type to represent a base array (whole allocation /// unit), exposed for proof purposes only [@@erasable] val base_t (elt: Type0) : Tot Type0 val base_len (#elt: Type) (b: base_t elt) : GTot nat /// An abstract type to represent a C pointer, as a base and an offset /// into its base inline_for_extraction [@@noextract_to "krml"] val ptr ([@@@unused] elt: Type0) : Type0 inline_for_extraction [@@noextract_to "krml"] val null_ptr (elt: Type0) : ptr elt // TODO: turn into a stateful operation to avoid comparing dangling pointers inline_for_extraction [@@noextract_to "krml"] val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null_ptr elt)) val base (#elt: Type) (p: ptr elt) : Tot (base_t elt) val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p))) val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma (requires ( base p1 == base p2 /\ offset p1 == offset p2 )) (ensures ( p1 == p2 )) val base_len_null_ptr (elt: Type0) : Lemma (base_len (base (null_ptr elt)) == 0) [SMTPat (base_len (base (null_ptr elt)))] /// A concrete type to represent a C array, as a C pointer and a ghost /// array length. By virtue of the length being ghost, Karamel will /// extract this type as just ptr, but to inline the definition of /// this type, we use standard dependent pairs instead of a custom /// record type. inline_for_extraction [@@noextract_to "krml"] let array ([@@@strictly_positive] elt: Type0) : Tot Type0 = (p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)})) inline_for_extraction [@@noextract_to "krml"] let null (#a: Type0) : array a = (| null_ptr a, Ghost.hide 0 |) /// This will extract to "let p = a" inline_for_extraction [@@noextract_to "krml"] let ptr_of (#elt: Type) (a: array elt) : Tot (ptr elt) = match a with // dfst is not marked inline_for_extraction, so we need to reimplement it | (| p, _ |) -> p inline_for_extraction [@@noextract_to "krml"] let is_null (#a: Type0) (p: array a) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null)) = is_null_ptr (ptr_of p) /// Returns the length of the array. Usable for specification and proof purposes, /// as modeled by the GTot effect let length (#elt: Type) (a: array elt) : GTot nat = dsnd a val length_fits (#elt: Type) (a: array elt) : Lemma (US.fits (length a)) /// An abbreviation refining an array by its length inline_for_extraction [@@noextract_to "krml"] let larray (t:Type) (n:nat) = a:array t{ length a = n } /// The main representation predicate: /// A Steel separation logic heap predicate to describe that an array /// a points to some element sequence s with some permission p. /// /// A big design decision in this library was whether the second index /// of this predicate should be a [lseq t (length a)] or just a [seq t]. /// /// Making it an [lseq] forces every specification to be strongly /// typed, in the sense that the logical representation of an array /// has to be a sequence of the right length. This can be a little /// cumbersome in specifications, particularly as the refinement appears /// in some cases beneath the [erased] constructor. /// /// So, we opted instead to let the index be just a [seq t], and /// requiring length refinements on it in certain functions, only when /// necessary. val pts_to (#elt: Type0) (a: array elt) (p: P.perm) ([@@@ smt_fallback ] s: Seq.seq elt) : Tot vprop /// A stateful lemma to relate the size of an array with the size /// of the element sequence it points to /// This ghost function proves that an array always points to a /// sequence of the appropriate length val pts_to_length (#opened: _) (#elt: Type0) (#p: P.perm) (a: array elt) (s: Seq.seq elt) : STGhost unit opened (pts_to a p s) (fun _ -> pts_to a p s) (True) (fun _ -> Seq.length s == length a) val pts_to_not_null (#opened: _) (#elt: Type0) (#p: P.perm) (a: array elt) (s: Seq.seq elt) : STGhost unit opened (pts_to a p s) (fun _ -> pts_to a p s) (True) (fun _ -> a =!= null) /// An injectivity property, needed only to define a selector. Such a /// selector can be only defined in universe 0, and universes are not /// cumulative, so we need to define a separate module for arrays of /// universe 0 elements with selectors, reusing definitions from this /// interface, but we do not want to use `friend`. val pts_to_inj (#elt: Type0) (a: array elt) (p1: P.perm) (s1: Seq.seq elt) (p2: P.perm) (s2: Seq.seq elt) (m: mem) : Lemma (requires ( interp (hp_of (pts_to a p1 s1)) m /\ interp (hp_of (pts_to a p2 s2)) m )) (ensures ( s1 == s2 )) /// Allocating a new array of size n, where each cell is initialized /// with value x. We define the non-selector version of this operation /// (and others) with a _pt suffix in the name. let is_full_array (#elt: Type) (a: array elt) : Tot prop = length a == base_len (base (ptr_of a)) inline_for_extraction [@@noextract_to "krml"] val malloc (#elt: Type) (x: elt) (n: US.t) : ST (array elt) emp (fun a -> pts_to a P.full_perm (Seq.create (US.v n) x)) (True) (fun a -> length a == US.v n /\ is_full_array a ) inline_for_extraction [@@noextract_to "krml"] let alloc #elt = malloc #elt /// Freeing a full array. inline_for_extraction [@@ noextract_to "krml"; warn_on_use "Steel.Array.free_pt is currently unsound in the presence of zero-size subarrays, have you collected them all?"] val free (#elt: Type) (a: array elt) : ST unit (exists_ (pts_to a P.full_perm)) (fun _ -> emp) ( is_full_array a ) (fun _ -> True) /// Sharing and gathering permissions on an array. Those only /// manipulate permissions, so they are nothing more than stateful /// lemmas. val share (#opened: _) (#elt: Type) (#x: Seq.seq elt) (a: array elt) (p p1 p2: P.perm) : STGhost unit opened (pts_to a p x) (fun _ -> pts_to a p1 x `star` pts_to a p2 x) (p == p1 `P.sum_perm` p2) (fun _ -> True) val gather (#opened: _) (#elt: Type) (a: array elt) (#x1: Seq.seq elt) (p1: P.perm) (#x2: Seq.seq elt) (p2: P.perm) : STGhost unit opened (pts_to a p1 x1 `star` pts_to a p2 x2) (fun _ -> pts_to a (p1 `P.sum_perm` p2) x1) (True) (fun _ -> x1 == x2) /// Reading the i-th element of an array a. /// TODO: we should also provide an atomic version for small types. inline_for_extraction [@@noextract_to "krml"] val index (#t: Type) (#p: P.perm) (a: array t) (#s: Ghost.erased (Seq.seq t)) (i: US.t) : ST t (pts_to a p s) (fun _ -> pts_to a p s) (US.v i < length a \/ US.v i < Seq.length s) (fun res -> Seq.length s == length a /\ US.v i < Seq.length s /\ res == Seq.index s (US.v i)) inline_for_extraction
false
false
Steel.ST.Array.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val read : a: Steel.ST.Array.array t -> i: FStar.SizeT.t -> Steel.ST.Effect.ST t
[]
Steel.ST.Array.read
{ "file_name": "lib/steel/Steel.ST.Array.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
a: Steel.ST.Array.array t -> i: FStar.SizeT.t -> Steel.ST.Effect.ST t
{ "end_col": 28, "end_line": 268, "start_col": 17, "start_line": 268 }
Prims.Tot
val array ([@@@ strictly_positive]elt: Type0) : Tot Type0
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": true, "full_module": "FStar.PtrdiffT", "short_module": "UP" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "P" }, { "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 } ]
false
let array ([@@@strictly_positive] elt: Type0) : Tot Type0 = (p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)}))
val array ([@@@ strictly_positive]elt: Type0) : Tot Type0 let array ([@@@ strictly_positive]elt: Type0) : Tot Type0 =
false
null
false
(p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)}))
{ "checked_file": "Steel.ST.Array.fsti.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.PtrdiffT.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.Array.fsti" }
[ "total" ]
[ "Prims.dtuple2", "Steel.ST.Array.ptr", "FStar.Ghost.erased", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Steel.ST.Array.offset", "FStar.Ghost.reveal", "Steel.ST.Array.base_len", "Steel.ST.Array.base" ]
[]
(* Copyright 2020, 2021, 2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.ST.Array /// C arrays of universe 0 elements, with selectors. module P = Steel.FractionalPermission module US = FStar.SizeT module UP = FStar.PtrdiffT open Steel.ST.Util /// NOTE: This module is defined on top of Steel.HigherArray, so its /// definitions are all meant to be inlined and benefit from the /// latter module's primitive extraction. We seal it under an /// interface to avoid unpleasantly leaking the lifting of values /// of lower universes into the SMT context. Due to this interface, /// cross-module inlining must be enabled using F*'s --cmi option. /// An abstract type to represent a base array (whole allocation /// unit), exposed for proof purposes only [@@erasable] val base_t (elt: Type0) : Tot Type0 val base_len (#elt: Type) (b: base_t elt) : GTot nat /// An abstract type to represent a C pointer, as a base and an offset /// into its base inline_for_extraction [@@noextract_to "krml"] val ptr ([@@@unused] elt: Type0) : Type0 inline_for_extraction [@@noextract_to "krml"] val null_ptr (elt: Type0) : ptr elt // TODO: turn into a stateful operation to avoid comparing dangling pointers inline_for_extraction [@@noextract_to "krml"] val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null_ptr elt)) val base (#elt: Type) (p: ptr elt) : Tot (base_t elt) val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p))) val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma (requires ( base p1 == base p2 /\ offset p1 == offset p2 )) (ensures ( p1 == p2 )) val base_len_null_ptr (elt: Type0) : Lemma (base_len (base (null_ptr elt)) == 0) [SMTPat (base_len (base (null_ptr elt)))] /// A concrete type to represent a C array, as a C pointer and a ghost /// array length. By virtue of the length being ghost, Karamel will /// extract this type as just ptr, but to inline the definition of /// this type, we use standard dependent pairs instead of a custom /// record type. inline_for_extraction [@@noextract_to "krml"]
false
true
Steel.ST.Array.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val array ([@@@ strictly_positive]elt: Type0) : Tot Type0
[]
Steel.ST.Array.array
{ "file_name": "lib/steel/Steel.ST.Array.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
elt: Type0 -> Type0
{ "end_col": 84, "end_line": 76, "start_col": 2, "start_line": 76 }
Prims.Tot
val merge_into (#elt: Type) (a1 a2 a: array elt) : Tot prop
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": true, "full_module": "FStar.PtrdiffT", "short_module": "UP" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "P" }, { "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 } ]
false
let merge_into (#elt: Type) (a1 a2 a: array elt) : Tot prop = adjacent a1 a2 /\ merge a1 a2 == a
val merge_into (#elt: Type) (a1 a2 a: array elt) : Tot prop let merge_into (#elt: Type) (a1 a2 a: array elt) : Tot prop =
false
null
false
adjacent a1 a2 /\ merge a1 a2 == a
{ "checked_file": "Steel.ST.Array.fsti.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.PtrdiffT.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.Array.fsti" }
[ "total" ]
[ "Steel.ST.Array.array", "Prims.l_and", "Steel.ST.Array.adjacent", "Prims.eq2", "Steel.ST.Array.merge", "FStar.Ghost.hide", "Prims.prop" ]
[]
(* Copyright 2020, 2021, 2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.ST.Array /// C arrays of universe 0 elements, with selectors. module P = Steel.FractionalPermission module US = FStar.SizeT module UP = FStar.PtrdiffT open Steel.ST.Util /// NOTE: This module is defined on top of Steel.HigherArray, so its /// definitions are all meant to be inlined and benefit from the /// latter module's primitive extraction. We seal it under an /// interface to avoid unpleasantly leaking the lifting of values /// of lower universes into the SMT context. Due to this interface, /// cross-module inlining must be enabled using F*'s --cmi option. /// An abstract type to represent a base array (whole allocation /// unit), exposed for proof purposes only [@@erasable] val base_t (elt: Type0) : Tot Type0 val base_len (#elt: Type) (b: base_t elt) : GTot nat /// An abstract type to represent a C pointer, as a base and an offset /// into its base inline_for_extraction [@@noextract_to "krml"] val ptr ([@@@unused] elt: Type0) : Type0 inline_for_extraction [@@noextract_to "krml"] val null_ptr (elt: Type0) : ptr elt // TODO: turn into a stateful operation to avoid comparing dangling pointers inline_for_extraction [@@noextract_to "krml"] val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null_ptr elt)) val base (#elt: Type) (p: ptr elt) : Tot (base_t elt) val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p))) val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma (requires ( base p1 == base p2 /\ offset p1 == offset p2 )) (ensures ( p1 == p2 )) val base_len_null_ptr (elt: Type0) : Lemma (base_len (base (null_ptr elt)) == 0) [SMTPat (base_len (base (null_ptr elt)))] /// A concrete type to represent a C array, as a C pointer and a ghost /// array length. By virtue of the length being ghost, Karamel will /// extract this type as just ptr, but to inline the definition of /// this type, we use standard dependent pairs instead of a custom /// record type. inline_for_extraction [@@noextract_to "krml"] let array ([@@@strictly_positive] elt: Type0) : Tot Type0 = (p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)})) inline_for_extraction [@@noextract_to "krml"] let null (#a: Type0) : array a = (| null_ptr a, Ghost.hide 0 |) /// This will extract to "let p = a" inline_for_extraction [@@noextract_to "krml"] let ptr_of (#elt: Type) (a: array elt) : Tot (ptr elt) = match a with // dfst is not marked inline_for_extraction, so we need to reimplement it | (| p, _ |) -> p inline_for_extraction [@@noextract_to "krml"] let is_null (#a: Type0) (p: array a) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null)) = is_null_ptr (ptr_of p) /// Returns the length of the array. Usable for specification and proof purposes, /// as modeled by the GTot effect let length (#elt: Type) (a: array elt) : GTot nat = dsnd a val length_fits (#elt: Type) (a: array elt) : Lemma (US.fits (length a)) /// An abbreviation refining an array by its length inline_for_extraction [@@noextract_to "krml"] let larray (t:Type) (n:nat) = a:array t{ length a = n } /// The main representation predicate: /// A Steel separation logic heap predicate to describe that an array /// a points to some element sequence s with some permission p. /// /// A big design decision in this library was whether the second index /// of this predicate should be a [lseq t (length a)] or just a [seq t]. /// /// Making it an [lseq] forces every specification to be strongly /// typed, in the sense that the logical representation of an array /// has to be a sequence of the right length. This can be a little /// cumbersome in specifications, particularly as the refinement appears /// in some cases beneath the [erased] constructor. /// /// So, we opted instead to let the index be just a [seq t], and /// requiring length refinements on it in certain functions, only when /// necessary. val pts_to (#elt: Type0) (a: array elt) (p: P.perm) ([@@@ smt_fallback ] s: Seq.seq elt) : Tot vprop /// A stateful lemma to relate the size of an array with the size /// of the element sequence it points to /// This ghost function proves that an array always points to a /// sequence of the appropriate length val pts_to_length (#opened: _) (#elt: Type0) (#p: P.perm) (a: array elt) (s: Seq.seq elt) : STGhost unit opened (pts_to a p s) (fun _ -> pts_to a p s) (True) (fun _ -> Seq.length s == length a) val pts_to_not_null (#opened: _) (#elt: Type0) (#p: P.perm) (a: array elt) (s: Seq.seq elt) : STGhost unit opened (pts_to a p s) (fun _ -> pts_to a p s) (True) (fun _ -> a =!= null) /// An injectivity property, needed only to define a selector. Such a /// selector can be only defined in universe 0, and universes are not /// cumulative, so we need to define a separate module for arrays of /// universe 0 elements with selectors, reusing definitions from this /// interface, but we do not want to use `friend`. val pts_to_inj (#elt: Type0) (a: array elt) (p1: P.perm) (s1: Seq.seq elt) (p2: P.perm) (s2: Seq.seq elt) (m: mem) : Lemma (requires ( interp (hp_of (pts_to a p1 s1)) m /\ interp (hp_of (pts_to a p2 s2)) m )) (ensures ( s1 == s2 )) /// Allocating a new array of size n, where each cell is initialized /// with value x. We define the non-selector version of this operation /// (and others) with a _pt suffix in the name. let is_full_array (#elt: Type) (a: array elt) : Tot prop = length a == base_len (base (ptr_of a)) inline_for_extraction [@@noextract_to "krml"] val malloc (#elt: Type) (x: elt) (n: US.t) : ST (array elt) emp (fun a -> pts_to a P.full_perm (Seq.create (US.v n) x)) (True) (fun a -> length a == US.v n /\ is_full_array a ) inline_for_extraction [@@noextract_to "krml"] let alloc #elt = malloc #elt /// Freeing a full array. inline_for_extraction [@@ noextract_to "krml"; warn_on_use "Steel.Array.free_pt is currently unsound in the presence of zero-size subarrays, have you collected them all?"] val free (#elt: Type) (a: array elt) : ST unit (exists_ (pts_to a P.full_perm)) (fun _ -> emp) ( is_full_array a ) (fun _ -> True) /// Sharing and gathering permissions on an array. Those only /// manipulate permissions, so they are nothing more than stateful /// lemmas. val share (#opened: _) (#elt: Type) (#x: Seq.seq elt) (a: array elt) (p p1 p2: P.perm) : STGhost unit opened (pts_to a p x) (fun _ -> pts_to a p1 x `star` pts_to a p2 x) (p == p1 `P.sum_perm` p2) (fun _ -> True) val gather (#opened: _) (#elt: Type) (a: array elt) (#x1: Seq.seq elt) (p1: P.perm) (#x2: Seq.seq elt) (p2: P.perm) : STGhost unit opened (pts_to a p1 x1 `star` pts_to a p2 x2) (fun _ -> pts_to a (p1 `P.sum_perm` p2) x1) (True) (fun _ -> x1 == x2) /// Reading the i-th element of an array a. /// TODO: we should also provide an atomic version for small types. inline_for_extraction [@@noextract_to "krml"] val index (#t: Type) (#p: P.perm) (a: array t) (#s: Ghost.erased (Seq.seq t)) (i: US.t) : ST t (pts_to a p s) (fun _ -> pts_to a p s) (US.v i < length a \/ US.v i < Seq.length s) (fun res -> Seq.length s == length a /\ US.v i < Seq.length s /\ res == Seq.index s (US.v i)) inline_for_extraction [@@noextract_to "krml"] let read #t #p = index #t #p /// Writing the value v at the i-th element of an array a. /// TODO: we should also provide an atomic version for small types. inline_for_extraction [@@noextract_to "krml"] val upd (#t: Type) (a: array t) (#s: Ghost.erased (Seq.seq t)) (i: US.t {US.v i < Seq.length s}) (v: t) : STT unit (pts_to a P.full_perm s) (fun res -> pts_to a P.full_perm (Seq.upd s (US.v i) v)) inline_for_extraction [@@noextract_to "krml"] let write #t = upd #t /// An array a1 is adjacent to an array a2 if and only if they have /// the same base array and the end of a1 coincides with the beginning /// of a2 let adjacent (#elt: Type) (a1 a2: array elt) : Tot prop = base (ptr_of a1) == base (ptr_of a2) /\ offset (ptr_of a1) + (length a1) == offset (ptr_of a2) /// If two arrays are adjacent, then we can compute their merge, with /// their combined lengths. By virtue of the length being ghost, /// Karamel will extract it as "let y = a1" inline_for_extraction [@@noextract_to "krml"] let merge (#elt: Type) (a1: array elt) (a2: Ghost.erased (array elt)) : Pure (array elt) (requires (adjacent a1 a2)) (ensures (fun y -> length y == length a1 + length a2)) = (| ptr_of a1, Ghost.hide (length a1 + length a2) |) /// Adjacency and merging are associative. let merge_assoc (#elt: Type) (a1 a2 a3: array elt) : Lemma (requires ( (adjacent a1 a2 /\ adjacent a2 a3) \/ (adjacent a1 a2 /\ adjacent (merge a1 a2) a3) \/ (adjacent a2 a3 /\ adjacent a1 (merge a2 a3)) )) (ensures ( adjacent (merge a1 a2) a3 /\ adjacent a1 (merge a2 a3) /\ merge (merge a1 a2) a3 == merge a1 (merge a2 a3) )) = () /// A shortcut to combine adjacency and merging
false
false
Steel.ST.Array.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val merge_into (#elt: Type) (a1 a2 a: array elt) : Tot prop
[]
Steel.ST.Array.merge_into
{ "file_name": "lib/steel/Steel.ST.Array.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
a1: Steel.ST.Array.array elt -> a2: Steel.ST.Array.array elt -> a: Steel.ST.Array.array elt -> Prims.prop
{ "end_col": 18, "end_line": 322, "start_col": 2, "start_line": 321 }
Steel.ST.Effect.STT
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": true, "full_module": "FStar.PtrdiffT", "short_module": "UP" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "P" }, { "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 } ]
false
let write #t = upd #t
let write #t =
true
null
false
upd #t
{ "checked_file": "Steel.ST.Array.fsti.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.PtrdiffT.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.Array.fsti" }
[]
[ "Steel.ST.Array.upd", "Steel.ST.Array.array", "FStar.Ghost.erased", "FStar.Seq.Base.seq", "FStar.SizeT.t", "Prims.b2t", "Prims.op_LessThan", "FStar.SizeT.v", "FStar.Seq.Base.length", "FStar.Ghost.reveal", "Prims.unit", "Steel.ST.Array.pts_to", "Steel.FractionalPermission.full_perm", "FStar.Seq.Base.upd", "Steel.Effect.Common.vprop" ]
[]
(* Copyright 2020, 2021, 2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.ST.Array /// C arrays of universe 0 elements, with selectors. module P = Steel.FractionalPermission module US = FStar.SizeT module UP = FStar.PtrdiffT open Steel.ST.Util /// NOTE: This module is defined on top of Steel.HigherArray, so its /// definitions are all meant to be inlined and benefit from the /// latter module's primitive extraction. We seal it under an /// interface to avoid unpleasantly leaking the lifting of values /// of lower universes into the SMT context. Due to this interface, /// cross-module inlining must be enabled using F*'s --cmi option. /// An abstract type to represent a base array (whole allocation /// unit), exposed for proof purposes only [@@erasable] val base_t (elt: Type0) : Tot Type0 val base_len (#elt: Type) (b: base_t elt) : GTot nat /// An abstract type to represent a C pointer, as a base and an offset /// into its base inline_for_extraction [@@noextract_to "krml"] val ptr ([@@@unused] elt: Type0) : Type0 inline_for_extraction [@@noextract_to "krml"] val null_ptr (elt: Type0) : ptr elt // TODO: turn into a stateful operation to avoid comparing dangling pointers inline_for_extraction [@@noextract_to "krml"] val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null_ptr elt)) val base (#elt: Type) (p: ptr elt) : Tot (base_t elt) val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p))) val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma (requires ( base p1 == base p2 /\ offset p1 == offset p2 )) (ensures ( p1 == p2 )) val base_len_null_ptr (elt: Type0) : Lemma (base_len (base (null_ptr elt)) == 0) [SMTPat (base_len (base (null_ptr elt)))] /// A concrete type to represent a C array, as a C pointer and a ghost /// array length. By virtue of the length being ghost, Karamel will /// extract this type as just ptr, but to inline the definition of /// this type, we use standard dependent pairs instead of a custom /// record type. inline_for_extraction [@@noextract_to "krml"] let array ([@@@strictly_positive] elt: Type0) : Tot Type0 = (p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)})) inline_for_extraction [@@noextract_to "krml"] let null (#a: Type0) : array a = (| null_ptr a, Ghost.hide 0 |) /// This will extract to "let p = a" inline_for_extraction [@@noextract_to "krml"] let ptr_of (#elt: Type) (a: array elt) : Tot (ptr elt) = match a with // dfst is not marked inline_for_extraction, so we need to reimplement it | (| p, _ |) -> p inline_for_extraction [@@noextract_to "krml"] let is_null (#a: Type0) (p: array a) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null)) = is_null_ptr (ptr_of p) /// Returns the length of the array. Usable for specification and proof purposes, /// as modeled by the GTot effect let length (#elt: Type) (a: array elt) : GTot nat = dsnd a val length_fits (#elt: Type) (a: array elt) : Lemma (US.fits (length a)) /// An abbreviation refining an array by its length inline_for_extraction [@@noextract_to "krml"] let larray (t:Type) (n:nat) = a:array t{ length a = n } /// The main representation predicate: /// A Steel separation logic heap predicate to describe that an array /// a points to some element sequence s with some permission p. /// /// A big design decision in this library was whether the second index /// of this predicate should be a [lseq t (length a)] or just a [seq t]. /// /// Making it an [lseq] forces every specification to be strongly /// typed, in the sense that the logical representation of an array /// has to be a sequence of the right length. This can be a little /// cumbersome in specifications, particularly as the refinement appears /// in some cases beneath the [erased] constructor. /// /// So, we opted instead to let the index be just a [seq t], and /// requiring length refinements on it in certain functions, only when /// necessary. val pts_to (#elt: Type0) (a: array elt) (p: P.perm) ([@@@ smt_fallback ] s: Seq.seq elt) : Tot vprop /// A stateful lemma to relate the size of an array with the size /// of the element sequence it points to /// This ghost function proves that an array always points to a /// sequence of the appropriate length val pts_to_length (#opened: _) (#elt: Type0) (#p: P.perm) (a: array elt) (s: Seq.seq elt) : STGhost unit opened (pts_to a p s) (fun _ -> pts_to a p s) (True) (fun _ -> Seq.length s == length a) val pts_to_not_null (#opened: _) (#elt: Type0) (#p: P.perm) (a: array elt) (s: Seq.seq elt) : STGhost unit opened (pts_to a p s) (fun _ -> pts_to a p s) (True) (fun _ -> a =!= null) /// An injectivity property, needed only to define a selector. Such a /// selector can be only defined in universe 0, and universes are not /// cumulative, so we need to define a separate module for arrays of /// universe 0 elements with selectors, reusing definitions from this /// interface, but we do not want to use `friend`. val pts_to_inj (#elt: Type0) (a: array elt) (p1: P.perm) (s1: Seq.seq elt) (p2: P.perm) (s2: Seq.seq elt) (m: mem) : Lemma (requires ( interp (hp_of (pts_to a p1 s1)) m /\ interp (hp_of (pts_to a p2 s2)) m )) (ensures ( s1 == s2 )) /// Allocating a new array of size n, where each cell is initialized /// with value x. We define the non-selector version of this operation /// (and others) with a _pt suffix in the name. let is_full_array (#elt: Type) (a: array elt) : Tot prop = length a == base_len (base (ptr_of a)) inline_for_extraction [@@noextract_to "krml"] val malloc (#elt: Type) (x: elt) (n: US.t) : ST (array elt) emp (fun a -> pts_to a P.full_perm (Seq.create (US.v n) x)) (True) (fun a -> length a == US.v n /\ is_full_array a ) inline_for_extraction [@@noextract_to "krml"] let alloc #elt = malloc #elt /// Freeing a full array. inline_for_extraction [@@ noextract_to "krml"; warn_on_use "Steel.Array.free_pt is currently unsound in the presence of zero-size subarrays, have you collected them all?"] val free (#elt: Type) (a: array elt) : ST unit (exists_ (pts_to a P.full_perm)) (fun _ -> emp) ( is_full_array a ) (fun _ -> True) /// Sharing and gathering permissions on an array. Those only /// manipulate permissions, so they are nothing more than stateful /// lemmas. val share (#opened: _) (#elt: Type) (#x: Seq.seq elt) (a: array elt) (p p1 p2: P.perm) : STGhost unit opened (pts_to a p x) (fun _ -> pts_to a p1 x `star` pts_to a p2 x) (p == p1 `P.sum_perm` p2) (fun _ -> True) val gather (#opened: _) (#elt: Type) (a: array elt) (#x1: Seq.seq elt) (p1: P.perm) (#x2: Seq.seq elt) (p2: P.perm) : STGhost unit opened (pts_to a p1 x1 `star` pts_to a p2 x2) (fun _ -> pts_to a (p1 `P.sum_perm` p2) x1) (True) (fun _ -> x1 == x2) /// Reading the i-th element of an array a. /// TODO: we should also provide an atomic version for small types. inline_for_extraction [@@noextract_to "krml"] val index (#t: Type) (#p: P.perm) (a: array t) (#s: Ghost.erased (Seq.seq t)) (i: US.t) : ST t (pts_to a p s) (fun _ -> pts_to a p s) (US.v i < length a \/ US.v i < Seq.length s) (fun res -> Seq.length s == length a /\ US.v i < Seq.length s /\ res == Seq.index s (US.v i)) inline_for_extraction [@@noextract_to "krml"] let read #t #p = index #t #p /// Writing the value v at the i-th element of an array a. /// TODO: we should also provide an atomic version for small types. inline_for_extraction [@@noextract_to "krml"] val upd (#t: Type) (a: array t) (#s: Ghost.erased (Seq.seq t)) (i: US.t {US.v i < Seq.length s}) (v: t) : STT unit (pts_to a P.full_perm s) (fun res -> pts_to a P.full_perm (Seq.upd s (US.v i) v)) inline_for_extraction
false
false
Steel.ST.Array.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val write : a: Steel.ST.Array.array t -> i: FStar.SizeT.t{FStar.SizeT.v i < FStar.Seq.Base.length (FStar.Ghost.reveal s)} -> v: t -> Steel.ST.Effect.STT Prims.unit
[]
Steel.ST.Array.write
{ "file_name": "lib/steel/Steel.ST.Array.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
a: Steel.ST.Array.array t -> i: FStar.SizeT.t{FStar.SizeT.v i < FStar.Seq.Base.length (FStar.Ghost.reveal s)} -> v: t -> Steel.ST.Effect.STT Prims.unit
{ "end_col": 21, "end_line": 286, "start_col": 15, "start_line": 286 }
Prims.Tot
val is_full_array (#elt: Type) (a: array elt) : Tot prop
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": true, "full_module": "FStar.PtrdiffT", "short_module": "UP" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "P" }, { "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 } ]
false
let is_full_array (#elt: Type) (a: array elt) : Tot prop = length a == base_len (base (ptr_of a))
val is_full_array (#elt: Type) (a: array elt) : Tot prop let is_full_array (#elt: Type) (a: array elt) : Tot prop =
false
null
false
length a == base_len (base (ptr_of a))
{ "checked_file": "Steel.ST.Array.fsti.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.PtrdiffT.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.Array.fsti" }
[ "total" ]
[ "Steel.ST.Array.array", "Prims.eq2", "Prims.nat", "Steel.ST.Array.length", "Steel.ST.Array.base_len", "Steel.ST.Array.base", "Steel.ST.Array.ptr_of", "Prims.prop" ]
[]
(* Copyright 2020, 2021, 2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.ST.Array /// C arrays of universe 0 elements, with selectors. module P = Steel.FractionalPermission module US = FStar.SizeT module UP = FStar.PtrdiffT open Steel.ST.Util /// NOTE: This module is defined on top of Steel.HigherArray, so its /// definitions are all meant to be inlined and benefit from the /// latter module's primitive extraction. We seal it under an /// interface to avoid unpleasantly leaking the lifting of values /// of lower universes into the SMT context. Due to this interface, /// cross-module inlining must be enabled using F*'s --cmi option. /// An abstract type to represent a base array (whole allocation /// unit), exposed for proof purposes only [@@erasable] val base_t (elt: Type0) : Tot Type0 val base_len (#elt: Type) (b: base_t elt) : GTot nat /// An abstract type to represent a C pointer, as a base and an offset /// into its base inline_for_extraction [@@noextract_to "krml"] val ptr ([@@@unused] elt: Type0) : Type0 inline_for_extraction [@@noextract_to "krml"] val null_ptr (elt: Type0) : ptr elt // TODO: turn into a stateful operation to avoid comparing dangling pointers inline_for_extraction [@@noextract_to "krml"] val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null_ptr elt)) val base (#elt: Type) (p: ptr elt) : Tot (base_t elt) val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p))) val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma (requires ( base p1 == base p2 /\ offset p1 == offset p2 )) (ensures ( p1 == p2 )) val base_len_null_ptr (elt: Type0) : Lemma (base_len (base (null_ptr elt)) == 0) [SMTPat (base_len (base (null_ptr elt)))] /// A concrete type to represent a C array, as a C pointer and a ghost /// array length. By virtue of the length being ghost, Karamel will /// extract this type as just ptr, but to inline the definition of /// this type, we use standard dependent pairs instead of a custom /// record type. inline_for_extraction [@@noextract_to "krml"] let array ([@@@strictly_positive] elt: Type0) : Tot Type0 = (p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)})) inline_for_extraction [@@noextract_to "krml"] let null (#a: Type0) : array a = (| null_ptr a, Ghost.hide 0 |) /// This will extract to "let p = a" inline_for_extraction [@@noextract_to "krml"] let ptr_of (#elt: Type) (a: array elt) : Tot (ptr elt) = match a with // dfst is not marked inline_for_extraction, so we need to reimplement it | (| p, _ |) -> p inline_for_extraction [@@noextract_to "krml"] let is_null (#a: Type0) (p: array a) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null)) = is_null_ptr (ptr_of p) /// Returns the length of the array. Usable for specification and proof purposes, /// as modeled by the GTot effect let length (#elt: Type) (a: array elt) : GTot nat = dsnd a val length_fits (#elt: Type) (a: array elt) : Lemma (US.fits (length a)) /// An abbreviation refining an array by its length inline_for_extraction [@@noextract_to "krml"] let larray (t:Type) (n:nat) = a:array t{ length a = n } /// The main representation predicate: /// A Steel separation logic heap predicate to describe that an array /// a points to some element sequence s with some permission p. /// /// A big design decision in this library was whether the second index /// of this predicate should be a [lseq t (length a)] or just a [seq t]. /// /// Making it an [lseq] forces every specification to be strongly /// typed, in the sense that the logical representation of an array /// has to be a sequence of the right length. This can be a little /// cumbersome in specifications, particularly as the refinement appears /// in some cases beneath the [erased] constructor. /// /// So, we opted instead to let the index be just a [seq t], and /// requiring length refinements on it in certain functions, only when /// necessary. val pts_to (#elt: Type0) (a: array elt) (p: P.perm) ([@@@ smt_fallback ] s: Seq.seq elt) : Tot vprop /// A stateful lemma to relate the size of an array with the size /// of the element sequence it points to /// This ghost function proves that an array always points to a /// sequence of the appropriate length val pts_to_length (#opened: _) (#elt: Type0) (#p: P.perm) (a: array elt) (s: Seq.seq elt) : STGhost unit opened (pts_to a p s) (fun _ -> pts_to a p s) (True) (fun _ -> Seq.length s == length a) val pts_to_not_null (#opened: _) (#elt: Type0) (#p: P.perm) (a: array elt) (s: Seq.seq elt) : STGhost unit opened (pts_to a p s) (fun _ -> pts_to a p s) (True) (fun _ -> a =!= null) /// An injectivity property, needed only to define a selector. Such a /// selector can be only defined in universe 0, and universes are not /// cumulative, so we need to define a separate module for arrays of /// universe 0 elements with selectors, reusing definitions from this /// interface, but we do not want to use `friend`. val pts_to_inj (#elt: Type0) (a: array elt) (p1: P.perm) (s1: Seq.seq elt) (p2: P.perm) (s2: Seq.seq elt) (m: mem) : Lemma (requires ( interp (hp_of (pts_to a p1 s1)) m /\ interp (hp_of (pts_to a p2 s2)) m )) (ensures ( s1 == s2 )) /// Allocating a new array of size n, where each cell is initialized /// with value x. We define the non-selector version of this operation /// (and others) with a _pt suffix in the name.
false
false
Steel.ST.Array.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val is_full_array (#elt: Type) (a: array elt) : Tot prop
[]
Steel.ST.Array.is_full_array
{ "file_name": "lib/steel/Steel.ST.Array.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
a: Steel.ST.Array.array elt -> Prims.prop
{ "end_col": 40, "end_line": 188, "start_col": 2, "start_line": 188 }
Prims.Tot
val adjacent (#elt: Type) (a1 a2: array elt) : Tot prop
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": true, "full_module": "FStar.PtrdiffT", "short_module": "UP" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "P" }, { "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 } ]
false
let adjacent (#elt: Type) (a1 a2: array elt) : Tot prop = base (ptr_of a1) == base (ptr_of a2) /\ offset (ptr_of a1) + (length a1) == offset (ptr_of a2)
val adjacent (#elt: Type) (a1 a2: array elt) : Tot prop let adjacent (#elt: Type) (a1 a2: array elt) : Tot prop =
false
null
false
base (ptr_of a1) == base (ptr_of a2) /\ offset (ptr_of a1) + (length a1) == offset (ptr_of a2)
{ "checked_file": "Steel.ST.Array.fsti.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.PtrdiffT.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.Array.fsti" }
[ "total" ]
[ "Steel.ST.Array.array", "Prims.l_and", "Prims.eq2", "Steel.ST.Array.base_t", "Steel.ST.Array.base", "Steel.ST.Array.ptr_of", "Prims.int", "Prims.op_Addition", "Steel.ST.Array.offset", "Steel.ST.Array.length", "Prims.prop" ]
[]
(* Copyright 2020, 2021, 2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.ST.Array /// C arrays of universe 0 elements, with selectors. module P = Steel.FractionalPermission module US = FStar.SizeT module UP = FStar.PtrdiffT open Steel.ST.Util /// NOTE: This module is defined on top of Steel.HigherArray, so its /// definitions are all meant to be inlined and benefit from the /// latter module's primitive extraction. We seal it under an /// interface to avoid unpleasantly leaking the lifting of values /// of lower universes into the SMT context. Due to this interface, /// cross-module inlining must be enabled using F*'s --cmi option. /// An abstract type to represent a base array (whole allocation /// unit), exposed for proof purposes only [@@erasable] val base_t (elt: Type0) : Tot Type0 val base_len (#elt: Type) (b: base_t elt) : GTot nat /// An abstract type to represent a C pointer, as a base and an offset /// into its base inline_for_extraction [@@noextract_to "krml"] val ptr ([@@@unused] elt: Type0) : Type0 inline_for_extraction [@@noextract_to "krml"] val null_ptr (elt: Type0) : ptr elt // TODO: turn into a stateful operation to avoid comparing dangling pointers inline_for_extraction [@@noextract_to "krml"] val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null_ptr elt)) val base (#elt: Type) (p: ptr elt) : Tot (base_t elt) val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p))) val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma (requires ( base p1 == base p2 /\ offset p1 == offset p2 )) (ensures ( p1 == p2 )) val base_len_null_ptr (elt: Type0) : Lemma (base_len (base (null_ptr elt)) == 0) [SMTPat (base_len (base (null_ptr elt)))] /// A concrete type to represent a C array, as a C pointer and a ghost /// array length. By virtue of the length being ghost, Karamel will /// extract this type as just ptr, but to inline the definition of /// this type, we use standard dependent pairs instead of a custom /// record type. inline_for_extraction [@@noextract_to "krml"] let array ([@@@strictly_positive] elt: Type0) : Tot Type0 = (p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)})) inline_for_extraction [@@noextract_to "krml"] let null (#a: Type0) : array a = (| null_ptr a, Ghost.hide 0 |) /// This will extract to "let p = a" inline_for_extraction [@@noextract_to "krml"] let ptr_of (#elt: Type) (a: array elt) : Tot (ptr elt) = match a with // dfst is not marked inline_for_extraction, so we need to reimplement it | (| p, _ |) -> p inline_for_extraction [@@noextract_to "krml"] let is_null (#a: Type0) (p: array a) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null)) = is_null_ptr (ptr_of p) /// Returns the length of the array. Usable for specification and proof purposes, /// as modeled by the GTot effect let length (#elt: Type) (a: array elt) : GTot nat = dsnd a val length_fits (#elt: Type) (a: array elt) : Lemma (US.fits (length a)) /// An abbreviation refining an array by its length inline_for_extraction [@@noextract_to "krml"] let larray (t:Type) (n:nat) = a:array t{ length a = n } /// The main representation predicate: /// A Steel separation logic heap predicate to describe that an array /// a points to some element sequence s with some permission p. /// /// A big design decision in this library was whether the second index /// of this predicate should be a [lseq t (length a)] or just a [seq t]. /// /// Making it an [lseq] forces every specification to be strongly /// typed, in the sense that the logical representation of an array /// has to be a sequence of the right length. This can be a little /// cumbersome in specifications, particularly as the refinement appears /// in some cases beneath the [erased] constructor. /// /// So, we opted instead to let the index be just a [seq t], and /// requiring length refinements on it in certain functions, only when /// necessary. val pts_to (#elt: Type0) (a: array elt) (p: P.perm) ([@@@ smt_fallback ] s: Seq.seq elt) : Tot vprop /// A stateful lemma to relate the size of an array with the size /// of the element sequence it points to /// This ghost function proves that an array always points to a /// sequence of the appropriate length val pts_to_length (#opened: _) (#elt: Type0) (#p: P.perm) (a: array elt) (s: Seq.seq elt) : STGhost unit opened (pts_to a p s) (fun _ -> pts_to a p s) (True) (fun _ -> Seq.length s == length a) val pts_to_not_null (#opened: _) (#elt: Type0) (#p: P.perm) (a: array elt) (s: Seq.seq elt) : STGhost unit opened (pts_to a p s) (fun _ -> pts_to a p s) (True) (fun _ -> a =!= null) /// An injectivity property, needed only to define a selector. Such a /// selector can be only defined in universe 0, and universes are not /// cumulative, so we need to define a separate module for arrays of /// universe 0 elements with selectors, reusing definitions from this /// interface, but we do not want to use `friend`. val pts_to_inj (#elt: Type0) (a: array elt) (p1: P.perm) (s1: Seq.seq elt) (p2: P.perm) (s2: Seq.seq elt) (m: mem) : Lemma (requires ( interp (hp_of (pts_to a p1 s1)) m /\ interp (hp_of (pts_to a p2 s2)) m )) (ensures ( s1 == s2 )) /// Allocating a new array of size n, where each cell is initialized /// with value x. We define the non-selector version of this operation /// (and others) with a _pt suffix in the name. let is_full_array (#elt: Type) (a: array elt) : Tot prop = length a == base_len (base (ptr_of a)) inline_for_extraction [@@noextract_to "krml"] val malloc (#elt: Type) (x: elt) (n: US.t) : ST (array elt) emp (fun a -> pts_to a P.full_perm (Seq.create (US.v n) x)) (True) (fun a -> length a == US.v n /\ is_full_array a ) inline_for_extraction [@@noextract_to "krml"] let alloc #elt = malloc #elt /// Freeing a full array. inline_for_extraction [@@ noextract_to "krml"; warn_on_use "Steel.Array.free_pt is currently unsound in the presence of zero-size subarrays, have you collected them all?"] val free (#elt: Type) (a: array elt) : ST unit (exists_ (pts_to a P.full_perm)) (fun _ -> emp) ( is_full_array a ) (fun _ -> True) /// Sharing and gathering permissions on an array. Those only /// manipulate permissions, so they are nothing more than stateful /// lemmas. val share (#opened: _) (#elt: Type) (#x: Seq.seq elt) (a: array elt) (p p1 p2: P.perm) : STGhost unit opened (pts_to a p x) (fun _ -> pts_to a p1 x `star` pts_to a p2 x) (p == p1 `P.sum_perm` p2) (fun _ -> True) val gather (#opened: _) (#elt: Type) (a: array elt) (#x1: Seq.seq elt) (p1: P.perm) (#x2: Seq.seq elt) (p2: P.perm) : STGhost unit opened (pts_to a p1 x1 `star` pts_to a p2 x2) (fun _ -> pts_to a (p1 `P.sum_perm` p2) x1) (True) (fun _ -> x1 == x2) /// Reading the i-th element of an array a. /// TODO: we should also provide an atomic version for small types. inline_for_extraction [@@noextract_to "krml"] val index (#t: Type) (#p: P.perm) (a: array t) (#s: Ghost.erased (Seq.seq t)) (i: US.t) : ST t (pts_to a p s) (fun _ -> pts_to a p s) (US.v i < length a \/ US.v i < Seq.length s) (fun res -> Seq.length s == length a /\ US.v i < Seq.length s /\ res == Seq.index s (US.v i)) inline_for_extraction [@@noextract_to "krml"] let read #t #p = index #t #p /// Writing the value v at the i-th element of an array a. /// TODO: we should also provide an atomic version for small types. inline_for_extraction [@@noextract_to "krml"] val upd (#t: Type) (a: array t) (#s: Ghost.erased (Seq.seq t)) (i: US.t {US.v i < Seq.length s}) (v: t) : STT unit (pts_to a P.full_perm s) (fun res -> pts_to a P.full_perm (Seq.upd s (US.v i) v)) inline_for_extraction [@@noextract_to "krml"] let write #t = upd #t /// An array a1 is adjacent to an array a2 if and only if they have /// the same base array and the end of a1 coincides with the beginning /// of a2
false
false
Steel.ST.Array.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val adjacent (#elt: Type) (a1 a2: array elt) : Tot prop
[]
Steel.ST.Array.adjacent
{ "file_name": "lib/steel/Steel.ST.Array.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
a1: Steel.ST.Array.array elt -> a2: Steel.ST.Array.array elt -> Prims.prop
{ "end_col": 56, "end_line": 293, "start_col": 2, "start_line": 292 }
Prims.Tot
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": true, "full_module": "FStar.PtrdiffT", "short_module": "UP" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "P" }, { "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 } ]
false
let larray (t:Type) (n:nat) = a:array t{ length a = n }
let larray (t: Type) (n: nat) =
false
null
false
a: array t {length a = n}
{ "checked_file": "Steel.ST.Array.fsti.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.PtrdiffT.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.Array.fsti" }
[ "total" ]
[ "Prims.nat", "Steel.ST.Array.array", "Prims.b2t", "Prims.op_Equality", "Steel.ST.Array.length" ]
[]
(* Copyright 2020, 2021, 2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.ST.Array /// C arrays of universe 0 elements, with selectors. module P = Steel.FractionalPermission module US = FStar.SizeT module UP = FStar.PtrdiffT open Steel.ST.Util /// NOTE: This module is defined on top of Steel.HigherArray, so its /// definitions are all meant to be inlined and benefit from the /// latter module's primitive extraction. We seal it under an /// interface to avoid unpleasantly leaking the lifting of values /// of lower universes into the SMT context. Due to this interface, /// cross-module inlining must be enabled using F*'s --cmi option. /// An abstract type to represent a base array (whole allocation /// unit), exposed for proof purposes only [@@erasable] val base_t (elt: Type0) : Tot Type0 val base_len (#elt: Type) (b: base_t elt) : GTot nat /// An abstract type to represent a C pointer, as a base and an offset /// into its base inline_for_extraction [@@noextract_to "krml"] val ptr ([@@@unused] elt: Type0) : Type0 inline_for_extraction [@@noextract_to "krml"] val null_ptr (elt: Type0) : ptr elt // TODO: turn into a stateful operation to avoid comparing dangling pointers inline_for_extraction [@@noextract_to "krml"] val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null_ptr elt)) val base (#elt: Type) (p: ptr elt) : Tot (base_t elt) val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p))) val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma (requires ( base p1 == base p2 /\ offset p1 == offset p2 )) (ensures ( p1 == p2 )) val base_len_null_ptr (elt: Type0) : Lemma (base_len (base (null_ptr elt)) == 0) [SMTPat (base_len (base (null_ptr elt)))] /// A concrete type to represent a C array, as a C pointer and a ghost /// array length. By virtue of the length being ghost, Karamel will /// extract this type as just ptr, but to inline the definition of /// this type, we use standard dependent pairs instead of a custom /// record type. inline_for_extraction [@@noextract_to "krml"] let array ([@@@strictly_positive] elt: Type0) : Tot Type0 = (p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)})) inline_for_extraction [@@noextract_to "krml"] let null (#a: Type0) : array a = (| null_ptr a, Ghost.hide 0 |) /// This will extract to "let p = a" inline_for_extraction [@@noextract_to "krml"] let ptr_of (#elt: Type) (a: array elt) : Tot (ptr elt) = match a with // dfst is not marked inline_for_extraction, so we need to reimplement it | (| p, _ |) -> p inline_for_extraction [@@noextract_to "krml"] let is_null (#a: Type0) (p: array a) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null)) = is_null_ptr (ptr_of p) /// Returns the length of the array. Usable for specification and proof purposes, /// as modeled by the GTot effect let length (#elt: Type) (a: array elt) : GTot nat = dsnd a val length_fits (#elt: Type) (a: array elt) : Lemma (US.fits (length a)) /// An abbreviation refining an array by its length inline_for_extraction
false
true
Steel.ST.Array.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val larray : t: Type0 -> n: Prims.nat -> Type0
[]
Steel.ST.Array.larray
{ "file_name": "lib/steel/Steel.ST.Array.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
t: Type0 -> n: Prims.nat -> Type0
{ "end_col": 55, "end_line": 110, "start_col": 30, "start_line": 110 }
Prims.Tot
val null (#a: Type0) : array a
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": true, "full_module": "FStar.PtrdiffT", "short_module": "UP" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "P" }, { "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 } ]
false
let null (#a: Type0) : array a = (| null_ptr a, Ghost.hide 0 |)
val null (#a: Type0) : array a let null (#a: Type0) : array a =
false
null
false
(| null_ptr a, Ghost.hide 0 |)
{ "checked_file": "Steel.ST.Array.fsti.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.PtrdiffT.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.Array.fsti" }
[ "total" ]
[ "Prims.Mkdtuple2", "Steel.ST.Array.ptr", "FStar.Ghost.erased", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Steel.ST.Array.offset", "FStar.Ghost.reveal", "Steel.ST.Array.base_len", "Steel.ST.Array.base", "Steel.ST.Array.null_ptr", "FStar.Ghost.hide", "Steel.ST.Array.array" ]
[]
(* Copyright 2020, 2021, 2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.ST.Array /// C arrays of universe 0 elements, with selectors. module P = Steel.FractionalPermission module US = FStar.SizeT module UP = FStar.PtrdiffT open Steel.ST.Util /// NOTE: This module is defined on top of Steel.HigherArray, so its /// definitions are all meant to be inlined and benefit from the /// latter module's primitive extraction. We seal it under an /// interface to avoid unpleasantly leaking the lifting of values /// of lower universes into the SMT context. Due to this interface, /// cross-module inlining must be enabled using F*'s --cmi option. /// An abstract type to represent a base array (whole allocation /// unit), exposed for proof purposes only [@@erasable] val base_t (elt: Type0) : Tot Type0 val base_len (#elt: Type) (b: base_t elt) : GTot nat /// An abstract type to represent a C pointer, as a base and an offset /// into its base inline_for_extraction [@@noextract_to "krml"] val ptr ([@@@unused] elt: Type0) : Type0 inline_for_extraction [@@noextract_to "krml"] val null_ptr (elt: Type0) : ptr elt // TODO: turn into a stateful operation to avoid comparing dangling pointers inline_for_extraction [@@noextract_to "krml"] val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null_ptr elt)) val base (#elt: Type) (p: ptr elt) : Tot (base_t elt) val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p))) val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma (requires ( base p1 == base p2 /\ offset p1 == offset p2 )) (ensures ( p1 == p2 )) val base_len_null_ptr (elt: Type0) : Lemma (base_len (base (null_ptr elt)) == 0) [SMTPat (base_len (base (null_ptr elt)))] /// A concrete type to represent a C array, as a C pointer and a ghost /// array length. By virtue of the length being ghost, Karamel will /// extract this type as just ptr, but to inline the definition of /// this type, we use standard dependent pairs instead of a custom /// record type. inline_for_extraction [@@noextract_to "krml"] let array ([@@@strictly_positive] elt: Type0) : Tot Type0 = (p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)})) inline_for_extraction [@@noextract_to "krml"]
false
false
Steel.ST.Array.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val null (#a: Type0) : array a
[]
Steel.ST.Array.null
{ "file_name": "lib/steel/Steel.ST.Array.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
Steel.ST.Array.array a
{ "end_col": 32, "end_line": 81, "start_col": 2, "start_line": 81 }
Prims.Pure
val is_null (#a: Type0) (p: array a) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null))
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": true, "full_module": "FStar.PtrdiffT", "short_module": "UP" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "P" }, { "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 } ]
false
let is_null (#a: Type0) (p: array a) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null)) = is_null_ptr (ptr_of p)
val is_null (#a: Type0) (p: array a) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null)) let is_null (#a: Type0) (p: array a) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null)) =
false
null
false
is_null_ptr (ptr_of p)
{ "checked_file": "Steel.ST.Array.fsti.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.PtrdiffT.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.Array.fsti" }
[]
[ "Steel.ST.Array.array", "Steel.ST.Array.is_null_ptr", "Steel.ST.Array.ptr_of", "Prims.bool", "Prims.l_True", "Prims.l_iff", "Prims.eq2", "Steel.ST.Array.null" ]
[]
(* Copyright 2020, 2021, 2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.ST.Array /// C arrays of universe 0 elements, with selectors. module P = Steel.FractionalPermission module US = FStar.SizeT module UP = FStar.PtrdiffT open Steel.ST.Util /// NOTE: This module is defined on top of Steel.HigherArray, so its /// definitions are all meant to be inlined and benefit from the /// latter module's primitive extraction. We seal it under an /// interface to avoid unpleasantly leaking the lifting of values /// of lower universes into the SMT context. Due to this interface, /// cross-module inlining must be enabled using F*'s --cmi option. /// An abstract type to represent a base array (whole allocation /// unit), exposed for proof purposes only [@@erasable] val base_t (elt: Type0) : Tot Type0 val base_len (#elt: Type) (b: base_t elt) : GTot nat /// An abstract type to represent a C pointer, as a base and an offset /// into its base inline_for_extraction [@@noextract_to "krml"] val ptr ([@@@unused] elt: Type0) : Type0 inline_for_extraction [@@noextract_to "krml"] val null_ptr (elt: Type0) : ptr elt // TODO: turn into a stateful operation to avoid comparing dangling pointers inline_for_extraction [@@noextract_to "krml"] val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null_ptr elt)) val base (#elt: Type) (p: ptr elt) : Tot (base_t elt) val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p))) val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma (requires ( base p1 == base p2 /\ offset p1 == offset p2 )) (ensures ( p1 == p2 )) val base_len_null_ptr (elt: Type0) : Lemma (base_len (base (null_ptr elt)) == 0) [SMTPat (base_len (base (null_ptr elt)))] /// A concrete type to represent a C array, as a C pointer and a ghost /// array length. By virtue of the length being ghost, Karamel will /// extract this type as just ptr, but to inline the definition of /// this type, we use standard dependent pairs instead of a custom /// record type. inline_for_extraction [@@noextract_to "krml"] let array ([@@@strictly_positive] elt: Type0) : Tot Type0 = (p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)})) inline_for_extraction [@@noextract_to "krml"] let null (#a: Type0) : array a = (| null_ptr a, Ghost.hide 0 |) /// This will extract to "let p = a" inline_for_extraction [@@noextract_to "krml"] let ptr_of (#elt: Type) (a: array elt) : Tot (ptr elt) = match a with // dfst is not marked inline_for_extraction, so we need to reimplement it | (| p, _ |) -> p inline_for_extraction [@@noextract_to "krml"] let is_null (#a: Type0) (p: array a) : Pure bool (requires True)
false
false
Steel.ST.Array.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val is_null (#a: Type0) (p: array a) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null))
[]
Steel.ST.Array.is_null
{ "file_name": "lib/steel/Steel.ST.Array.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
p: Steel.ST.Array.array a -> Prims.Pure Prims.bool
{ "end_col": 24, "end_line": 98, "start_col": 2, "start_line": 98 }
Prims.Pure
val merge (#elt: Type) (a1: array elt) (a2: Ghost.erased (array elt)) : Pure (array elt) (requires (adjacent a1 a2)) (ensures (fun y -> length y == length a1 + length a2))
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": true, "full_module": "FStar.PtrdiffT", "short_module": "UP" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "P" }, { "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 } ]
false
let merge (#elt: Type) (a1: array elt) (a2: Ghost.erased (array elt)) : Pure (array elt) (requires (adjacent a1 a2)) (ensures (fun y -> length y == length a1 + length a2)) = (| ptr_of a1, Ghost.hide (length a1 + length a2) |)
val merge (#elt: Type) (a1: array elt) (a2: Ghost.erased (array elt)) : Pure (array elt) (requires (adjacent a1 a2)) (ensures (fun y -> length y == length a1 + length a2)) let merge (#elt: Type) (a1: array elt) (a2: Ghost.erased (array elt)) : Pure (array elt) (requires (adjacent a1 a2)) (ensures (fun y -> length y == length a1 + length a2)) =
false
null
false
(| ptr_of a1, Ghost.hide (length a1 + length a2) |)
{ "checked_file": "Steel.ST.Array.fsti.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.PtrdiffT.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.Array.fsti" }
[]
[ "Steel.ST.Array.array", "FStar.Ghost.erased", "Prims.Mkdtuple2", "Steel.ST.Array.ptr", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Steel.ST.Array.offset", "FStar.Ghost.reveal", "Steel.ST.Array.base_len", "Steel.ST.Array.base", "Steel.ST.Array.ptr_of", "FStar.Ghost.hide", "Steel.ST.Array.length", "Steel.ST.Array.adjacent", "Prims.eq2", "Prims.int" ]
[]
(* Copyright 2020, 2021, 2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.ST.Array /// C arrays of universe 0 elements, with selectors. module P = Steel.FractionalPermission module US = FStar.SizeT module UP = FStar.PtrdiffT open Steel.ST.Util /// NOTE: This module is defined on top of Steel.HigherArray, so its /// definitions are all meant to be inlined and benefit from the /// latter module's primitive extraction. We seal it under an /// interface to avoid unpleasantly leaking the lifting of values /// of lower universes into the SMT context. Due to this interface, /// cross-module inlining must be enabled using F*'s --cmi option. /// An abstract type to represent a base array (whole allocation /// unit), exposed for proof purposes only [@@erasable] val base_t (elt: Type0) : Tot Type0 val base_len (#elt: Type) (b: base_t elt) : GTot nat /// An abstract type to represent a C pointer, as a base and an offset /// into its base inline_for_extraction [@@noextract_to "krml"] val ptr ([@@@unused] elt: Type0) : Type0 inline_for_extraction [@@noextract_to "krml"] val null_ptr (elt: Type0) : ptr elt // TODO: turn into a stateful operation to avoid comparing dangling pointers inline_for_extraction [@@noextract_to "krml"] val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null_ptr elt)) val base (#elt: Type) (p: ptr elt) : Tot (base_t elt) val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p))) val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma (requires ( base p1 == base p2 /\ offset p1 == offset p2 )) (ensures ( p1 == p2 )) val base_len_null_ptr (elt: Type0) : Lemma (base_len (base (null_ptr elt)) == 0) [SMTPat (base_len (base (null_ptr elt)))] /// A concrete type to represent a C array, as a C pointer and a ghost /// array length. By virtue of the length being ghost, Karamel will /// extract this type as just ptr, but to inline the definition of /// this type, we use standard dependent pairs instead of a custom /// record type. inline_for_extraction [@@noextract_to "krml"] let array ([@@@strictly_positive] elt: Type0) : Tot Type0 = (p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)})) inline_for_extraction [@@noextract_to "krml"] let null (#a: Type0) : array a = (| null_ptr a, Ghost.hide 0 |) /// This will extract to "let p = a" inline_for_extraction [@@noextract_to "krml"] let ptr_of (#elt: Type) (a: array elt) : Tot (ptr elt) = match a with // dfst is not marked inline_for_extraction, so we need to reimplement it | (| p, _ |) -> p inline_for_extraction [@@noextract_to "krml"] let is_null (#a: Type0) (p: array a) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null)) = is_null_ptr (ptr_of p) /// Returns the length of the array. Usable for specification and proof purposes, /// as modeled by the GTot effect let length (#elt: Type) (a: array elt) : GTot nat = dsnd a val length_fits (#elt: Type) (a: array elt) : Lemma (US.fits (length a)) /// An abbreviation refining an array by its length inline_for_extraction [@@noextract_to "krml"] let larray (t:Type) (n:nat) = a:array t{ length a = n } /// The main representation predicate: /// A Steel separation logic heap predicate to describe that an array /// a points to some element sequence s with some permission p. /// /// A big design decision in this library was whether the second index /// of this predicate should be a [lseq t (length a)] or just a [seq t]. /// /// Making it an [lseq] forces every specification to be strongly /// typed, in the sense that the logical representation of an array /// has to be a sequence of the right length. This can be a little /// cumbersome in specifications, particularly as the refinement appears /// in some cases beneath the [erased] constructor. /// /// So, we opted instead to let the index be just a [seq t], and /// requiring length refinements on it in certain functions, only when /// necessary. val pts_to (#elt: Type0) (a: array elt) (p: P.perm) ([@@@ smt_fallback ] s: Seq.seq elt) : Tot vprop /// A stateful lemma to relate the size of an array with the size /// of the element sequence it points to /// This ghost function proves that an array always points to a /// sequence of the appropriate length val pts_to_length (#opened: _) (#elt: Type0) (#p: P.perm) (a: array elt) (s: Seq.seq elt) : STGhost unit opened (pts_to a p s) (fun _ -> pts_to a p s) (True) (fun _ -> Seq.length s == length a) val pts_to_not_null (#opened: _) (#elt: Type0) (#p: P.perm) (a: array elt) (s: Seq.seq elt) : STGhost unit opened (pts_to a p s) (fun _ -> pts_to a p s) (True) (fun _ -> a =!= null) /// An injectivity property, needed only to define a selector. Such a /// selector can be only defined in universe 0, and universes are not /// cumulative, so we need to define a separate module for arrays of /// universe 0 elements with selectors, reusing definitions from this /// interface, but we do not want to use `friend`. val pts_to_inj (#elt: Type0) (a: array elt) (p1: P.perm) (s1: Seq.seq elt) (p2: P.perm) (s2: Seq.seq elt) (m: mem) : Lemma (requires ( interp (hp_of (pts_to a p1 s1)) m /\ interp (hp_of (pts_to a p2 s2)) m )) (ensures ( s1 == s2 )) /// Allocating a new array of size n, where each cell is initialized /// with value x. We define the non-selector version of this operation /// (and others) with a _pt suffix in the name. let is_full_array (#elt: Type) (a: array elt) : Tot prop = length a == base_len (base (ptr_of a)) inline_for_extraction [@@noextract_to "krml"] val malloc (#elt: Type) (x: elt) (n: US.t) : ST (array elt) emp (fun a -> pts_to a P.full_perm (Seq.create (US.v n) x)) (True) (fun a -> length a == US.v n /\ is_full_array a ) inline_for_extraction [@@noextract_to "krml"] let alloc #elt = malloc #elt /// Freeing a full array. inline_for_extraction [@@ noextract_to "krml"; warn_on_use "Steel.Array.free_pt is currently unsound in the presence of zero-size subarrays, have you collected them all?"] val free (#elt: Type) (a: array elt) : ST unit (exists_ (pts_to a P.full_perm)) (fun _ -> emp) ( is_full_array a ) (fun _ -> True) /// Sharing and gathering permissions on an array. Those only /// manipulate permissions, so they are nothing more than stateful /// lemmas. val share (#opened: _) (#elt: Type) (#x: Seq.seq elt) (a: array elt) (p p1 p2: P.perm) : STGhost unit opened (pts_to a p x) (fun _ -> pts_to a p1 x `star` pts_to a p2 x) (p == p1 `P.sum_perm` p2) (fun _ -> True) val gather (#opened: _) (#elt: Type) (a: array elt) (#x1: Seq.seq elt) (p1: P.perm) (#x2: Seq.seq elt) (p2: P.perm) : STGhost unit opened (pts_to a p1 x1 `star` pts_to a p2 x2) (fun _ -> pts_to a (p1 `P.sum_perm` p2) x1) (True) (fun _ -> x1 == x2) /// Reading the i-th element of an array a. /// TODO: we should also provide an atomic version for small types. inline_for_extraction [@@noextract_to "krml"] val index (#t: Type) (#p: P.perm) (a: array t) (#s: Ghost.erased (Seq.seq t)) (i: US.t) : ST t (pts_to a p s) (fun _ -> pts_to a p s) (US.v i < length a \/ US.v i < Seq.length s) (fun res -> Seq.length s == length a /\ US.v i < Seq.length s /\ res == Seq.index s (US.v i)) inline_for_extraction [@@noextract_to "krml"] let read #t #p = index #t #p /// Writing the value v at the i-th element of an array a. /// TODO: we should also provide an atomic version for small types. inline_for_extraction [@@noextract_to "krml"] val upd (#t: Type) (a: array t) (#s: Ghost.erased (Seq.seq t)) (i: US.t {US.v i < Seq.length s}) (v: t) : STT unit (pts_to a P.full_perm s) (fun res -> pts_to a P.full_perm (Seq.upd s (US.v i) v)) inline_for_extraction [@@noextract_to "krml"] let write #t = upd #t /// An array a1 is adjacent to an array a2 if and only if they have /// the same base array and the end of a1 coincides with the beginning /// of a2 let adjacent (#elt: Type) (a1 a2: array elt) : Tot prop = base (ptr_of a1) == base (ptr_of a2) /\ offset (ptr_of a1) + (length a1) == offset (ptr_of a2) /// If two arrays are adjacent, then we can compute their merge, with /// their combined lengths. By virtue of the length being ghost, /// Karamel will extract it as "let y = a1" inline_for_extraction [@@noextract_to "krml"] let merge (#elt: Type) (a1: array elt) (a2: Ghost.erased (array elt)) : Pure (array elt) (requires (adjacent a1 a2))
false
false
Steel.ST.Array.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val merge (#elt: Type) (a1: array elt) (a2: Ghost.erased (array elt)) : Pure (array elt) (requires (adjacent a1 a2)) (ensures (fun y -> length y == length a1 + length a2))
[]
Steel.ST.Array.merge
{ "file_name": "lib/steel/Steel.ST.Array.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
a1: Steel.ST.Array.array elt -> a2: FStar.Ghost.erased (Steel.ST.Array.array elt) -> Prims.Pure (Steel.ST.Array.array elt)
{ "end_col": 53, "end_line": 304, "start_col": 2, "start_line": 304 }
Prims.Pure
val split_l (#elt: Type) (a: array elt) (i: Ghost.erased US.t) : Pure (array elt) (requires (US.v i <= length a)) (ensures (fun y -> True))
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": true, "full_module": "FStar.PtrdiffT", "short_module": "UP" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "P" }, { "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 } ]
false
let split_l (#elt: Type) (a: array elt) (i: Ghost.erased US.t) : Pure (array elt) (requires (US.v i <= length a)) (ensures (fun y -> True)) = (| ptr_of a, Ghost.hide (US.v i) |)
val split_l (#elt: Type) (a: array elt) (i: Ghost.erased US.t) : Pure (array elt) (requires (US.v i <= length a)) (ensures (fun y -> True)) let split_l (#elt: Type) (a: array elt) (i: Ghost.erased US.t) : Pure (array elt) (requires (US.v i <= length a)) (ensures (fun y -> True)) =
false
null
false
(| ptr_of a, Ghost.hide (US.v i) |)
{ "checked_file": "Steel.ST.Array.fsti.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.PtrdiffT.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.Array.fsti" }
[]
[ "Steel.ST.Array.array", "FStar.Ghost.erased", "FStar.SizeT.t", "Prims.Mkdtuple2", "Steel.ST.Array.ptr", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Steel.ST.Array.offset", "FStar.Ghost.reveal", "Steel.ST.Array.base_len", "Steel.ST.Array.base", "Steel.ST.Array.ptr_of", "FStar.Ghost.hide", "FStar.SizeT.v", "Steel.ST.Array.length", "Prims.l_True" ]
[]
(* Copyright 2020, 2021, 2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.ST.Array /// C arrays of universe 0 elements, with selectors. module P = Steel.FractionalPermission module US = FStar.SizeT module UP = FStar.PtrdiffT open Steel.ST.Util /// NOTE: This module is defined on top of Steel.HigherArray, so its /// definitions are all meant to be inlined and benefit from the /// latter module's primitive extraction. We seal it under an /// interface to avoid unpleasantly leaking the lifting of values /// of lower universes into the SMT context. Due to this interface, /// cross-module inlining must be enabled using F*'s --cmi option. /// An abstract type to represent a base array (whole allocation /// unit), exposed for proof purposes only [@@erasable] val base_t (elt: Type0) : Tot Type0 val base_len (#elt: Type) (b: base_t elt) : GTot nat /// An abstract type to represent a C pointer, as a base and an offset /// into its base inline_for_extraction [@@noextract_to "krml"] val ptr ([@@@unused] elt: Type0) : Type0 inline_for_extraction [@@noextract_to "krml"] val null_ptr (elt: Type0) : ptr elt // TODO: turn into a stateful operation to avoid comparing dangling pointers inline_for_extraction [@@noextract_to "krml"] val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null_ptr elt)) val base (#elt: Type) (p: ptr elt) : Tot (base_t elt) val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p))) val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma (requires ( base p1 == base p2 /\ offset p1 == offset p2 )) (ensures ( p1 == p2 )) val base_len_null_ptr (elt: Type0) : Lemma (base_len (base (null_ptr elt)) == 0) [SMTPat (base_len (base (null_ptr elt)))] /// A concrete type to represent a C array, as a C pointer and a ghost /// array length. By virtue of the length being ghost, Karamel will /// extract this type as just ptr, but to inline the definition of /// this type, we use standard dependent pairs instead of a custom /// record type. inline_for_extraction [@@noextract_to "krml"] let array ([@@@strictly_positive] elt: Type0) : Tot Type0 = (p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)})) inline_for_extraction [@@noextract_to "krml"] let null (#a: Type0) : array a = (| null_ptr a, Ghost.hide 0 |) /// This will extract to "let p = a" inline_for_extraction [@@noextract_to "krml"] let ptr_of (#elt: Type) (a: array elt) : Tot (ptr elt) = match a with // dfst is not marked inline_for_extraction, so we need to reimplement it | (| p, _ |) -> p inline_for_extraction [@@noextract_to "krml"] let is_null (#a: Type0) (p: array a) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null)) = is_null_ptr (ptr_of p) /// Returns the length of the array. Usable for specification and proof purposes, /// as modeled by the GTot effect let length (#elt: Type) (a: array elt) : GTot nat = dsnd a val length_fits (#elt: Type) (a: array elt) : Lemma (US.fits (length a)) /// An abbreviation refining an array by its length inline_for_extraction [@@noextract_to "krml"] let larray (t:Type) (n:nat) = a:array t{ length a = n } /// The main representation predicate: /// A Steel separation logic heap predicate to describe that an array /// a points to some element sequence s with some permission p. /// /// A big design decision in this library was whether the second index /// of this predicate should be a [lseq t (length a)] or just a [seq t]. /// /// Making it an [lseq] forces every specification to be strongly /// typed, in the sense that the logical representation of an array /// has to be a sequence of the right length. This can be a little /// cumbersome in specifications, particularly as the refinement appears /// in some cases beneath the [erased] constructor. /// /// So, we opted instead to let the index be just a [seq t], and /// requiring length refinements on it in certain functions, only when /// necessary. val pts_to (#elt: Type0) (a: array elt) (p: P.perm) ([@@@ smt_fallback ] s: Seq.seq elt) : Tot vprop /// A stateful lemma to relate the size of an array with the size /// of the element sequence it points to /// This ghost function proves that an array always points to a /// sequence of the appropriate length val pts_to_length (#opened: _) (#elt: Type0) (#p: P.perm) (a: array elt) (s: Seq.seq elt) : STGhost unit opened (pts_to a p s) (fun _ -> pts_to a p s) (True) (fun _ -> Seq.length s == length a) val pts_to_not_null (#opened: _) (#elt: Type0) (#p: P.perm) (a: array elt) (s: Seq.seq elt) : STGhost unit opened (pts_to a p s) (fun _ -> pts_to a p s) (True) (fun _ -> a =!= null) /// An injectivity property, needed only to define a selector. Such a /// selector can be only defined in universe 0, and universes are not /// cumulative, so we need to define a separate module for arrays of /// universe 0 elements with selectors, reusing definitions from this /// interface, but we do not want to use `friend`. val pts_to_inj (#elt: Type0) (a: array elt) (p1: P.perm) (s1: Seq.seq elt) (p2: P.perm) (s2: Seq.seq elt) (m: mem) : Lemma (requires ( interp (hp_of (pts_to a p1 s1)) m /\ interp (hp_of (pts_to a p2 s2)) m )) (ensures ( s1 == s2 )) /// Allocating a new array of size n, where each cell is initialized /// with value x. We define the non-selector version of this operation /// (and others) with a _pt suffix in the name. let is_full_array (#elt: Type) (a: array elt) : Tot prop = length a == base_len (base (ptr_of a)) inline_for_extraction [@@noextract_to "krml"] val malloc (#elt: Type) (x: elt) (n: US.t) : ST (array elt) emp (fun a -> pts_to a P.full_perm (Seq.create (US.v n) x)) (True) (fun a -> length a == US.v n /\ is_full_array a ) inline_for_extraction [@@noextract_to "krml"] let alloc #elt = malloc #elt /// Freeing a full array. inline_for_extraction [@@ noextract_to "krml"; warn_on_use "Steel.Array.free_pt is currently unsound in the presence of zero-size subarrays, have you collected them all?"] val free (#elt: Type) (a: array elt) : ST unit (exists_ (pts_to a P.full_perm)) (fun _ -> emp) ( is_full_array a ) (fun _ -> True) /// Sharing and gathering permissions on an array. Those only /// manipulate permissions, so they are nothing more than stateful /// lemmas. val share (#opened: _) (#elt: Type) (#x: Seq.seq elt) (a: array elt) (p p1 p2: P.perm) : STGhost unit opened (pts_to a p x) (fun _ -> pts_to a p1 x `star` pts_to a p2 x) (p == p1 `P.sum_perm` p2) (fun _ -> True) val gather (#opened: _) (#elt: Type) (a: array elt) (#x1: Seq.seq elt) (p1: P.perm) (#x2: Seq.seq elt) (p2: P.perm) : STGhost unit opened (pts_to a p1 x1 `star` pts_to a p2 x2) (fun _ -> pts_to a (p1 `P.sum_perm` p2) x1) (True) (fun _ -> x1 == x2) /// Reading the i-th element of an array a. /// TODO: we should also provide an atomic version for small types. inline_for_extraction [@@noextract_to "krml"] val index (#t: Type) (#p: P.perm) (a: array t) (#s: Ghost.erased (Seq.seq t)) (i: US.t) : ST t (pts_to a p s) (fun _ -> pts_to a p s) (US.v i < length a \/ US.v i < Seq.length s) (fun res -> Seq.length s == length a /\ US.v i < Seq.length s /\ res == Seq.index s (US.v i)) inline_for_extraction [@@noextract_to "krml"] let read #t #p = index #t #p /// Writing the value v at the i-th element of an array a. /// TODO: we should also provide an atomic version for small types. inline_for_extraction [@@noextract_to "krml"] val upd (#t: Type) (a: array t) (#s: Ghost.erased (Seq.seq t)) (i: US.t {US.v i < Seq.length s}) (v: t) : STT unit (pts_to a P.full_perm s) (fun res -> pts_to a P.full_perm (Seq.upd s (US.v i) v)) inline_for_extraction [@@noextract_to "krml"] let write #t = upd #t /// An array a1 is adjacent to an array a2 if and only if they have /// the same base array and the end of a1 coincides with the beginning /// of a2 let adjacent (#elt: Type) (a1 a2: array elt) : Tot prop = base (ptr_of a1) == base (ptr_of a2) /\ offset (ptr_of a1) + (length a1) == offset (ptr_of a2) /// If two arrays are adjacent, then we can compute their merge, with /// their combined lengths. By virtue of the length being ghost, /// Karamel will extract it as "let y = a1" inline_for_extraction [@@noextract_to "krml"] let merge (#elt: Type) (a1: array elt) (a2: Ghost.erased (array elt)) : Pure (array elt) (requires (adjacent a1 a2)) (ensures (fun y -> length y == length a1 + length a2)) = (| ptr_of a1, Ghost.hide (length a1 + length a2) |) /// Adjacency and merging are associative. let merge_assoc (#elt: Type) (a1 a2 a3: array elt) : Lemma (requires ( (adjacent a1 a2 /\ adjacent a2 a3) \/ (adjacent a1 a2 /\ adjacent (merge a1 a2) a3) \/ (adjacent a2 a3 /\ adjacent a1 (merge a2 a3)) )) (ensures ( adjacent (merge a1 a2) a3 /\ adjacent a1 (merge a2 a3) /\ merge (merge a1 a2) a3 == merge a1 (merge a2 a3) )) = () /// A shortcut to combine adjacency and merging let merge_into (#elt: Type) (a1 a2 a: array elt) : Tot prop = adjacent a1 a2 /\ merge a1 a2 == a /// Spatial merging of two arrays, expressed in terms of `merge`. val ghost_join (#opened: _) (#elt: Type) (#x1 #x2: Seq.seq elt) (#p: P.perm) (a1 a2: array elt) (h: squash (adjacent a1 a2)) : STGhostT unit opened (pts_to a1 p x1 `star` pts_to a2 p x2) (fun res -> pts_to (merge a1 a2) p (x1 `Seq.append` x2)) /// Spatial merging, combining the use of `merge` and the call to the /// stateful lemma. Since the only operations are calls to stateful /// lemmas and pure computations, the overall computation is atomic /// and unobservable, so can be used anywhere in atomic contexts. By /// virtue of the length being ghost, Karamel will extract this to /// "let res = a1" inline_for_extraction // this will extract to "let res = a1" [@@noextract_to "krml"] let join (#opened: _) (#elt: Type) (#x1 #x2: Ghost.erased (Seq.seq elt)) (#p: P.perm) (a1: array elt) (a2: Ghost.erased (array elt)) : STAtomicBase (array elt) false opened Unobservable (pts_to a1 p x1 `star` pts_to a2 p x2) (fun res -> pts_to res p (x1 `Seq.append` x2)) (adjacent a1 a2) (fun res -> merge_into a1 a2 res) = let _ : squash (adjacent a1 a2) = () in ghost_join a1 a2 (); let res = merge a1 a2 in rewrite (pts_to (merge a1 (Ghost.hide (Ghost.reveal a2))) p (x1 `Seq.append` x2)) (pts_to res p (x1 `Seq.append` x2)); return res /// Computing the left-hand-side part of splitting an array a at /// offset i. By virtue of the length being ghost, Karamel will /// extract this to "let y = a" inline_for_extraction // this will extract to "let y = a" [@@noextract_to "krml"] let split_l (#elt: Type) (a: array elt) (i: Ghost.erased US.t) : Pure (array elt) (requires (US.v i <= length a))
false
false
Steel.ST.Array.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val split_l (#elt: Type) (a: array elt) (i: Ghost.erased US.t) : Pure (array elt) (requires (US.v i <= length a)) (ensures (fun y -> True))
[]
Steel.ST.Array.split_l
{ "file_name": "lib/steel/Steel.ST.Array.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
a: Steel.ST.Array.array elt -> i: FStar.Ghost.erased FStar.SizeT.t -> Prims.Pure (Steel.ST.Array.array elt)
{ "end_col": 37, "end_line": 374, "start_col": 2, "start_line": 374 }
FStar.Pervasives.Lemma
val ptr_shift_zero (#elt: Type) (p: ptr elt) : Lemma (ptr_shift p 0sz == p)
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": true, "full_module": "FStar.PtrdiffT", "short_module": "UP" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "P" }, { "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 } ]
false
let ptr_shift_zero (#elt: Type) (p: ptr elt) : Lemma (ptr_shift p 0sz == p) = ptr_base_offset_inj (ptr_shift p 0sz) p
val ptr_shift_zero (#elt: Type) (p: ptr elt) : Lemma (ptr_shift p 0sz == p) let ptr_shift_zero (#elt: Type) (p: ptr elt) : Lemma (ptr_shift p 0sz == p) =
false
null
true
ptr_base_offset_inj (ptr_shift p 0sz) p
{ "checked_file": "Steel.ST.Array.fsti.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.PtrdiffT.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.Array.fsti" }
[ "lemma" ]
[ "Steel.ST.Array.ptr", "Steel.ST.Array.ptr_base_offset_inj", "Steel.ST.Array.ptr_shift", "FStar.SizeT.__uint_to_t", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2020, 2021, 2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.ST.Array /// C arrays of universe 0 elements, with selectors. module P = Steel.FractionalPermission module US = FStar.SizeT module UP = FStar.PtrdiffT open Steel.ST.Util /// NOTE: This module is defined on top of Steel.HigherArray, so its /// definitions are all meant to be inlined and benefit from the /// latter module's primitive extraction. We seal it under an /// interface to avoid unpleasantly leaking the lifting of values /// of lower universes into the SMT context. Due to this interface, /// cross-module inlining must be enabled using F*'s --cmi option. /// An abstract type to represent a base array (whole allocation /// unit), exposed for proof purposes only [@@erasable] val base_t (elt: Type0) : Tot Type0 val base_len (#elt: Type) (b: base_t elt) : GTot nat /// An abstract type to represent a C pointer, as a base and an offset /// into its base inline_for_extraction [@@noextract_to "krml"] val ptr ([@@@unused] elt: Type0) : Type0 inline_for_extraction [@@noextract_to "krml"] val null_ptr (elt: Type0) : ptr elt // TODO: turn into a stateful operation to avoid comparing dangling pointers inline_for_extraction [@@noextract_to "krml"] val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null_ptr elt)) val base (#elt: Type) (p: ptr elt) : Tot (base_t elt) val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p))) val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma (requires ( base p1 == base p2 /\ offset p1 == offset p2 )) (ensures ( p1 == p2 )) val base_len_null_ptr (elt: Type0) : Lemma (base_len (base (null_ptr elt)) == 0) [SMTPat (base_len (base (null_ptr elt)))] /// A concrete type to represent a C array, as a C pointer and a ghost /// array length. By virtue of the length being ghost, Karamel will /// extract this type as just ptr, but to inline the definition of /// this type, we use standard dependent pairs instead of a custom /// record type. inline_for_extraction [@@noextract_to "krml"] let array ([@@@strictly_positive] elt: Type0) : Tot Type0 = (p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)})) inline_for_extraction [@@noextract_to "krml"] let null (#a: Type0) : array a = (| null_ptr a, Ghost.hide 0 |) /// This will extract to "let p = a" inline_for_extraction [@@noextract_to "krml"] let ptr_of (#elt: Type) (a: array elt) : Tot (ptr elt) = match a with // dfst is not marked inline_for_extraction, so we need to reimplement it | (| p, _ |) -> p inline_for_extraction [@@noextract_to "krml"] let is_null (#a: Type0) (p: array a) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null)) = is_null_ptr (ptr_of p) /// Returns the length of the array. Usable for specification and proof purposes, /// as modeled by the GTot effect let length (#elt: Type) (a: array elt) : GTot nat = dsnd a val length_fits (#elt: Type) (a: array elt) : Lemma (US.fits (length a)) /// An abbreviation refining an array by its length inline_for_extraction [@@noextract_to "krml"] let larray (t:Type) (n:nat) = a:array t{ length a = n } /// The main representation predicate: /// A Steel separation logic heap predicate to describe that an array /// a points to some element sequence s with some permission p. /// /// A big design decision in this library was whether the second index /// of this predicate should be a [lseq t (length a)] or just a [seq t]. /// /// Making it an [lseq] forces every specification to be strongly /// typed, in the sense that the logical representation of an array /// has to be a sequence of the right length. This can be a little /// cumbersome in specifications, particularly as the refinement appears /// in some cases beneath the [erased] constructor. /// /// So, we opted instead to let the index be just a [seq t], and /// requiring length refinements on it in certain functions, only when /// necessary. val pts_to (#elt: Type0) (a: array elt) (p: P.perm) ([@@@ smt_fallback ] s: Seq.seq elt) : Tot vprop /// A stateful lemma to relate the size of an array with the size /// of the element sequence it points to /// This ghost function proves that an array always points to a /// sequence of the appropriate length val pts_to_length (#opened: _) (#elt: Type0) (#p: P.perm) (a: array elt) (s: Seq.seq elt) : STGhost unit opened (pts_to a p s) (fun _ -> pts_to a p s) (True) (fun _ -> Seq.length s == length a) val pts_to_not_null (#opened: _) (#elt: Type0) (#p: P.perm) (a: array elt) (s: Seq.seq elt) : STGhost unit opened (pts_to a p s) (fun _ -> pts_to a p s) (True) (fun _ -> a =!= null) /// An injectivity property, needed only to define a selector. Such a /// selector can be only defined in universe 0, and universes are not /// cumulative, so we need to define a separate module for arrays of /// universe 0 elements with selectors, reusing definitions from this /// interface, but we do not want to use `friend`. val pts_to_inj (#elt: Type0) (a: array elt) (p1: P.perm) (s1: Seq.seq elt) (p2: P.perm) (s2: Seq.seq elt) (m: mem) : Lemma (requires ( interp (hp_of (pts_to a p1 s1)) m /\ interp (hp_of (pts_to a p2 s2)) m )) (ensures ( s1 == s2 )) /// Allocating a new array of size n, where each cell is initialized /// with value x. We define the non-selector version of this operation /// (and others) with a _pt suffix in the name. let is_full_array (#elt: Type) (a: array elt) : Tot prop = length a == base_len (base (ptr_of a)) inline_for_extraction [@@noextract_to "krml"] val malloc (#elt: Type) (x: elt) (n: US.t) : ST (array elt) emp (fun a -> pts_to a P.full_perm (Seq.create (US.v n) x)) (True) (fun a -> length a == US.v n /\ is_full_array a ) inline_for_extraction [@@noextract_to "krml"] let alloc #elt = malloc #elt /// Freeing a full array. inline_for_extraction [@@ noextract_to "krml"; warn_on_use "Steel.Array.free_pt is currently unsound in the presence of zero-size subarrays, have you collected them all?"] val free (#elt: Type) (a: array elt) : ST unit (exists_ (pts_to a P.full_perm)) (fun _ -> emp) ( is_full_array a ) (fun _ -> True) /// Sharing and gathering permissions on an array. Those only /// manipulate permissions, so they are nothing more than stateful /// lemmas. val share (#opened: _) (#elt: Type) (#x: Seq.seq elt) (a: array elt) (p p1 p2: P.perm) : STGhost unit opened (pts_to a p x) (fun _ -> pts_to a p1 x `star` pts_to a p2 x) (p == p1 `P.sum_perm` p2) (fun _ -> True) val gather (#opened: _) (#elt: Type) (a: array elt) (#x1: Seq.seq elt) (p1: P.perm) (#x2: Seq.seq elt) (p2: P.perm) : STGhost unit opened (pts_to a p1 x1 `star` pts_to a p2 x2) (fun _ -> pts_to a (p1 `P.sum_perm` p2) x1) (True) (fun _ -> x1 == x2) /// Reading the i-th element of an array a. /// TODO: we should also provide an atomic version for small types. inline_for_extraction [@@noextract_to "krml"] val index (#t: Type) (#p: P.perm) (a: array t) (#s: Ghost.erased (Seq.seq t)) (i: US.t) : ST t (pts_to a p s) (fun _ -> pts_to a p s) (US.v i < length a \/ US.v i < Seq.length s) (fun res -> Seq.length s == length a /\ US.v i < Seq.length s /\ res == Seq.index s (US.v i)) inline_for_extraction [@@noextract_to "krml"] let read #t #p = index #t #p /// Writing the value v at the i-th element of an array a. /// TODO: we should also provide an atomic version for small types. inline_for_extraction [@@noextract_to "krml"] val upd (#t: Type) (a: array t) (#s: Ghost.erased (Seq.seq t)) (i: US.t {US.v i < Seq.length s}) (v: t) : STT unit (pts_to a P.full_perm s) (fun res -> pts_to a P.full_perm (Seq.upd s (US.v i) v)) inline_for_extraction [@@noextract_to "krml"] let write #t = upd #t /// An array a1 is adjacent to an array a2 if and only if they have /// the same base array and the end of a1 coincides with the beginning /// of a2 let adjacent (#elt: Type) (a1 a2: array elt) : Tot prop = base (ptr_of a1) == base (ptr_of a2) /\ offset (ptr_of a1) + (length a1) == offset (ptr_of a2) /// If two arrays are adjacent, then we can compute their merge, with /// their combined lengths. By virtue of the length being ghost, /// Karamel will extract it as "let y = a1" inline_for_extraction [@@noextract_to "krml"] let merge (#elt: Type) (a1: array elt) (a2: Ghost.erased (array elt)) : Pure (array elt) (requires (adjacent a1 a2)) (ensures (fun y -> length y == length a1 + length a2)) = (| ptr_of a1, Ghost.hide (length a1 + length a2) |) /// Adjacency and merging are associative. let merge_assoc (#elt: Type) (a1 a2 a3: array elt) : Lemma (requires ( (adjacent a1 a2 /\ adjacent a2 a3) \/ (adjacent a1 a2 /\ adjacent (merge a1 a2) a3) \/ (adjacent a2 a3 /\ adjacent a1 (merge a2 a3)) )) (ensures ( adjacent (merge a1 a2) a3 /\ adjacent a1 (merge a2 a3) /\ merge (merge a1 a2) a3 == merge a1 (merge a2 a3) )) = () /// A shortcut to combine adjacency and merging let merge_into (#elt: Type) (a1 a2 a: array elt) : Tot prop = adjacent a1 a2 /\ merge a1 a2 == a /// Spatial merging of two arrays, expressed in terms of `merge`. val ghost_join (#opened: _) (#elt: Type) (#x1 #x2: Seq.seq elt) (#p: P.perm) (a1 a2: array elt) (h: squash (adjacent a1 a2)) : STGhostT unit opened (pts_to a1 p x1 `star` pts_to a2 p x2) (fun res -> pts_to (merge a1 a2) p (x1 `Seq.append` x2)) /// Spatial merging, combining the use of `merge` and the call to the /// stateful lemma. Since the only operations are calls to stateful /// lemmas and pure computations, the overall computation is atomic /// and unobservable, so can be used anywhere in atomic contexts. By /// virtue of the length being ghost, Karamel will extract this to /// "let res = a1" inline_for_extraction // this will extract to "let res = a1" [@@noextract_to "krml"] let join (#opened: _) (#elt: Type) (#x1 #x2: Ghost.erased (Seq.seq elt)) (#p: P.perm) (a1: array elt) (a2: Ghost.erased (array elt)) : STAtomicBase (array elt) false opened Unobservable (pts_to a1 p x1 `star` pts_to a2 p x2) (fun res -> pts_to res p (x1 `Seq.append` x2)) (adjacent a1 a2) (fun res -> merge_into a1 a2 res) = let _ : squash (adjacent a1 a2) = () in ghost_join a1 a2 (); let res = merge a1 a2 in rewrite (pts_to (merge a1 (Ghost.hide (Ghost.reveal a2))) p (x1 `Seq.append` x2)) (pts_to res p (x1 `Seq.append` x2)); return res /// Computing the left-hand-side part of splitting an array a at /// offset i. By virtue of the length being ghost, Karamel will /// extract this to "let y = a" inline_for_extraction // this will extract to "let y = a" [@@noextract_to "krml"] let split_l (#elt: Type) (a: array elt) (i: Ghost.erased US.t) : Pure (array elt) (requires (US.v i <= length a)) (ensures (fun y -> True)) = (| ptr_of a, Ghost.hide (US.v i) |) /// C pointer arithmetic to compute (p+off), shifting a pointer p by /// offset off. TODO: replace this with a Ghost definition and a /// SteelAtomicBase Unobservable operation with the corresponding /// permission. inline_for_extraction [@@noextract_to "krml"] val ptr_shift (#elt: Type) (p: ptr elt) (off: US.t) : Pure (ptr elt) (requires (offset p + US.v off <= base_len (base p))) (ensures (fun p' -> base p' == base p /\ offset p' == offset p + US.v off )) let ptr_shift_zero (#elt: Type) (p: ptr elt) : Lemma
false
false
Steel.ST.Array.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ptr_shift_zero (#elt: Type) (p: ptr elt) : Lemma (ptr_shift p 0sz == p)
[]
Steel.ST.Array.ptr_shift_zero
{ "file_name": "lib/steel/Steel.ST.Array.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
p: Steel.ST.Array.ptr elt -> FStar.Pervasives.Lemma (ensures Steel.ST.Array.ptr_shift p (FStar.SizeT.__uint_to_t 0) == p)
{ "end_col": 41, "end_line": 398, "start_col": 2, "start_line": 398 }
Prims.Pure
val split_r (#elt: Type) (a: array elt) (i: US.t) : Pure (array elt) (requires (US.v i <= length a)) (ensures (fun y -> merge_into (split_l a i) y a))
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": true, "full_module": "FStar.PtrdiffT", "short_module": "UP" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "P" }, { "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 } ]
false
let split_r (#elt: Type) (a: array elt) (i: US.t) : Pure (array elt) (requires (US.v i <= length a)) (ensures (fun y -> merge_into (split_l a i) y a)) = (| ptr_shift (ptr_of a) i, Ghost.hide (length a - US.v i) |)
val split_r (#elt: Type) (a: array elt) (i: US.t) : Pure (array elt) (requires (US.v i <= length a)) (ensures (fun y -> merge_into (split_l a i) y a)) let split_r (#elt: Type) (a: array elt) (i: US.t) : Pure (array elt) (requires (US.v i <= length a)) (ensures (fun y -> merge_into (split_l a i) y a)) =
false
null
false
(| ptr_shift (ptr_of a) i, Ghost.hide (length a - US.v i) |)
{ "checked_file": "Steel.ST.Array.fsti.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.PtrdiffT.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.Array.fsti" }
[]
[ "Steel.ST.Array.array", "FStar.SizeT.t", "Prims.Mkdtuple2", "Steel.ST.Array.ptr", "FStar.Ghost.erased", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Steel.ST.Array.offset", "FStar.Ghost.reveal", "Steel.ST.Array.base_len", "Steel.ST.Array.base", "Steel.ST.Array.ptr_shift", "Steel.ST.Array.ptr_of", "FStar.Ghost.hide", "Prims.op_Subtraction", "Steel.ST.Array.length", "FStar.SizeT.v", "Steel.ST.Array.merge_into", "Steel.ST.Array.split_l" ]
[]
(* Copyright 2020, 2021, 2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.ST.Array /// C arrays of universe 0 elements, with selectors. module P = Steel.FractionalPermission module US = FStar.SizeT module UP = FStar.PtrdiffT open Steel.ST.Util /// NOTE: This module is defined on top of Steel.HigherArray, so its /// definitions are all meant to be inlined and benefit from the /// latter module's primitive extraction. We seal it under an /// interface to avoid unpleasantly leaking the lifting of values /// of lower universes into the SMT context. Due to this interface, /// cross-module inlining must be enabled using F*'s --cmi option. /// An abstract type to represent a base array (whole allocation /// unit), exposed for proof purposes only [@@erasable] val base_t (elt: Type0) : Tot Type0 val base_len (#elt: Type) (b: base_t elt) : GTot nat /// An abstract type to represent a C pointer, as a base and an offset /// into its base inline_for_extraction [@@noextract_to "krml"] val ptr ([@@@unused] elt: Type0) : Type0 inline_for_extraction [@@noextract_to "krml"] val null_ptr (elt: Type0) : ptr elt // TODO: turn into a stateful operation to avoid comparing dangling pointers inline_for_extraction [@@noextract_to "krml"] val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null_ptr elt)) val base (#elt: Type) (p: ptr elt) : Tot (base_t elt) val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p))) val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma (requires ( base p1 == base p2 /\ offset p1 == offset p2 )) (ensures ( p1 == p2 )) val base_len_null_ptr (elt: Type0) : Lemma (base_len (base (null_ptr elt)) == 0) [SMTPat (base_len (base (null_ptr elt)))] /// A concrete type to represent a C array, as a C pointer and a ghost /// array length. By virtue of the length being ghost, Karamel will /// extract this type as just ptr, but to inline the definition of /// this type, we use standard dependent pairs instead of a custom /// record type. inline_for_extraction [@@noextract_to "krml"] let array ([@@@strictly_positive] elt: Type0) : Tot Type0 = (p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)})) inline_for_extraction [@@noextract_to "krml"] let null (#a: Type0) : array a = (| null_ptr a, Ghost.hide 0 |) /// This will extract to "let p = a" inline_for_extraction [@@noextract_to "krml"] let ptr_of (#elt: Type) (a: array elt) : Tot (ptr elt) = match a with // dfst is not marked inline_for_extraction, so we need to reimplement it | (| p, _ |) -> p inline_for_extraction [@@noextract_to "krml"] let is_null (#a: Type0) (p: array a) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null)) = is_null_ptr (ptr_of p) /// Returns the length of the array. Usable for specification and proof purposes, /// as modeled by the GTot effect let length (#elt: Type) (a: array elt) : GTot nat = dsnd a val length_fits (#elt: Type) (a: array elt) : Lemma (US.fits (length a)) /// An abbreviation refining an array by its length inline_for_extraction [@@noextract_to "krml"] let larray (t:Type) (n:nat) = a:array t{ length a = n } /// The main representation predicate: /// A Steel separation logic heap predicate to describe that an array /// a points to some element sequence s with some permission p. /// /// A big design decision in this library was whether the second index /// of this predicate should be a [lseq t (length a)] or just a [seq t]. /// /// Making it an [lseq] forces every specification to be strongly /// typed, in the sense that the logical representation of an array /// has to be a sequence of the right length. This can be a little /// cumbersome in specifications, particularly as the refinement appears /// in some cases beneath the [erased] constructor. /// /// So, we opted instead to let the index be just a [seq t], and /// requiring length refinements on it in certain functions, only when /// necessary. val pts_to (#elt: Type0) (a: array elt) (p: P.perm) ([@@@ smt_fallback ] s: Seq.seq elt) : Tot vprop /// A stateful lemma to relate the size of an array with the size /// of the element sequence it points to /// This ghost function proves that an array always points to a /// sequence of the appropriate length val pts_to_length (#opened: _) (#elt: Type0) (#p: P.perm) (a: array elt) (s: Seq.seq elt) : STGhost unit opened (pts_to a p s) (fun _ -> pts_to a p s) (True) (fun _ -> Seq.length s == length a) val pts_to_not_null (#opened: _) (#elt: Type0) (#p: P.perm) (a: array elt) (s: Seq.seq elt) : STGhost unit opened (pts_to a p s) (fun _ -> pts_to a p s) (True) (fun _ -> a =!= null) /// An injectivity property, needed only to define a selector. Such a /// selector can be only defined in universe 0, and universes are not /// cumulative, so we need to define a separate module for arrays of /// universe 0 elements with selectors, reusing definitions from this /// interface, but we do not want to use `friend`. val pts_to_inj (#elt: Type0) (a: array elt) (p1: P.perm) (s1: Seq.seq elt) (p2: P.perm) (s2: Seq.seq elt) (m: mem) : Lemma (requires ( interp (hp_of (pts_to a p1 s1)) m /\ interp (hp_of (pts_to a p2 s2)) m )) (ensures ( s1 == s2 )) /// Allocating a new array of size n, where each cell is initialized /// with value x. We define the non-selector version of this operation /// (and others) with a _pt suffix in the name. let is_full_array (#elt: Type) (a: array elt) : Tot prop = length a == base_len (base (ptr_of a)) inline_for_extraction [@@noextract_to "krml"] val malloc (#elt: Type) (x: elt) (n: US.t) : ST (array elt) emp (fun a -> pts_to a P.full_perm (Seq.create (US.v n) x)) (True) (fun a -> length a == US.v n /\ is_full_array a ) inline_for_extraction [@@noextract_to "krml"] let alloc #elt = malloc #elt /// Freeing a full array. inline_for_extraction [@@ noextract_to "krml"; warn_on_use "Steel.Array.free_pt is currently unsound in the presence of zero-size subarrays, have you collected them all?"] val free (#elt: Type) (a: array elt) : ST unit (exists_ (pts_to a P.full_perm)) (fun _ -> emp) ( is_full_array a ) (fun _ -> True) /// Sharing and gathering permissions on an array. Those only /// manipulate permissions, so they are nothing more than stateful /// lemmas. val share (#opened: _) (#elt: Type) (#x: Seq.seq elt) (a: array elt) (p p1 p2: P.perm) : STGhost unit opened (pts_to a p x) (fun _ -> pts_to a p1 x `star` pts_to a p2 x) (p == p1 `P.sum_perm` p2) (fun _ -> True) val gather (#opened: _) (#elt: Type) (a: array elt) (#x1: Seq.seq elt) (p1: P.perm) (#x2: Seq.seq elt) (p2: P.perm) : STGhost unit opened (pts_to a p1 x1 `star` pts_to a p2 x2) (fun _ -> pts_to a (p1 `P.sum_perm` p2) x1) (True) (fun _ -> x1 == x2) /// Reading the i-th element of an array a. /// TODO: we should also provide an atomic version for small types. inline_for_extraction [@@noextract_to "krml"] val index (#t: Type) (#p: P.perm) (a: array t) (#s: Ghost.erased (Seq.seq t)) (i: US.t) : ST t (pts_to a p s) (fun _ -> pts_to a p s) (US.v i < length a \/ US.v i < Seq.length s) (fun res -> Seq.length s == length a /\ US.v i < Seq.length s /\ res == Seq.index s (US.v i)) inline_for_extraction [@@noextract_to "krml"] let read #t #p = index #t #p /// Writing the value v at the i-th element of an array a. /// TODO: we should also provide an atomic version for small types. inline_for_extraction [@@noextract_to "krml"] val upd (#t: Type) (a: array t) (#s: Ghost.erased (Seq.seq t)) (i: US.t {US.v i < Seq.length s}) (v: t) : STT unit (pts_to a P.full_perm s) (fun res -> pts_to a P.full_perm (Seq.upd s (US.v i) v)) inline_for_extraction [@@noextract_to "krml"] let write #t = upd #t /// An array a1 is adjacent to an array a2 if and only if they have /// the same base array and the end of a1 coincides with the beginning /// of a2 let adjacent (#elt: Type) (a1 a2: array elt) : Tot prop = base (ptr_of a1) == base (ptr_of a2) /\ offset (ptr_of a1) + (length a1) == offset (ptr_of a2) /// If two arrays are adjacent, then we can compute their merge, with /// their combined lengths. By virtue of the length being ghost, /// Karamel will extract it as "let y = a1" inline_for_extraction [@@noextract_to "krml"] let merge (#elt: Type) (a1: array elt) (a2: Ghost.erased (array elt)) : Pure (array elt) (requires (adjacent a1 a2)) (ensures (fun y -> length y == length a1 + length a2)) = (| ptr_of a1, Ghost.hide (length a1 + length a2) |) /// Adjacency and merging are associative. let merge_assoc (#elt: Type) (a1 a2 a3: array elt) : Lemma (requires ( (adjacent a1 a2 /\ adjacent a2 a3) \/ (adjacent a1 a2 /\ adjacent (merge a1 a2) a3) \/ (adjacent a2 a3 /\ adjacent a1 (merge a2 a3)) )) (ensures ( adjacent (merge a1 a2) a3 /\ adjacent a1 (merge a2 a3) /\ merge (merge a1 a2) a3 == merge a1 (merge a2 a3) )) = () /// A shortcut to combine adjacency and merging let merge_into (#elt: Type) (a1 a2 a: array elt) : Tot prop = adjacent a1 a2 /\ merge a1 a2 == a /// Spatial merging of two arrays, expressed in terms of `merge`. val ghost_join (#opened: _) (#elt: Type) (#x1 #x2: Seq.seq elt) (#p: P.perm) (a1 a2: array elt) (h: squash (adjacent a1 a2)) : STGhostT unit opened (pts_to a1 p x1 `star` pts_to a2 p x2) (fun res -> pts_to (merge a1 a2) p (x1 `Seq.append` x2)) /// Spatial merging, combining the use of `merge` and the call to the /// stateful lemma. Since the only operations are calls to stateful /// lemmas and pure computations, the overall computation is atomic /// and unobservable, so can be used anywhere in atomic contexts. By /// virtue of the length being ghost, Karamel will extract this to /// "let res = a1" inline_for_extraction // this will extract to "let res = a1" [@@noextract_to "krml"] let join (#opened: _) (#elt: Type) (#x1 #x2: Ghost.erased (Seq.seq elt)) (#p: P.perm) (a1: array elt) (a2: Ghost.erased (array elt)) : STAtomicBase (array elt) false opened Unobservable (pts_to a1 p x1 `star` pts_to a2 p x2) (fun res -> pts_to res p (x1 `Seq.append` x2)) (adjacent a1 a2) (fun res -> merge_into a1 a2 res) = let _ : squash (adjacent a1 a2) = () in ghost_join a1 a2 (); let res = merge a1 a2 in rewrite (pts_to (merge a1 (Ghost.hide (Ghost.reveal a2))) p (x1 `Seq.append` x2)) (pts_to res p (x1 `Seq.append` x2)); return res /// Computing the left-hand-side part of splitting an array a at /// offset i. By virtue of the length being ghost, Karamel will /// extract this to "let y = a" inline_for_extraction // this will extract to "let y = a" [@@noextract_to "krml"] let split_l (#elt: Type) (a: array elt) (i: Ghost.erased US.t) : Pure (array elt) (requires (US.v i <= length a)) (ensures (fun y -> True)) = (| ptr_of a, Ghost.hide (US.v i) |) /// C pointer arithmetic to compute (p+off), shifting a pointer p by /// offset off. TODO: replace this with a Ghost definition and a /// SteelAtomicBase Unobservable operation with the corresponding /// permission. inline_for_extraction [@@noextract_to "krml"] val ptr_shift (#elt: Type) (p: ptr elt) (off: US.t) : Pure (ptr elt) (requires (offset p + US.v off <= base_len (base p))) (ensures (fun p' -> base p' == base p /\ offset p' == offset p + US.v off )) let ptr_shift_zero (#elt: Type) (p: ptr elt) : Lemma (ptr_shift p 0sz == p) = ptr_base_offset_inj (ptr_shift p 0sz) p /// Computing the right-hand-side part of splitting an array a at /// offset i. inline_for_extraction [@@noextract_to "krml"] let split_r (#elt: Type) (a: array elt) (i: US.t) : Pure (array elt) (requires (US.v i <= length a))
false
false
Steel.ST.Array.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val split_r (#elt: Type) (a: array elt) (i: US.t) : Pure (array elt) (requires (US.v i <= length a)) (ensures (fun y -> merge_into (split_l a i) y a))
[]
Steel.ST.Array.split_r
{ "file_name": "lib/steel/Steel.ST.Array.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
a: Steel.ST.Array.array elt -> i: FStar.SizeT.t -> Prims.Pure (Steel.ST.Array.array elt)
{ "end_col": 62, "end_line": 409, "start_col": 2, "start_line": 409 }
Steel.ST.Effect.Atomic.STAtomicBase
val join (#opened: _) (#elt: Type) (#x1 #x2: Ghost.erased (Seq.seq elt)) (#p: P.perm) (a1: array elt) (a2: Ghost.erased (array elt)) : STAtomicBase (array elt) false opened Unobservable ((pts_to a1 p x1) `star` (pts_to a2 p x2)) (fun res -> pts_to res p (x1 `Seq.append` x2)) (adjacent a1 a2) (fun res -> merge_into a1 a2 res)
[ { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": true, "full_module": "FStar.PtrdiffT", "short_module": "UP" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "Steel.FractionalPermission", "short_module": "P" }, { "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 } ]
false
let join (#opened: _) (#elt: Type) (#x1 #x2: Ghost.erased (Seq.seq elt)) (#p: P.perm) (a1: array elt) (a2: Ghost.erased (array elt)) : STAtomicBase (array elt) false opened Unobservable (pts_to a1 p x1 `star` pts_to a2 p x2) (fun res -> pts_to res p (x1 `Seq.append` x2)) (adjacent a1 a2) (fun res -> merge_into a1 a2 res) = let _ : squash (adjacent a1 a2) = () in ghost_join a1 a2 (); let res = merge a1 a2 in rewrite (pts_to (merge a1 (Ghost.hide (Ghost.reveal a2))) p (x1 `Seq.append` x2)) (pts_to res p (x1 `Seq.append` x2)); return res
val join (#opened: _) (#elt: Type) (#x1 #x2: Ghost.erased (Seq.seq elt)) (#p: P.perm) (a1: array elt) (a2: Ghost.erased (array elt)) : STAtomicBase (array elt) false opened Unobservable ((pts_to a1 p x1) `star` (pts_to a2 p x2)) (fun res -> pts_to res p (x1 `Seq.append` x2)) (adjacent a1 a2) (fun res -> merge_into a1 a2 res) let join (#opened: _) (#elt: Type) (#x1 #x2: Ghost.erased (Seq.seq elt)) (#p: P.perm) (a1: array elt) (a2: Ghost.erased (array elt)) : STAtomicBase (array elt) false opened Unobservable ((pts_to a1 p x1) `star` (pts_to a2 p x2)) (fun res -> pts_to res p (x1 `Seq.append` x2)) (adjacent a1 a2) (fun res -> merge_into a1 a2 res) =
true
null
false
let _:squash (adjacent a1 a2) = () in ghost_join a1 a2 (); let res = merge a1 a2 in rewrite (pts_to (merge a1 (Ghost.hide (Ghost.reveal a2))) p (x1 `Seq.append` x2)) (pts_to res p (x1 `Seq.append` x2)); return res
{ "checked_file": "Steel.ST.Array.fsti.checked", "dependencies": [ "Steel.ST.Util.fsti.checked", "Steel.FractionalPermission.fst.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.PtrdiffT.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.Array.fsti" }
[]
[ "Steel.Memory.inames", "FStar.Ghost.erased", "FStar.Seq.Base.seq", "Steel.FractionalPermission.perm", "Steel.ST.Array.array", "Steel.ST.Util.return", "Steel.ST.Array.pts_to", "FStar.Seq.Base.append", "FStar.Ghost.reveal", "Steel.Effect.Common.vprop", "Prims.unit", "Steel.ST.Util.rewrite", "Steel.ST.Array.merge", "FStar.Ghost.hide", "Steel.ST.Array.ghost_join", "Prims.squash", "Steel.ST.Array.adjacent", "Steel.Effect.Common.Unobservable", "Steel.Effect.Common.star", "Prims.l_True", "Steel.ST.Array.merge_into" ]
[]
(* Copyright 2020, 2021, 2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.ST.Array /// C arrays of universe 0 elements, with selectors. module P = Steel.FractionalPermission module US = FStar.SizeT module UP = FStar.PtrdiffT open Steel.ST.Util /// NOTE: This module is defined on top of Steel.HigherArray, so its /// definitions are all meant to be inlined and benefit from the /// latter module's primitive extraction. We seal it under an /// interface to avoid unpleasantly leaking the lifting of values /// of lower universes into the SMT context. Due to this interface, /// cross-module inlining must be enabled using F*'s --cmi option. /// An abstract type to represent a base array (whole allocation /// unit), exposed for proof purposes only [@@erasable] val base_t (elt: Type0) : Tot Type0 val base_len (#elt: Type) (b: base_t elt) : GTot nat /// An abstract type to represent a C pointer, as a base and an offset /// into its base inline_for_extraction [@@noextract_to "krml"] val ptr ([@@@unused] elt: Type0) : Type0 inline_for_extraction [@@noextract_to "krml"] val null_ptr (elt: Type0) : ptr elt // TODO: turn into a stateful operation to avoid comparing dangling pointers inline_for_extraction [@@noextract_to "krml"] val is_null_ptr (#elt: Type0) (p: ptr elt) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null_ptr elt)) val base (#elt: Type) (p: ptr elt) : Tot (base_t elt) val offset (#elt: Type) (p: ptr elt) : Ghost nat (requires True) (ensures (fun offset -> offset <= base_len (base p))) val ptr_base_offset_inj (#elt: Type) (p1 p2: ptr elt) : Lemma (requires ( base p1 == base p2 /\ offset p1 == offset p2 )) (ensures ( p1 == p2 )) val base_len_null_ptr (elt: Type0) : Lemma (base_len (base (null_ptr elt)) == 0) [SMTPat (base_len (base (null_ptr elt)))] /// A concrete type to represent a C array, as a C pointer and a ghost /// array length. By virtue of the length being ghost, Karamel will /// extract this type as just ptr, but to inline the definition of /// this type, we use standard dependent pairs instead of a custom /// record type. inline_for_extraction [@@noextract_to "krml"] let array ([@@@strictly_positive] elt: Type0) : Tot Type0 = (p: ptr elt & (length: Ghost.erased nat {offset p + length <= base_len (base p)})) inline_for_extraction [@@noextract_to "krml"] let null (#a: Type0) : array a = (| null_ptr a, Ghost.hide 0 |) /// This will extract to "let p = a" inline_for_extraction [@@noextract_to "krml"] let ptr_of (#elt: Type) (a: array elt) : Tot (ptr elt) = match a with // dfst is not marked inline_for_extraction, so we need to reimplement it | (| p, _ |) -> p inline_for_extraction [@@noextract_to "krml"] let is_null (#a: Type0) (p: array a) : Pure bool (requires True) (ensures (fun res -> res == true <==> p == null)) = is_null_ptr (ptr_of p) /// Returns the length of the array. Usable for specification and proof purposes, /// as modeled by the GTot effect let length (#elt: Type) (a: array elt) : GTot nat = dsnd a val length_fits (#elt: Type) (a: array elt) : Lemma (US.fits (length a)) /// An abbreviation refining an array by its length inline_for_extraction [@@noextract_to "krml"] let larray (t:Type) (n:nat) = a:array t{ length a = n } /// The main representation predicate: /// A Steel separation logic heap predicate to describe that an array /// a points to some element sequence s with some permission p. /// /// A big design decision in this library was whether the second index /// of this predicate should be a [lseq t (length a)] or just a [seq t]. /// /// Making it an [lseq] forces every specification to be strongly /// typed, in the sense that the logical representation of an array /// has to be a sequence of the right length. This can be a little /// cumbersome in specifications, particularly as the refinement appears /// in some cases beneath the [erased] constructor. /// /// So, we opted instead to let the index be just a [seq t], and /// requiring length refinements on it in certain functions, only when /// necessary. val pts_to (#elt: Type0) (a: array elt) (p: P.perm) ([@@@ smt_fallback ] s: Seq.seq elt) : Tot vprop /// A stateful lemma to relate the size of an array with the size /// of the element sequence it points to /// This ghost function proves that an array always points to a /// sequence of the appropriate length val pts_to_length (#opened: _) (#elt: Type0) (#p: P.perm) (a: array elt) (s: Seq.seq elt) : STGhost unit opened (pts_to a p s) (fun _ -> pts_to a p s) (True) (fun _ -> Seq.length s == length a) val pts_to_not_null (#opened: _) (#elt: Type0) (#p: P.perm) (a: array elt) (s: Seq.seq elt) : STGhost unit opened (pts_to a p s) (fun _ -> pts_to a p s) (True) (fun _ -> a =!= null) /// An injectivity property, needed only to define a selector. Such a /// selector can be only defined in universe 0, and universes are not /// cumulative, so we need to define a separate module for arrays of /// universe 0 elements with selectors, reusing definitions from this /// interface, but we do not want to use `friend`. val pts_to_inj (#elt: Type0) (a: array elt) (p1: P.perm) (s1: Seq.seq elt) (p2: P.perm) (s2: Seq.seq elt) (m: mem) : Lemma (requires ( interp (hp_of (pts_to a p1 s1)) m /\ interp (hp_of (pts_to a p2 s2)) m )) (ensures ( s1 == s2 )) /// Allocating a new array of size n, where each cell is initialized /// with value x. We define the non-selector version of this operation /// (and others) with a _pt suffix in the name. let is_full_array (#elt: Type) (a: array elt) : Tot prop = length a == base_len (base (ptr_of a)) inline_for_extraction [@@noextract_to "krml"] val malloc (#elt: Type) (x: elt) (n: US.t) : ST (array elt) emp (fun a -> pts_to a P.full_perm (Seq.create (US.v n) x)) (True) (fun a -> length a == US.v n /\ is_full_array a ) inline_for_extraction [@@noextract_to "krml"] let alloc #elt = malloc #elt /// Freeing a full array. inline_for_extraction [@@ noextract_to "krml"; warn_on_use "Steel.Array.free_pt is currently unsound in the presence of zero-size subarrays, have you collected them all?"] val free (#elt: Type) (a: array elt) : ST unit (exists_ (pts_to a P.full_perm)) (fun _ -> emp) ( is_full_array a ) (fun _ -> True) /// Sharing and gathering permissions on an array. Those only /// manipulate permissions, so they are nothing more than stateful /// lemmas. val share (#opened: _) (#elt: Type) (#x: Seq.seq elt) (a: array elt) (p p1 p2: P.perm) : STGhost unit opened (pts_to a p x) (fun _ -> pts_to a p1 x `star` pts_to a p2 x) (p == p1 `P.sum_perm` p2) (fun _ -> True) val gather (#opened: _) (#elt: Type) (a: array elt) (#x1: Seq.seq elt) (p1: P.perm) (#x2: Seq.seq elt) (p2: P.perm) : STGhost unit opened (pts_to a p1 x1 `star` pts_to a p2 x2) (fun _ -> pts_to a (p1 `P.sum_perm` p2) x1) (True) (fun _ -> x1 == x2) /// Reading the i-th element of an array a. /// TODO: we should also provide an atomic version for small types. inline_for_extraction [@@noextract_to "krml"] val index (#t: Type) (#p: P.perm) (a: array t) (#s: Ghost.erased (Seq.seq t)) (i: US.t) : ST t (pts_to a p s) (fun _ -> pts_to a p s) (US.v i < length a \/ US.v i < Seq.length s) (fun res -> Seq.length s == length a /\ US.v i < Seq.length s /\ res == Seq.index s (US.v i)) inline_for_extraction [@@noextract_to "krml"] let read #t #p = index #t #p /// Writing the value v at the i-th element of an array a. /// TODO: we should also provide an atomic version for small types. inline_for_extraction [@@noextract_to "krml"] val upd (#t: Type) (a: array t) (#s: Ghost.erased (Seq.seq t)) (i: US.t {US.v i < Seq.length s}) (v: t) : STT unit (pts_to a P.full_perm s) (fun res -> pts_to a P.full_perm (Seq.upd s (US.v i) v)) inline_for_extraction [@@noextract_to "krml"] let write #t = upd #t /// An array a1 is adjacent to an array a2 if and only if they have /// the same base array and the end of a1 coincides with the beginning /// of a2 let adjacent (#elt: Type) (a1 a2: array elt) : Tot prop = base (ptr_of a1) == base (ptr_of a2) /\ offset (ptr_of a1) + (length a1) == offset (ptr_of a2) /// If two arrays are adjacent, then we can compute their merge, with /// their combined lengths. By virtue of the length being ghost, /// Karamel will extract it as "let y = a1" inline_for_extraction [@@noextract_to "krml"] let merge (#elt: Type) (a1: array elt) (a2: Ghost.erased (array elt)) : Pure (array elt) (requires (adjacent a1 a2)) (ensures (fun y -> length y == length a1 + length a2)) = (| ptr_of a1, Ghost.hide (length a1 + length a2) |) /// Adjacency and merging are associative. let merge_assoc (#elt: Type) (a1 a2 a3: array elt) : Lemma (requires ( (adjacent a1 a2 /\ adjacent a2 a3) \/ (adjacent a1 a2 /\ adjacent (merge a1 a2) a3) \/ (adjacent a2 a3 /\ adjacent a1 (merge a2 a3)) )) (ensures ( adjacent (merge a1 a2) a3 /\ adjacent a1 (merge a2 a3) /\ merge (merge a1 a2) a3 == merge a1 (merge a2 a3) )) = () /// A shortcut to combine adjacency and merging let merge_into (#elt: Type) (a1 a2 a: array elt) : Tot prop = adjacent a1 a2 /\ merge a1 a2 == a /// Spatial merging of two arrays, expressed in terms of `merge`. val ghost_join (#opened: _) (#elt: Type) (#x1 #x2: Seq.seq elt) (#p: P.perm) (a1 a2: array elt) (h: squash (adjacent a1 a2)) : STGhostT unit opened (pts_to a1 p x1 `star` pts_to a2 p x2) (fun res -> pts_to (merge a1 a2) p (x1 `Seq.append` x2)) /// Spatial merging, combining the use of `merge` and the call to the /// stateful lemma. Since the only operations are calls to stateful /// lemmas and pure computations, the overall computation is atomic /// and unobservable, so can be used anywhere in atomic contexts. By /// virtue of the length being ghost, Karamel will extract this to /// "let res = a1" inline_for_extraction // this will extract to "let res = a1" [@@noextract_to "krml"] let join (#opened: _) (#elt: Type) (#x1 #x2: Ghost.erased (Seq.seq elt)) (#p: P.perm) (a1: array elt) (a2: Ghost.erased (array elt)) : STAtomicBase (array elt) false opened Unobservable (pts_to a1 p x1 `star` pts_to a2 p x2) (fun res -> pts_to res p (x1 `Seq.append` x2)) (adjacent a1 a2)
false
false
Steel.ST.Array.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val join (#opened: _) (#elt: Type) (#x1 #x2: Ghost.erased (Seq.seq elt)) (#p: P.perm) (a1: array elt) (a2: Ghost.erased (array elt)) : STAtomicBase (array elt) false opened Unobservable ((pts_to a1 p x1) `star` (pts_to a2 p x2)) (fun res -> pts_to res p (x1 `Seq.append` x2)) (adjacent a1 a2) (fun res -> merge_into a1 a2 res)
[]
Steel.ST.Array.join
{ "file_name": "lib/steel/Steel.ST.Array.fsti", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
a1: Steel.ST.Array.array elt -> a2: FStar.Ghost.erased (Steel.ST.Array.array elt) -> Steel.ST.Effect.Atomic.STAtomicBase (Steel.ST.Array.array elt)
{ "end_col": 12, "end_line": 362, "start_col": 1, "start_line": 356 }
Prims.Tot
val parse_format_string (s: string) (parse_ext: extension_parser) : option (list dir)
[ { "abbrev": true, "full_module": "FStar.Integers", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse_format_string (s:string) (parse_ext:extension_parser) : option (list dir) = parse_format (list_of_string s) parse_ext
val parse_format_string (s: string) (parse_ext: extension_parser) : option (list dir) let parse_format_string (s: string) (parse_ext: extension_parser) : option (list dir) =
false
null
false
parse_format (list_of_string s) parse_ext
{ "checked_file": "FStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Printf.fst" }
[ "total" ]
[ "Prims.string", "FStar.Printf.extension_parser", "FStar.Printf.parse_format", "FStar.String.list_of_string", "FStar.Pervasives.Native.option", "Prims.list", "FStar.Printf.dir" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Printf (* * A variable arity C-style printf * See tests/micro-benchmarks/Test.Printf.fst for example usage *) open FStar.Char open FStar.String module I = FStar.Integers noeq type extension = | MkExtension : #a:Type0 -> $f:(a -> Tot string) -> extension /// `arg`: The format specifiers supported /// %b : bool /// %d : int /// %c : char /// %s : string /// %uy : U8.t /// %us : U16.t /// %ul : U32.t /// %uL : U64.t /// %y : Int8.t /// %i : Int16.t /// %l : Int32.t /// %L : Int64.t noeq type arg = | Bool | Int | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 | Extension of extension /// `arg_type`: Interpreting a `arg` tag as a type let arg_type (a:arg) : Tot Type0 = match a with | Bool -> bool | Int -> int | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t | Extension (MkExtension #t _) -> t let string_of_arg (#a:arg) (x:arg_type a) : string = match a with | Bool -> string_of_bool x | Int -> string_of_int x | Char -> string_of_char x | String -> x | U8 -> FStar.UInt8.to_string x | U16 -> FStar.UInt16.to_string x | U32 -> FStar.UInt32.to_string x | U64 -> FStar.UInt64.to_string x | I8 -> FStar.Int8.to_string x | I16 -> FStar.Int16.to_string x | I32 -> FStar.Int32.to_string x | I64 -> FStar.Int64.to_string x | Extension (MkExtension f) -> f x /// `dir`: Internal to this module /// A 'directive"; used when parsing a format specifier noeq type dir = | Lit of char | Arg of arg /// `dir_type ds`: Interpreting a list directives as a pure function type let rec dir_type (ds:list dir) : Tot Type0 = match ds with | [] -> string | Lit c :: ds' -> dir_type ds' | Arg a :: ds' -> arg_type a -> dir_type ds' /// `string_of_dirs ds`: /// Interpreting a list of directives as its function, /// in a continuation-passing style let rec string_of_dirs (ds:list dir) (k:string -> string) : dir_type ds = match ds with | [] -> k "" | Lit c :: ds' -> string_of_dirs ds' (fun res -> k (string_of_char c ^ res)) <: normalize_term (dir_type ds') | Arg a :: ds' -> fun (x : arg_type a) -> string_of_dirs ds' (fun res -> ((k "") ^ string_of_arg x ^ res)) type extension_parser = i:list char -> option (extension * o:list char{o << i}) /// `parse_format s`: /// Parses a list of characters into a list of directives /// Or None, in case the format string is invalid let rec parse_format (s:list char) (parse_ext: extension_parser) : option (list dir) = let add_dir (d:dir) (ods : option (list dir)) : option (list dir) = match ods with | None -> None | Some ds -> Some (d::ds) in match s with | [] -> Some [] | ['%'] -> None //Unsigned integers beging with '%u' | '%' :: 'u' :: s' -> begin match s' with | 'y' :: s'' -> add_dir (Arg U8) (parse_format s'' parse_ext) | 's' :: s'' -> add_dir (Arg U16) (parse_format s'' parse_ext) | 'l' :: s'' -> add_dir (Arg U32) (parse_format s'' parse_ext) | 'L' :: s'' -> add_dir (Arg U64) (parse_format s'' parse_ext) | _ -> None end //User extensions begin with '%X' | '%' :: 'X' :: s' -> begin match parse_ext s' with | Some (ext, rest) -> add_dir (Arg (Extension ext)) (parse_format rest parse_ext) | _ -> None end | '%' :: c :: s' -> begin match c with | '%' -> add_dir (Lit '%') (parse_format s' parse_ext) | 'b' -> add_dir (Arg Bool) (parse_format s' parse_ext) | 'd' -> add_dir (Arg Int) (parse_format s' parse_ext) | 'c' -> add_dir (Arg Char) (parse_format s' parse_ext) | 's' -> add_dir (Arg String) (parse_format s' parse_ext) | 'y' -> add_dir (Arg I8) (parse_format s' parse_ext) | 'i' -> add_dir (Arg I16) (parse_format s' parse_ext) | 'l' -> add_dir (Arg I32) (parse_format s' parse_ext) | 'L' -> add_dir (Arg I64) (parse_format s' parse_ext) | _ -> None end | c :: s' -> add_dir (Lit c) (parse_format s' parse_ext) /// `parse_format_string`: parses a format `string` into a list of directives let parse_format_string (s:string) (parse_ext:extension_parser)
false
true
FStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse_format_string (s: string) (parse_ext: extension_parser) : option (list dir)
[]
FStar.Printf.parse_format_string
{ "file_name": "ulib/FStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s: Prims.string -> parse_ext: FStar.Printf.extension_parser -> FStar.Pervasives.Native.option (Prims.list FStar.Printf.dir)
{ "end_col": 45, "end_line": 182, "start_col": 4, "start_line": 182 }
Prims.Tot
val no_extensions:extension_parser
[ { "abbrev": true, "full_module": "FStar.Integers", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let no_extensions : extension_parser = fun s -> None
val no_extensions:extension_parser let no_extensions:extension_parser =
false
null
false
fun s -> None
{ "checked_file": "FStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Printf.fst" }
[ "total" ]
[ "Prims.list", "FStar.String.char", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.tuple2", "FStar.Printf.extension", "Prims.precedes", "FStar.Pervasives.Native.option" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Printf (* * A variable arity C-style printf * See tests/micro-benchmarks/Test.Printf.fst for example usage *) open FStar.Char open FStar.String module I = FStar.Integers noeq type extension = | MkExtension : #a:Type0 -> $f:(a -> Tot string) -> extension /// `arg`: The format specifiers supported /// %b : bool /// %d : int /// %c : char /// %s : string /// %uy : U8.t /// %us : U16.t /// %ul : U32.t /// %uL : U64.t /// %y : Int8.t /// %i : Int16.t /// %l : Int32.t /// %L : Int64.t noeq type arg = | Bool | Int | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 | Extension of extension /// `arg_type`: Interpreting a `arg` tag as a type let arg_type (a:arg) : Tot Type0 = match a with | Bool -> bool | Int -> int | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t | Extension (MkExtension #t _) -> t let string_of_arg (#a:arg) (x:arg_type a) : string = match a with | Bool -> string_of_bool x | Int -> string_of_int x | Char -> string_of_char x | String -> x | U8 -> FStar.UInt8.to_string x | U16 -> FStar.UInt16.to_string x | U32 -> FStar.UInt32.to_string x | U64 -> FStar.UInt64.to_string x | I8 -> FStar.Int8.to_string x | I16 -> FStar.Int16.to_string x | I32 -> FStar.Int32.to_string x | I64 -> FStar.Int64.to_string x | Extension (MkExtension f) -> f x /// `dir`: Internal to this module /// A 'directive"; used when parsing a format specifier noeq type dir = | Lit of char | Arg of arg /// `dir_type ds`: Interpreting a list directives as a pure function type let rec dir_type (ds:list dir) : Tot Type0 = match ds with | [] -> string | Lit c :: ds' -> dir_type ds' | Arg a :: ds' -> arg_type a -> dir_type ds' /// `string_of_dirs ds`: /// Interpreting a list of directives as its function, /// in a continuation-passing style let rec string_of_dirs (ds:list dir) (k:string -> string) : dir_type ds = match ds with | [] -> k "" | Lit c :: ds' -> string_of_dirs ds' (fun res -> k (string_of_char c ^ res)) <: normalize_term (dir_type ds') | Arg a :: ds' -> fun (x : arg_type a) -> string_of_dirs ds' (fun res -> ((k "") ^ string_of_arg x ^ res)) type extension_parser = i:list char -> option (extension * o:list char{o << i}) /// `parse_format s`: /// Parses a list of characters into a list of directives /// Or None, in case the format string is invalid let rec parse_format (s:list char) (parse_ext: extension_parser) : option (list dir) = let add_dir (d:dir) (ods : option (list dir)) : option (list dir) = match ods with | None -> None | Some ds -> Some (d::ds) in match s with | [] -> Some [] | ['%'] -> None //Unsigned integers beging with '%u' | '%' :: 'u' :: s' -> begin match s' with | 'y' :: s'' -> add_dir (Arg U8) (parse_format s'' parse_ext) | 's' :: s'' -> add_dir (Arg U16) (parse_format s'' parse_ext) | 'l' :: s'' -> add_dir (Arg U32) (parse_format s'' parse_ext) | 'L' :: s'' -> add_dir (Arg U64) (parse_format s'' parse_ext) | _ -> None end //User extensions begin with '%X' | '%' :: 'X' :: s' -> begin match parse_ext s' with | Some (ext, rest) -> add_dir (Arg (Extension ext)) (parse_format rest parse_ext) | _ -> None end | '%' :: c :: s' -> begin match c with | '%' -> add_dir (Lit '%') (parse_format s' parse_ext) | 'b' -> add_dir (Arg Bool) (parse_format s' parse_ext) | 'd' -> add_dir (Arg Int) (parse_format s' parse_ext) | 'c' -> add_dir (Arg Char) (parse_format s' parse_ext) | 's' -> add_dir (Arg String) (parse_format s' parse_ext) | 'y' -> add_dir (Arg I8) (parse_format s' parse_ext) | 'i' -> add_dir (Arg I16) (parse_format s' parse_ext) | 'l' -> add_dir (Arg I32) (parse_format s' parse_ext) | 'L' -> add_dir (Arg I64) (parse_format s' parse_ext) | _ -> None end | c :: s' -> add_dir (Lit c) (parse_format s' parse_ext) /// `parse_format_string`: parses a format `string` into a list of directives let parse_format_string (s:string) (parse_ext:extension_parser) : option (list dir) = parse_format (list_of_string s) parse_ext
false
true
FStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val no_extensions:extension_parser
[]
FStar.Printf.no_extensions
{ "file_name": "ulib/FStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
FStar.Printf.extension_parser
{ "end_col": 52, "end_line": 184, "start_col": 39, "start_line": 184 }
Prims.Tot
val string_of_arg (#a: arg) (x: arg_type a) : string
[ { "abbrev": true, "full_module": "FStar.Integers", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let string_of_arg (#a:arg) (x:arg_type a) : string = match a with | Bool -> string_of_bool x | Int -> string_of_int x | Char -> string_of_char x | String -> x | U8 -> FStar.UInt8.to_string x | U16 -> FStar.UInt16.to_string x | U32 -> FStar.UInt32.to_string x | U64 -> FStar.UInt64.to_string x | I8 -> FStar.Int8.to_string x | I16 -> FStar.Int16.to_string x | I32 -> FStar.Int32.to_string x | I64 -> FStar.Int64.to_string x | Extension (MkExtension f) -> f x
val string_of_arg (#a: arg) (x: arg_type a) : string let string_of_arg (#a: arg) (x: arg_type a) : string =
false
null
false
match a with | Bool -> string_of_bool x | Int -> string_of_int x | Char -> string_of_char x | String -> x | U8 -> FStar.UInt8.to_string x | U16 -> FStar.UInt16.to_string x | U32 -> FStar.UInt32.to_string x | U64 -> FStar.UInt64.to_string x | I8 -> FStar.Int8.to_string x | I16 -> FStar.Int16.to_string x | I32 -> FStar.Int32.to_string x | I64 -> FStar.Int64.to_string x | Extension (MkExtension f) -> f x
{ "checked_file": "FStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Printf.fst" }
[ "total" ]
[ "FStar.Printf.arg", "FStar.Printf.arg_type", "Prims.string_of_bool", "Prims.string_of_int", "FStar.String.string_of_char", "FStar.UInt8.to_string", "FStar.UInt16.to_string", "FStar.UInt32.to_string", "FStar.UInt64.to_string", "FStar.Int8.to_string", "FStar.Int16.to_string", "FStar.Int32.to_string", "FStar.Int64.to_string", "Prims.string" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Printf (* * A variable arity C-style printf * See tests/micro-benchmarks/Test.Printf.fst for example usage *) open FStar.Char open FStar.String module I = FStar.Integers noeq type extension = | MkExtension : #a:Type0 -> $f:(a -> Tot string) -> extension /// `arg`: The format specifiers supported /// %b : bool /// %d : int /// %c : char /// %s : string /// %uy : U8.t /// %us : U16.t /// %ul : U32.t /// %uL : U64.t /// %y : Int8.t /// %i : Int16.t /// %l : Int32.t /// %L : Int64.t noeq type arg = | Bool | Int | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 | Extension of extension /// `arg_type`: Interpreting a `arg` tag as a type let arg_type (a:arg) : Tot Type0 = match a with | Bool -> bool | Int -> int | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t | Extension (MkExtension #t _) -> t
false
false
FStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val string_of_arg (#a: arg) (x: arg_type a) : string
[]
FStar.Printf.string_of_arg
{ "file_name": "ulib/FStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: FStar.Printf.arg_type a -> Prims.string
{ "end_col": 38, "end_line": 91, "start_col": 4, "start_line": 78 }
Prims.Tot
val arg_type (a: arg) : Tot Type0
[ { "abbrev": true, "full_module": "FStar.Integers", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let arg_type (a:arg) : Tot Type0 = match a with | Bool -> bool | Int -> int | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t | Extension (MkExtension #t _) -> t
val arg_type (a: arg) : Tot Type0 let arg_type (a: arg) : Tot Type0 =
false
null
false
match a with | Bool -> bool | Int -> int | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t | Extension (MkExtension #t _) -> t
{ "checked_file": "FStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Printf.fst" }
[ "total" ]
[ "FStar.Printf.arg", "Prims.bool", "Prims.int", "FStar.String.char", "Prims.string", "FStar.UInt8.t", "FStar.UInt16.t", "FStar.UInt32.t", "FStar.UInt64.t", "FStar.Int8.t", "FStar.Int16.t", "FStar.Int32.t", "FStar.Int64.t" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Printf (* * A variable arity C-style printf * See tests/micro-benchmarks/Test.Printf.fst for example usage *) open FStar.Char open FStar.String module I = FStar.Integers noeq type extension = | MkExtension : #a:Type0 -> $f:(a -> Tot string) -> extension /// `arg`: The format specifiers supported /// %b : bool /// %d : int /// %c : char /// %s : string /// %uy : U8.t /// %us : U16.t /// %ul : U32.t /// %uL : U64.t /// %y : Int8.t /// %i : Int16.t /// %l : Int32.t /// %L : Int64.t noeq type arg = | Bool | Int | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 | Extension of extension /// `arg_type`: Interpreting a `arg` tag as a type
false
true
FStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val arg_type (a: arg) : Tot Type0
[]
FStar.Printf.arg_type
{ "file_name": "ulib/FStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.Printf.arg -> Type0
{ "end_col": 38, "end_line": 75, "start_col": 2, "start_line": 62 }
Prims.Tot
val string_of_dirs (ds: list dir) (k: (string -> string)) : dir_type ds
[ { "abbrev": true, "full_module": "FStar.Integers", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec string_of_dirs (ds:list dir) (k:string -> string) : dir_type ds = match ds with | [] -> k "" | Lit c :: ds' -> string_of_dirs ds' (fun res -> k (string_of_char c ^ res)) <: normalize_term (dir_type ds') | Arg a :: ds' -> fun (x : arg_type a) -> string_of_dirs ds' (fun res -> ((k "") ^ string_of_arg x ^ res))
val string_of_dirs (ds: list dir) (k: (string -> string)) : dir_type ds let rec string_of_dirs (ds: list dir) (k: (string -> string)) : dir_type ds =
false
null
false
match ds with | [] -> k "" | Lit c :: ds' -> string_of_dirs ds' (fun res -> k (string_of_char c ^ res)) <: normalize_term (dir_type ds') | Arg a :: ds' -> fun (x: arg_type a) -> string_of_dirs ds' (fun res -> ((k "") ^ string_of_arg x ^ res))
{ "checked_file": "FStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Printf.fst" }
[ "total" ]
[ "Prims.list", "FStar.Printf.dir", "Prims.string", "FStar.String.char", "FStar.Printf.string_of_dirs", "Prims.op_Hat", "FStar.String.string_of_char", "FStar.Pervasives.normalize_term", "FStar.Printf.dir_type", "FStar.Printf.arg", "FStar.Printf.arg_type", "FStar.Printf.string_of_arg" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Printf (* * A variable arity C-style printf * See tests/micro-benchmarks/Test.Printf.fst for example usage *) open FStar.Char open FStar.String module I = FStar.Integers noeq type extension = | MkExtension : #a:Type0 -> $f:(a -> Tot string) -> extension /// `arg`: The format specifiers supported /// %b : bool /// %d : int /// %c : char /// %s : string /// %uy : U8.t /// %us : U16.t /// %ul : U32.t /// %uL : U64.t /// %y : Int8.t /// %i : Int16.t /// %l : Int32.t /// %L : Int64.t noeq type arg = | Bool | Int | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 | Extension of extension /// `arg_type`: Interpreting a `arg` tag as a type let arg_type (a:arg) : Tot Type0 = match a with | Bool -> bool | Int -> int | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t | Extension (MkExtension #t _) -> t let string_of_arg (#a:arg) (x:arg_type a) : string = match a with | Bool -> string_of_bool x | Int -> string_of_int x | Char -> string_of_char x | String -> x | U8 -> FStar.UInt8.to_string x | U16 -> FStar.UInt16.to_string x | U32 -> FStar.UInt32.to_string x | U64 -> FStar.UInt64.to_string x | I8 -> FStar.Int8.to_string x | I16 -> FStar.Int16.to_string x | I32 -> FStar.Int32.to_string x | I64 -> FStar.Int64.to_string x | Extension (MkExtension f) -> f x /// `dir`: Internal to this module /// A 'directive"; used when parsing a format specifier noeq type dir = | Lit of char | Arg of arg /// `dir_type ds`: Interpreting a list directives as a pure function type let rec dir_type (ds:list dir) : Tot Type0 = match ds with | [] -> string | Lit c :: ds' -> dir_type ds' | Arg a :: ds' -> arg_type a -> dir_type ds' /// `string_of_dirs ds`: /// Interpreting a list of directives as its function, /// in a continuation-passing style let rec string_of_dirs (ds:list dir) (k:string -> string)
false
false
FStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val string_of_dirs (ds: list dir) (k: (string -> string)) : dir_type ds
[ "recursion" ]
FStar.Printf.string_of_dirs
{ "file_name": "ulib/FStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
ds: Prims.list FStar.Printf.dir -> k: (_: Prims.string -> Prims.string) -> FStar.Printf.dir_type ds
{ "end_col": 44, "end_line": 123, "start_col": 4, "start_line": 114 }
Prims.Tot
val dir_type (ds: list dir) : Tot Type0
[ { "abbrev": true, "full_module": "FStar.Integers", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec dir_type (ds:list dir) : Tot Type0 = match ds with | [] -> string | Lit c :: ds' -> dir_type ds' | Arg a :: ds' -> arg_type a -> dir_type ds'
val dir_type (ds: list dir) : Tot Type0 let rec dir_type (ds: list dir) : Tot Type0 =
false
null
false
match ds with | [] -> string | Lit c :: ds' -> dir_type ds' | Arg a :: ds' -> arg_type a -> dir_type ds'
{ "checked_file": "FStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Printf.fst" }
[ "total" ]
[ "Prims.list", "FStar.Printf.dir", "Prims.string", "FStar.String.char", "FStar.Printf.dir_type", "FStar.Printf.arg", "FStar.Printf.arg_type" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Printf (* * A variable arity C-style printf * See tests/micro-benchmarks/Test.Printf.fst for example usage *) open FStar.Char open FStar.String module I = FStar.Integers noeq type extension = | MkExtension : #a:Type0 -> $f:(a -> Tot string) -> extension /// `arg`: The format specifiers supported /// %b : bool /// %d : int /// %c : char /// %s : string /// %uy : U8.t /// %us : U16.t /// %ul : U32.t /// %uL : U64.t /// %y : Int8.t /// %i : Int16.t /// %l : Int32.t /// %L : Int64.t noeq type arg = | Bool | Int | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 | Extension of extension /// `arg_type`: Interpreting a `arg` tag as a type let arg_type (a:arg) : Tot Type0 = match a with | Bool -> bool | Int -> int | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t | Extension (MkExtension #t _) -> t let string_of_arg (#a:arg) (x:arg_type a) : string = match a with | Bool -> string_of_bool x | Int -> string_of_int x | Char -> string_of_char x | String -> x | U8 -> FStar.UInt8.to_string x | U16 -> FStar.UInt16.to_string x | U32 -> FStar.UInt32.to_string x | U64 -> FStar.UInt64.to_string x | I8 -> FStar.Int8.to_string x | I16 -> FStar.Int16.to_string x | I32 -> FStar.Int32.to_string x | I64 -> FStar.Int64.to_string x | Extension (MkExtension f) -> f x /// `dir`: Internal to this module /// A 'directive"; used when parsing a format specifier noeq type dir = | Lit of char | Arg of arg /// `dir_type ds`: Interpreting a list directives as a pure function type
false
true
FStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val dir_type (ds: list dir) : Tot Type0
[ "recursion" ]
FStar.Printf.dir_type
{ "file_name": "ulib/FStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
ds: Prims.list FStar.Printf.dir -> Type0
{ "end_col": 46, "end_line": 105, "start_col": 2, "start_line": 102 }
Prims.Tot
val parse_format (s: list char) (parse_ext: extension_parser) : option (list dir)
[ { "abbrev": true, "full_module": "FStar.Integers", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec parse_format (s:list char) (parse_ext: extension_parser) : option (list dir) = let add_dir (d:dir) (ods : option (list dir)) : option (list dir) = match ods with | None -> None | Some ds -> Some (d::ds) in match s with | [] -> Some [] | ['%'] -> None //Unsigned integers beging with '%u' | '%' :: 'u' :: s' -> begin match s' with | 'y' :: s'' -> add_dir (Arg U8) (parse_format s'' parse_ext) | 's' :: s'' -> add_dir (Arg U16) (parse_format s'' parse_ext) | 'l' :: s'' -> add_dir (Arg U32) (parse_format s'' parse_ext) | 'L' :: s'' -> add_dir (Arg U64) (parse_format s'' parse_ext) | _ -> None end //User extensions begin with '%X' | '%' :: 'X' :: s' -> begin match parse_ext s' with | Some (ext, rest) -> add_dir (Arg (Extension ext)) (parse_format rest parse_ext) | _ -> None end | '%' :: c :: s' -> begin match c with | '%' -> add_dir (Lit '%') (parse_format s' parse_ext) | 'b' -> add_dir (Arg Bool) (parse_format s' parse_ext) | 'd' -> add_dir (Arg Int) (parse_format s' parse_ext) | 'c' -> add_dir (Arg Char) (parse_format s' parse_ext) | 's' -> add_dir (Arg String) (parse_format s' parse_ext) | 'y' -> add_dir (Arg I8) (parse_format s' parse_ext) | 'i' -> add_dir (Arg I16) (parse_format s' parse_ext) | 'l' -> add_dir (Arg I32) (parse_format s' parse_ext) | 'L' -> add_dir (Arg I64) (parse_format s' parse_ext) | _ -> None end | c :: s' -> add_dir (Lit c) (parse_format s' parse_ext)
val parse_format (s: list char) (parse_ext: extension_parser) : option (list dir) let rec parse_format (s: list char) (parse_ext: extension_parser) : option (list dir) =
false
null
false
let add_dir (d: dir) (ods: option (list dir)) : option (list dir) = match ods with | None -> None | Some ds -> Some (d :: ds) in match s with | [] -> Some [] | ['%'] -> None | '%' :: 'u' :: s' -> (match s' with | 'y' :: s'' -> add_dir (Arg U8) (parse_format s'' parse_ext) | 's' :: s'' -> add_dir (Arg U16) (parse_format s'' parse_ext) | 'l' :: s'' -> add_dir (Arg U32) (parse_format s'' parse_ext) | 'L' :: s'' -> add_dir (Arg U64) (parse_format s'' parse_ext) | _ -> None) | '%' :: 'X' :: s' -> (match parse_ext s' with | Some (ext, rest) -> add_dir (Arg (Extension ext)) (parse_format rest parse_ext) | _ -> None) | '%' :: c :: s' -> (match c with | '%' -> add_dir (Lit '%') (parse_format s' parse_ext) | 'b' -> add_dir (Arg Bool) (parse_format s' parse_ext) | 'd' -> add_dir (Arg Int) (parse_format s' parse_ext) | 'c' -> add_dir (Arg Char) (parse_format s' parse_ext) | 's' -> add_dir (Arg String) (parse_format s' parse_ext) | 'y' -> add_dir (Arg I8) (parse_format s' parse_ext) | 'i' -> add_dir (Arg I16) (parse_format s' parse_ext) | 'l' -> add_dir (Arg I32) (parse_format s' parse_ext) | 'L' -> add_dir (Arg I64) (parse_format s' parse_ext) | _ -> None) | c :: s' -> add_dir (Lit c) (parse_format s' parse_ext)
{ "checked_file": "FStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Printf.fst" }
[ "total" ]
[ "Prims.list", "FStar.String.char", "FStar.Printf.extension_parser", "FStar.Pervasives.Native.Some", "FStar.Printf.dir", "Prims.Nil", "FStar.Pervasives.Native.None", "FStar.Printf.Arg", "FStar.Printf.U8", "FStar.Printf.parse_format", "FStar.Printf.U16", "FStar.Printf.U32", "FStar.Printf.U64", "FStar.Pervasives.Native.option", "FStar.Printf.extension", "Prims.precedes", "FStar.Printf.Extension", "FStar.Pervasives.Native.tuple2", "FStar.Printf.Lit", "FStar.Printf.Bool", "FStar.Printf.Int", "FStar.Printf.Char", "FStar.Printf.String", "FStar.Printf.I8", "FStar.Printf.I16", "FStar.Printf.I32", "FStar.Printf.I64", "FStar.Char.char", "Prims.Cons" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Printf (* * A variable arity C-style printf * See tests/micro-benchmarks/Test.Printf.fst for example usage *) open FStar.Char open FStar.String module I = FStar.Integers noeq type extension = | MkExtension : #a:Type0 -> $f:(a -> Tot string) -> extension /// `arg`: The format specifiers supported /// %b : bool /// %d : int /// %c : char /// %s : string /// %uy : U8.t /// %us : U16.t /// %ul : U32.t /// %uL : U64.t /// %y : Int8.t /// %i : Int16.t /// %l : Int32.t /// %L : Int64.t noeq type arg = | Bool | Int | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 | Extension of extension /// `arg_type`: Interpreting a `arg` tag as a type let arg_type (a:arg) : Tot Type0 = match a with | Bool -> bool | Int -> int | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t | Extension (MkExtension #t _) -> t let string_of_arg (#a:arg) (x:arg_type a) : string = match a with | Bool -> string_of_bool x | Int -> string_of_int x | Char -> string_of_char x | String -> x | U8 -> FStar.UInt8.to_string x | U16 -> FStar.UInt16.to_string x | U32 -> FStar.UInt32.to_string x | U64 -> FStar.UInt64.to_string x | I8 -> FStar.Int8.to_string x | I16 -> FStar.Int16.to_string x | I32 -> FStar.Int32.to_string x | I64 -> FStar.Int64.to_string x | Extension (MkExtension f) -> f x /// `dir`: Internal to this module /// A 'directive"; used when parsing a format specifier noeq type dir = | Lit of char | Arg of arg /// `dir_type ds`: Interpreting a list directives as a pure function type let rec dir_type (ds:list dir) : Tot Type0 = match ds with | [] -> string | Lit c :: ds' -> dir_type ds' | Arg a :: ds' -> arg_type a -> dir_type ds' /// `string_of_dirs ds`: /// Interpreting a list of directives as its function, /// in a continuation-passing style let rec string_of_dirs (ds:list dir) (k:string -> string) : dir_type ds = match ds with | [] -> k "" | Lit c :: ds' -> string_of_dirs ds' (fun res -> k (string_of_char c ^ res)) <: normalize_term (dir_type ds') | Arg a :: ds' -> fun (x : arg_type a) -> string_of_dirs ds' (fun res -> ((k "") ^ string_of_arg x ^ res)) type extension_parser = i:list char -> option (extension * o:list char{o << i}) /// `parse_format s`: /// Parses a list of characters into a list of directives /// Or None, in case the format string is invalid let rec parse_format (s:list char) (parse_ext: extension_parser)
false
true
FStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse_format (s: list char) (parse_ext: extension_parser) : option (list dir)
[ "recursion" ]
FStar.Printf.parse_format
{ "file_name": "ulib/FStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s: Prims.list FStar.String.char -> parse_ext: FStar.Printf.extension_parser -> FStar.Pervasives.Native.option (Prims.list FStar.Printf.dir)
{ "end_col": 51, "end_line": 175, "start_col": 5, "start_line": 134 }
Prims.Tot
val sprintf (s: string{normalize_term (b2t (Some? (parse_format_string s no_extensions)))}) : normalize_term (dir_type (Some?.v (parse_format_string s no_extensions)))
[ { "abbrev": true, "full_module": "FStar.Integers", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sprintf (s:string{normalize_term (b2t (Some? (parse_format_string s no_extensions)))}) : normalize_term (dir_type (Some?.v (parse_format_string s no_extensions))) = normalize_term (string_of_dirs (Some?.v (parse_format_string s no_extensions)) (fun s -> s))
val sprintf (s: string{normalize_term (b2t (Some? (parse_format_string s no_extensions)))}) : normalize_term (dir_type (Some?.v (parse_format_string s no_extensions))) let sprintf (s: string{normalize_term (b2t (Some? (parse_format_string s no_extensions)))}) : normalize_term (dir_type (Some?.v (parse_format_string s no_extensions))) =
false
null
false
normalize_term (string_of_dirs (Some?.v (parse_format_string s no_extensions)) (fun s -> s))
{ "checked_file": "FStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Printf.fst" }
[ "total" ]
[ "Prims.string", "FStar.Pervasives.normalize_term", "Prims.b2t", "FStar.Pervasives.Native.uu___is_Some", "Prims.list", "FStar.Printf.dir", "FStar.Printf.parse_format_string", "FStar.Printf.no_extensions", "FStar.String.list_of_string", "FStar.Pervasives.Native.Some", "Prims.Nil", "FStar.Pervasives.Native.None", "FStar.String.char", "FStar.Printf.parse_format", "Prims.Cons", "FStar.Printf.Arg", "FStar.Printf.U8", "FStar.Pervasives.Native.option", "FStar.Printf.U16", "FStar.Printf.U32", "FStar.Printf.U64", "FStar.Printf.extension", "Prims.precedes", "FStar.Printf.Extension", "FStar.Pervasives.Native.tuple2", "FStar.Printf.Lit", "FStar.Printf.Bool", "FStar.Printf.Int", "FStar.Printf.Char", "FStar.Printf.String", "FStar.Printf.I8", "FStar.Printf.I16", "FStar.Printf.I32", "FStar.Printf.I64", "FStar.Char.char", "FStar.Printf.dir_type", "FStar.Printf.arg", "FStar.Printf.arg_type", "FStar.Printf.string_of_dirs", "FStar.Pervasives.Native.__proj__Some__item__v" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Printf (* * A variable arity C-style printf * See tests/micro-benchmarks/Test.Printf.fst for example usage *) open FStar.Char open FStar.String module I = FStar.Integers noeq type extension = | MkExtension : #a:Type0 -> $f:(a -> Tot string) -> extension /// `arg`: The format specifiers supported /// %b : bool /// %d : int /// %c : char /// %s : string /// %uy : U8.t /// %us : U16.t /// %ul : U32.t /// %uL : U64.t /// %y : Int8.t /// %i : Int16.t /// %l : Int32.t /// %L : Int64.t noeq type arg = | Bool | Int | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 | Extension of extension /// `arg_type`: Interpreting a `arg` tag as a type let arg_type (a:arg) : Tot Type0 = match a with | Bool -> bool | Int -> int | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t | Extension (MkExtension #t _) -> t let string_of_arg (#a:arg) (x:arg_type a) : string = match a with | Bool -> string_of_bool x | Int -> string_of_int x | Char -> string_of_char x | String -> x | U8 -> FStar.UInt8.to_string x | U16 -> FStar.UInt16.to_string x | U32 -> FStar.UInt32.to_string x | U64 -> FStar.UInt64.to_string x | I8 -> FStar.Int8.to_string x | I16 -> FStar.Int16.to_string x | I32 -> FStar.Int32.to_string x | I64 -> FStar.Int64.to_string x | Extension (MkExtension f) -> f x /// `dir`: Internal to this module /// A 'directive"; used when parsing a format specifier noeq type dir = | Lit of char | Arg of arg /// `dir_type ds`: Interpreting a list directives as a pure function type let rec dir_type (ds:list dir) : Tot Type0 = match ds with | [] -> string | Lit c :: ds' -> dir_type ds' | Arg a :: ds' -> arg_type a -> dir_type ds' /// `string_of_dirs ds`: /// Interpreting a list of directives as its function, /// in a continuation-passing style let rec string_of_dirs (ds:list dir) (k:string -> string) : dir_type ds = match ds with | [] -> k "" | Lit c :: ds' -> string_of_dirs ds' (fun res -> k (string_of_char c ^ res)) <: normalize_term (dir_type ds') | Arg a :: ds' -> fun (x : arg_type a) -> string_of_dirs ds' (fun res -> ((k "") ^ string_of_arg x ^ res)) type extension_parser = i:list char -> option (extension * o:list char{o << i}) /// `parse_format s`: /// Parses a list of characters into a list of directives /// Or None, in case the format string is invalid let rec parse_format (s:list char) (parse_ext: extension_parser) : option (list dir) = let add_dir (d:dir) (ods : option (list dir)) : option (list dir) = match ods with | None -> None | Some ds -> Some (d::ds) in match s with | [] -> Some [] | ['%'] -> None //Unsigned integers beging with '%u' | '%' :: 'u' :: s' -> begin match s' with | 'y' :: s'' -> add_dir (Arg U8) (parse_format s'' parse_ext) | 's' :: s'' -> add_dir (Arg U16) (parse_format s'' parse_ext) | 'l' :: s'' -> add_dir (Arg U32) (parse_format s'' parse_ext) | 'L' :: s'' -> add_dir (Arg U64) (parse_format s'' parse_ext) | _ -> None end //User extensions begin with '%X' | '%' :: 'X' :: s' -> begin match parse_ext s' with | Some (ext, rest) -> add_dir (Arg (Extension ext)) (parse_format rest parse_ext) | _ -> None end | '%' :: c :: s' -> begin match c with | '%' -> add_dir (Lit '%') (parse_format s' parse_ext) | 'b' -> add_dir (Arg Bool) (parse_format s' parse_ext) | 'd' -> add_dir (Arg Int) (parse_format s' parse_ext) | 'c' -> add_dir (Arg Char) (parse_format s' parse_ext) | 's' -> add_dir (Arg String) (parse_format s' parse_ext) | 'y' -> add_dir (Arg I8) (parse_format s' parse_ext) | 'i' -> add_dir (Arg I16) (parse_format s' parse_ext) | 'l' -> add_dir (Arg I32) (parse_format s' parse_ext) | 'L' -> add_dir (Arg I64) (parse_format s' parse_ext) | _ -> None end | c :: s' -> add_dir (Lit c) (parse_format s' parse_ext) /// `parse_format_string`: parses a format `string` into a list of directives let parse_format_string (s:string) (parse_ext:extension_parser) : option (list dir) = parse_format (list_of_string s) parse_ext let no_extensions : extension_parser = fun s -> None /// `sprintf`: The main function of this module /// A variable arity string formatter /// Used as: `sprintf "format string" v1 ... vn` /// /// It's marked `inline_for_extraction`, meaning that we don't need /// any special support in our compilation targets to support sprintf /// /// `sprintf "Hello %s" "world"` /// will just extract to `"Hello " ^ "world"` inline_for_extraction let sprintf (s:string{normalize_term (b2t (Some? (parse_format_string s no_extensions)))})
false
false
FStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sprintf (s: string{normalize_term (b2t (Some? (parse_format_string s no_extensions)))}) : normalize_term (dir_type (Some?.v (parse_format_string s no_extensions)))
[]
FStar.Printf.sprintf
{ "file_name": "ulib/FStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s: Prims.string { FStar.Pervasives.normalize_term (Some? (FStar.Printf.parse_format_string s FStar.Printf.no_extensions)) } -> FStar.Pervasives.normalize_term (FStar.Printf.dir_type (Some?.v (FStar.Printf.parse_format_string s FStar.Printf.no_extensions)))
{ "end_col": 98, "end_line": 199, "start_col": 6, "start_line": 199 }
Prims.Tot
val ext_sprintf (parse_ext: extension_parser) (s: string{normalize_term (b2t (Some? (parse_format_string s parse_ext)))}) : normalize_term (dir_type (Some?.v (parse_format_string s parse_ext)))
[ { "abbrev": true, "full_module": "FStar.Integers", "short_module": "I" }, { "abbrev": false, "full_module": "FStar.String", "short_module": null }, { "abbrev": false, "full_module": "FStar.Char", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ext_sprintf (parse_ext: extension_parser) (s:string{normalize_term (b2t (Some? (parse_format_string s parse_ext)))}) : normalize_term (dir_type (Some?.v (parse_format_string s parse_ext))) = normalize_term (string_of_dirs (Some?.v (parse_format_string s parse_ext)) (fun s -> s))
val ext_sprintf (parse_ext: extension_parser) (s: string{normalize_term (b2t (Some? (parse_format_string s parse_ext)))}) : normalize_term (dir_type (Some?.v (parse_format_string s parse_ext))) let ext_sprintf (parse_ext: extension_parser) (s: string{normalize_term (b2t (Some? (parse_format_string s parse_ext)))}) : normalize_term (dir_type (Some?.v (parse_format_string s parse_ext))) =
false
null
false
normalize_term (string_of_dirs (Some?.v (parse_format_string s parse_ext)) (fun s -> s))
{ "checked_file": "FStar.Printf.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.String.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Integers.fst.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Printf.fst" }
[ "total" ]
[ "FStar.Printf.extension_parser", "Prims.string", "FStar.Pervasives.normalize_term", "Prims.b2t", "FStar.Pervasives.Native.uu___is_Some", "Prims.list", "FStar.Printf.dir", "FStar.Printf.parse_format_string", "FStar.String.list_of_string", "FStar.Pervasives.Native.Some", "Prims.Nil", "FStar.Pervasives.Native.None", "FStar.String.char", "FStar.Printf.parse_format", "Prims.Cons", "FStar.Printf.Arg", "FStar.Printf.U8", "FStar.Pervasives.Native.option", "FStar.Printf.U16", "FStar.Printf.U32", "FStar.Printf.U64", "FStar.Printf.extension", "Prims.precedes", "FStar.Printf.Extension", "FStar.Pervasives.Native.tuple2", "FStar.Printf.Lit", "FStar.Printf.Bool", "FStar.Printf.Int", "FStar.Printf.Char", "FStar.Printf.String", "FStar.Printf.I8", "FStar.Printf.I16", "FStar.Printf.I32", "FStar.Printf.I64", "FStar.Char.char", "FStar.Printf.dir_type", "FStar.Printf.arg", "FStar.Printf.arg_type", "FStar.Printf.string_of_dirs", "FStar.Pervasives.Native.__proj__Some__item__v" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Printf (* * A variable arity C-style printf * See tests/micro-benchmarks/Test.Printf.fst for example usage *) open FStar.Char open FStar.String module I = FStar.Integers noeq type extension = | MkExtension : #a:Type0 -> $f:(a -> Tot string) -> extension /// `arg`: The format specifiers supported /// %b : bool /// %d : int /// %c : char /// %s : string /// %uy : U8.t /// %us : U16.t /// %ul : U32.t /// %uL : U64.t /// %y : Int8.t /// %i : Int16.t /// %l : Int32.t /// %L : Int64.t noeq type arg = | Bool | Int | Char | String | U8 | U16 | U32 | U64 | I8 | I16 | I32 | I64 | Extension of extension /// `arg_type`: Interpreting a `arg` tag as a type let arg_type (a:arg) : Tot Type0 = match a with | Bool -> bool | Int -> int | Char -> char | String -> string | U8 -> FStar.UInt8.t | U16 -> FStar.UInt16.t | U32 -> FStar.UInt32.t | U64 -> FStar.UInt64.t | I8 -> FStar.Int8.t | I16 -> FStar.Int16.t | I32 -> FStar.Int32.t | I64 -> FStar.Int64.t | Extension (MkExtension #t _) -> t let string_of_arg (#a:arg) (x:arg_type a) : string = match a with | Bool -> string_of_bool x | Int -> string_of_int x | Char -> string_of_char x | String -> x | U8 -> FStar.UInt8.to_string x | U16 -> FStar.UInt16.to_string x | U32 -> FStar.UInt32.to_string x | U64 -> FStar.UInt64.to_string x | I8 -> FStar.Int8.to_string x | I16 -> FStar.Int16.to_string x | I32 -> FStar.Int32.to_string x | I64 -> FStar.Int64.to_string x | Extension (MkExtension f) -> f x /// `dir`: Internal to this module /// A 'directive"; used when parsing a format specifier noeq type dir = | Lit of char | Arg of arg /// `dir_type ds`: Interpreting a list directives as a pure function type let rec dir_type (ds:list dir) : Tot Type0 = match ds with | [] -> string | Lit c :: ds' -> dir_type ds' | Arg a :: ds' -> arg_type a -> dir_type ds' /// `string_of_dirs ds`: /// Interpreting a list of directives as its function, /// in a continuation-passing style let rec string_of_dirs (ds:list dir) (k:string -> string) : dir_type ds = match ds with | [] -> k "" | Lit c :: ds' -> string_of_dirs ds' (fun res -> k (string_of_char c ^ res)) <: normalize_term (dir_type ds') | Arg a :: ds' -> fun (x : arg_type a) -> string_of_dirs ds' (fun res -> ((k "") ^ string_of_arg x ^ res)) type extension_parser = i:list char -> option (extension * o:list char{o << i}) /// `parse_format s`: /// Parses a list of characters into a list of directives /// Or None, in case the format string is invalid let rec parse_format (s:list char) (parse_ext: extension_parser) : option (list dir) = let add_dir (d:dir) (ods : option (list dir)) : option (list dir) = match ods with | None -> None | Some ds -> Some (d::ds) in match s with | [] -> Some [] | ['%'] -> None //Unsigned integers beging with '%u' | '%' :: 'u' :: s' -> begin match s' with | 'y' :: s'' -> add_dir (Arg U8) (parse_format s'' parse_ext) | 's' :: s'' -> add_dir (Arg U16) (parse_format s'' parse_ext) | 'l' :: s'' -> add_dir (Arg U32) (parse_format s'' parse_ext) | 'L' :: s'' -> add_dir (Arg U64) (parse_format s'' parse_ext) | _ -> None end //User extensions begin with '%X' | '%' :: 'X' :: s' -> begin match parse_ext s' with | Some (ext, rest) -> add_dir (Arg (Extension ext)) (parse_format rest parse_ext) | _ -> None end | '%' :: c :: s' -> begin match c with | '%' -> add_dir (Lit '%') (parse_format s' parse_ext) | 'b' -> add_dir (Arg Bool) (parse_format s' parse_ext) | 'd' -> add_dir (Arg Int) (parse_format s' parse_ext) | 'c' -> add_dir (Arg Char) (parse_format s' parse_ext) | 's' -> add_dir (Arg String) (parse_format s' parse_ext) | 'y' -> add_dir (Arg I8) (parse_format s' parse_ext) | 'i' -> add_dir (Arg I16) (parse_format s' parse_ext) | 'l' -> add_dir (Arg I32) (parse_format s' parse_ext) | 'L' -> add_dir (Arg I64) (parse_format s' parse_ext) | _ -> None end | c :: s' -> add_dir (Lit c) (parse_format s' parse_ext) /// `parse_format_string`: parses a format `string` into a list of directives let parse_format_string (s:string) (parse_ext:extension_parser) : option (list dir) = parse_format (list_of_string s) parse_ext let no_extensions : extension_parser = fun s -> None /// `sprintf`: The main function of this module /// A variable arity string formatter /// Used as: `sprintf "format string" v1 ... vn` /// /// It's marked `inline_for_extraction`, meaning that we don't need /// any special support in our compilation targets to support sprintf /// /// `sprintf "Hello %s" "world"` /// will just extract to `"Hello " ^ "world"` inline_for_extraction let sprintf (s:string{normalize_term (b2t (Some? (parse_format_string s no_extensions)))}) : normalize_term (dir_type (Some?.v (parse_format_string s no_extensions))) = normalize_term (string_of_dirs (Some?.v (parse_format_string s no_extensions)) (fun s -> s)) /// `ext_sprintf`: An extensible version of sprintf inline_for_extraction let ext_sprintf (parse_ext: extension_parser) (s:string{normalize_term (b2t (Some? (parse_format_string s parse_ext)))})
false
false
FStar.Printf.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ext_sprintf (parse_ext: extension_parser) (s: string{normalize_term (b2t (Some? (parse_format_string s parse_ext)))}) : normalize_term (dir_type (Some?.v (parse_format_string s parse_ext)))
[]
FStar.Printf.ext_sprintf
{ "file_name": "ulib/FStar.Printf.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
parse_ext: FStar.Printf.extension_parser -> s: Prims.string {FStar.Pervasives.normalize_term (Some? (FStar.Printf.parse_format_string s parse_ext))} -> FStar.Pervasives.normalize_term (FStar.Printf.dir_type (Some?.v (FStar.Printf.parse_format_string s parse_ext)))
{ "end_col": 94, "end_line": 208, "start_col": 6, "start_line": 208 }
Prims.Tot
val key0:(b: B.buffer UInt8.t {B.length b = 32 /\ B.recallable b})
[ { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Test.Vectors", "short_module": null }, { "abbrev": false, "full_module": "Test.Vectors", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let key0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy; 0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l
val key0:(b: B.buffer UInt8.t {B.length b = 32 /\ B.recallable b}) let key0:(b: B.buffer UInt8.t {B.length b = 32 /\ B.recallable b}) =
false
null
false
[@@ inline_let ]let l = [ 0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy; 0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l
{ "checked_file": "Test.Vectors.Chacha20Poly1305.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Test.Vectors.Chacha20Poly1305.fst" }
[ "total" ]
[ "LowStar.Buffer.gcmalloc_of_list", "FStar.UInt8.t", "FStar.Monotonic.HyperHeap.root", "LowStar.Monotonic.Buffer.mbuffer", "LowStar.Buffer.trivial_preorder", "Prims.l_and", "Prims.eq2", "Prims.nat", "LowStar.Monotonic.Buffer.length", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.length", "Prims.b2t", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "FStar.Monotonic.HyperHeap.rid", "LowStar.Monotonic.Buffer.frameOf", "LowStar.Monotonic.Buffer.recallable", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.op_Equality", "Prims.int", "LowStar.Buffer.buffer", "Prims.list", "Prims.Cons", "FStar.UInt8.__uint_to_t", "Prims.Nil" ]
[]
module Test.Vectors.Chacha20Poly1305 module B = LowStar.Buffer #set-options "--max_fuel 0 --max_ifuel 0"
false
false
Test.Vectors.Chacha20Poly1305.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val key0:(b: B.buffer UInt8.t {B.length b = 32 /\ B.recallable b})
[]
Test.Vectors.Chacha20Poly1305.key0
{ "file_name": "providers/test/vectors/Test.Vectors.Chacha20Poly1305.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: LowStar.Buffer.buffer FStar.UInt8.t {LowStar.Monotonic.Buffer.length b = 32 /\ LowStar.Monotonic.Buffer.recallable b}
{ "end_col": 38, "end_line": 10, "start_col": 2, "start_line": 8 }
Prims.Tot
val output1_len:(x: UInt32.t{UInt32.v x = B.length output1})
[ { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Test.Vectors", "short_module": null }, { "abbrev": false, "full_module": "Test.Vectors", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let output1_len: (x:UInt32.t { UInt32.v x = B.length output1 }) = 16ul
val output1_len:(x: UInt32.t{UInt32.v x = B.length output1}) let output1_len:(x: UInt32.t{UInt32.v x = B.length output1}) =
false
null
false
16ul
{ "checked_file": "Test.Vectors.Chacha20Poly1305.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Test.Vectors.Chacha20Poly1305.fst" }
[ "total" ]
[ "FStar.UInt32.__uint_to_t" ]
[]
module Test.Vectors.Chacha20Poly1305 module B = LowStar.Buffer #set-options "--max_fuel 0 --max_ifuel 0" let key0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy; 0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let key0_len: (x:UInt32.t { UInt32.v x = B.length key0 }) = 32ul let nonce0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) = [@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; ] in assert_norm (List.Tot.length l = 12); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let nonce0_len: (x:UInt32.t { UInt32.v x = B.length nonce0 }) = 12ul let aad0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) = [@inline_let] let l = [ 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x4euy; 0x91uy; ] in assert_norm (List.Tot.length l = 12); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let aad0_len: (x:UInt32.t { UInt32.v x = B.length aad0 }) = 12ul let input0: (b: B.buffer UInt8.t { B.length b = 265 /\ B.recallable b /\ B.disjoint b aad0 }) = B.recall aad0;[@inline_let] let l = [ 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x72uy; 0x65uy; 0x20uy; 0x64uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x76uy; 0x61uy; 0x6cuy; 0x69uy; 0x64uy; 0x20uy; 0x66uy; 0x6fuy; 0x72uy; 0x20uy; 0x61uy; 0x20uy; 0x6duy; 0x61uy; 0x78uy; 0x69uy; 0x6duy; 0x75uy; 0x6duy; 0x20uy; 0x6fuy; 0x66uy; 0x20uy; 0x73uy; 0x69uy; 0x78uy; 0x20uy; 0x6duy; 0x6fuy; 0x6euy; 0x74uy; 0x68uy; 0x73uy; 0x20uy; 0x61uy; 0x6euy; 0x64uy; 0x20uy; 0x6duy; 0x61uy; 0x79uy; 0x20uy; 0x62uy; 0x65uy; 0x20uy; 0x75uy; 0x70uy; 0x64uy; 0x61uy; 0x74uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x72uy; 0x65uy; 0x70uy; 0x6cuy; 0x61uy; 0x63uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x6fuy; 0x62uy; 0x73uy; 0x6fuy; 0x6cuy; 0x65uy; 0x74uy; 0x65uy; 0x64uy; 0x20uy; 0x62uy; 0x79uy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x74uy; 0x20uy; 0x61uy; 0x6euy; 0x79uy; 0x20uy; 0x74uy; 0x69uy; 0x6duy; 0x65uy; 0x2euy; 0x20uy; 0x49uy; 0x74uy; 0x20uy; 0x69uy; 0x73uy; 0x20uy; 0x69uy; 0x6euy; 0x61uy; 0x70uy; 0x70uy; 0x72uy; 0x6fuy; 0x70uy; 0x72uy; 0x69uy; 0x61uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x75uy; 0x73uy; 0x65uy; 0x20uy; 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x72uy; 0x65uy; 0x66uy; 0x65uy; 0x72uy; 0x65uy; 0x6euy; 0x63uy; 0x65uy; 0x20uy; 0x6duy; 0x61uy; 0x74uy; 0x65uy; 0x72uy; 0x69uy; 0x61uy; 0x6cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x63uy; 0x69uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x68uy; 0x65uy; 0x6duy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x74uy; 0x68uy; 0x61uy; 0x6euy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x2fuy; 0xe2uy; 0x80uy; 0x9cuy; 0x77uy; 0x6fuy; 0x72uy; 0x6buy; 0x20uy; 0x69uy; 0x6euy; 0x20uy; 0x70uy; 0x72uy; 0x6fuy; 0x67uy; 0x72uy; 0x65uy; 0x73uy; 0x73uy; 0x2euy; 0x2fuy; 0xe2uy; 0x80uy; 0x9duy; ] in assert_norm (List.Tot.length l = 265); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let input0_len: (x:UInt32.t { UInt32.v x = B.length input0 }) = 265ul let output0: (b: B.buffer UInt8.t { B.length b = 281 /\ B.recallable b }) = [@inline_let] let l = [ 0x64uy; 0xa0uy; 0x86uy; 0x15uy; 0x75uy; 0x86uy; 0x1auy; 0xf4uy; 0x60uy; 0xf0uy; 0x62uy; 0xc7uy; 0x9buy; 0xe6uy; 0x43uy; 0xbduy; 0x5euy; 0x80uy; 0x5cuy; 0xfduy; 0x34uy; 0x5cuy; 0xf3uy; 0x89uy; 0xf1uy; 0x08uy; 0x67uy; 0x0auy; 0xc7uy; 0x6cuy; 0x8cuy; 0xb2uy; 0x4cuy; 0x6cuy; 0xfcuy; 0x18uy; 0x75uy; 0x5duy; 0x43uy; 0xeeuy; 0xa0uy; 0x9euy; 0xe9uy; 0x4euy; 0x38uy; 0x2duy; 0x26uy; 0xb0uy; 0xbduy; 0xb7uy; 0xb7uy; 0x3cuy; 0x32uy; 0x1buy; 0x01uy; 0x00uy; 0xd4uy; 0xf0uy; 0x3buy; 0x7fuy; 0x35uy; 0x58uy; 0x94uy; 0xcfuy; 0x33uy; 0x2fuy; 0x83uy; 0x0euy; 0x71uy; 0x0buy; 0x97uy; 0xceuy; 0x98uy; 0xc8uy; 0xa8uy; 0x4auy; 0xbduy; 0x0buy; 0x94uy; 0x81uy; 0x14uy; 0xaduy; 0x17uy; 0x6euy; 0x00uy; 0x8duy; 0x33uy; 0xbduy; 0x60uy; 0xf9uy; 0x82uy; 0xb1uy; 0xffuy; 0x37uy; 0xc8uy; 0x55uy; 0x97uy; 0x97uy; 0xa0uy; 0x6euy; 0xf4uy; 0xf0uy; 0xefuy; 0x61uy; 0xc1uy; 0x86uy; 0x32uy; 0x4euy; 0x2buy; 0x35uy; 0x06uy; 0x38uy; 0x36uy; 0x06uy; 0x90uy; 0x7buy; 0x6auy; 0x7cuy; 0x02uy; 0xb0uy; 0xf9uy; 0xf6uy; 0x15uy; 0x7buy; 0x53uy; 0xc8uy; 0x67uy; 0xe4uy; 0xb9uy; 0x16uy; 0x6cuy; 0x76uy; 0x7buy; 0x80uy; 0x4duy; 0x46uy; 0xa5uy; 0x9buy; 0x52uy; 0x16uy; 0xcduy; 0xe7uy; 0xa4uy; 0xe9uy; 0x90uy; 0x40uy; 0xc5uy; 0xa4uy; 0x04uy; 0x33uy; 0x22uy; 0x5euy; 0xe2uy; 0x82uy; 0xa1uy; 0xb0uy; 0xa0uy; 0x6cuy; 0x52uy; 0x3euy; 0xafuy; 0x45uy; 0x34uy; 0xd7uy; 0xf8uy; 0x3fuy; 0xa1uy; 0x15uy; 0x5buy; 0x00uy; 0x47uy; 0x71uy; 0x8cuy; 0xbcuy; 0x54uy; 0x6auy; 0x0duy; 0x07uy; 0x2buy; 0x04uy; 0xb3uy; 0x56uy; 0x4euy; 0xeauy; 0x1buy; 0x42uy; 0x22uy; 0x73uy; 0xf5uy; 0x48uy; 0x27uy; 0x1auy; 0x0buy; 0xb2uy; 0x31uy; 0x60uy; 0x53uy; 0xfauy; 0x76uy; 0x99uy; 0x19uy; 0x55uy; 0xebuy; 0xd6uy; 0x31uy; 0x59uy; 0x43uy; 0x4euy; 0xceuy; 0xbbuy; 0x4euy; 0x46uy; 0x6duy; 0xaeuy; 0x5auy; 0x10uy; 0x73uy; 0xa6uy; 0x72uy; 0x76uy; 0x27uy; 0x09uy; 0x7auy; 0x10uy; 0x49uy; 0xe6uy; 0x17uy; 0xd9uy; 0x1duy; 0x36uy; 0x10uy; 0x94uy; 0xfauy; 0x68uy; 0xf0uy; 0xffuy; 0x77uy; 0x98uy; 0x71uy; 0x30uy; 0x30uy; 0x5buy; 0xeauy; 0xbauy; 0x2euy; 0xdauy; 0x04uy; 0xdfuy; 0x99uy; 0x7buy; 0x71uy; 0x4duy; 0x6cuy; 0x6fuy; 0x2cuy; 0x29uy; 0xa6uy; 0xaduy; 0x5cuy; 0xb4uy; 0x02uy; 0x2buy; 0x02uy; 0x70uy; 0x9buy; 0xeeuy; 0xaduy; 0x9duy; 0x67uy; 0x89uy; 0x0cuy; 0xbbuy; 0x22uy; 0x39uy; 0x23uy; 0x36uy; 0xfeuy; 0xa1uy; 0x85uy; 0x1fuy; 0x38uy; ] in assert_norm (List.Tot.length l = 281); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let output0_len: (x:UInt32.t { UInt32.v x = B.length output0 }) = 281ul let key1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x4cuy; 0xf5uy; 0x96uy; 0x83uy; 0x38uy; 0xe6uy; 0xaeuy; 0x7fuy; 0x2duy; 0x29uy; 0x25uy; 0x76uy; 0xd5uy; 0x75uy; 0x27uy; 0x86uy; 0x91uy; 0x9auy; 0x27uy; 0x7auy; 0xfbuy; 0x46uy; 0xc5uy; 0xefuy; 0x94uy; 0x81uy; 0x79uy; 0x57uy; 0x14uy; 0x59uy; 0x40uy; 0x68uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let key1_len: (x:UInt32.t { UInt32.v x = B.length key1 }) = 32ul let nonce1: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) = [@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0xcauy; 0xbfuy; 0x33uy; 0x71uy; 0x32uy; 0x45uy; 0x77uy; 0x8euy; ] in assert_norm (List.Tot.length l = 12); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let nonce1_len: (x:UInt32.t { UInt32.v x = B.length nonce1 }) = 12ul let aad1: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b }) = [@inline_let] let l = [ ] in assert_norm (List.Tot.length l = 0); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let aad1_len: (x:UInt32.t { UInt32.v x = B.length aad1 }) = 0ul let input1: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b /\ B.disjoint b aad1 }) = B.recall aad1;[@inline_let] let l = [ ] in assert_norm (List.Tot.length l = 0); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let input1_len: (x:UInt32.t { UInt32.v x = B.length input1 }) = 0ul let output1: (b: B.buffer UInt8.t { B.length b = 16 /\ B.recallable b }) = [@inline_let] let l = [ 0xeauy; 0xe0uy; 0x1euy; 0x9euy; 0x2cuy; 0x91uy; 0xaauy; 0xe1uy; 0xdbuy; 0x5duy; 0x99uy; 0x3fuy; 0x8auy; 0xf7uy; 0x69uy; 0x92uy; ] in assert_norm (List.Tot.length l = 16); B.gcmalloc_of_list HyperStack.root l
false
false
Test.Vectors.Chacha20Poly1305.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val output1_len:(x: UInt32.t{UInt32.v x = B.length output1})
[]
Test.Vectors.Chacha20Poly1305.output1_len
{ "file_name": "providers/test/vectors/Test.Vectors.Chacha20Poly1305.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: FStar.UInt32.t {FStar.UInt32.v x = LowStar.Monotonic.Buffer.length Test.Vectors.Chacha20Poly1305.output1}
{ "end_col": 6, "end_line": 85, "start_col": 2, "start_line": 85 }
Prims.Tot
val aad0_len:(x: UInt32.t{UInt32.v x = B.length aad0})
[ { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Test.Vectors", "short_module": null }, { "abbrev": false, "full_module": "Test.Vectors", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aad0_len: (x:UInt32.t { UInt32.v x = B.length aad0 }) = 12ul
val aad0_len:(x: UInt32.t{UInt32.v x = B.length aad0}) let aad0_len:(x: UInt32.t{UInt32.v x = B.length aad0}) =
false
null
false
12ul
{ "checked_file": "Test.Vectors.Chacha20Poly1305.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Test.Vectors.Chacha20Poly1305.fst" }
[ "total" ]
[ "FStar.UInt32.__uint_to_t" ]
[]
module Test.Vectors.Chacha20Poly1305 module B = LowStar.Buffer #set-options "--max_fuel 0 --max_ifuel 0" let key0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy; 0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let key0_len: (x:UInt32.t { UInt32.v x = B.length key0 }) = 32ul let nonce0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) = [@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; ] in assert_norm (List.Tot.length l = 12); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let nonce0_len: (x:UInt32.t { UInt32.v x = B.length nonce0 }) = 12ul let aad0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) = [@inline_let] let l = [ 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x4euy; 0x91uy; ] in assert_norm (List.Tot.length l = 12); B.gcmalloc_of_list HyperStack.root l
false
false
Test.Vectors.Chacha20Poly1305.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aad0_len:(x: UInt32.t{UInt32.v x = B.length aad0})
[]
Test.Vectors.Chacha20Poly1305.aad0_len
{ "file_name": "providers/test/vectors/Test.Vectors.Chacha20Poly1305.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: FStar.UInt32.t {FStar.UInt32.v x = LowStar.Monotonic.Buffer.length Test.Vectors.Chacha20Poly1305.aad0}
{ "end_col": 6, "end_line": 29, "start_col": 2, "start_line": 29 }
Prims.Tot
val key2_len:(x: UInt32.t{UInt32.v x = B.length key2})
[ { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Test.Vectors", "short_module": null }, { "abbrev": false, "full_module": "Test.Vectors", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let key2_len: (x:UInt32.t { UInt32.v x = B.length key2 }) = 32ul
val key2_len:(x: UInt32.t{UInt32.v x = B.length key2}) let key2_len:(x: UInt32.t{UInt32.v x = B.length key2}) =
false
null
false
32ul
{ "checked_file": "Test.Vectors.Chacha20Poly1305.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Test.Vectors.Chacha20Poly1305.fst" }
[ "total" ]
[ "FStar.UInt32.__uint_to_t" ]
[]
module Test.Vectors.Chacha20Poly1305 module B = LowStar.Buffer #set-options "--max_fuel 0 --max_ifuel 0" let key0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy; 0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let key0_len: (x:UInt32.t { UInt32.v x = B.length key0 }) = 32ul let nonce0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) = [@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; ] in assert_norm (List.Tot.length l = 12); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let nonce0_len: (x:UInt32.t { UInt32.v x = B.length nonce0 }) = 12ul let aad0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) = [@inline_let] let l = [ 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x4euy; 0x91uy; ] in assert_norm (List.Tot.length l = 12); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let aad0_len: (x:UInt32.t { UInt32.v x = B.length aad0 }) = 12ul let input0: (b: B.buffer UInt8.t { B.length b = 265 /\ B.recallable b /\ B.disjoint b aad0 }) = B.recall aad0;[@inline_let] let l = [ 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x72uy; 0x65uy; 0x20uy; 0x64uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x76uy; 0x61uy; 0x6cuy; 0x69uy; 0x64uy; 0x20uy; 0x66uy; 0x6fuy; 0x72uy; 0x20uy; 0x61uy; 0x20uy; 0x6duy; 0x61uy; 0x78uy; 0x69uy; 0x6duy; 0x75uy; 0x6duy; 0x20uy; 0x6fuy; 0x66uy; 0x20uy; 0x73uy; 0x69uy; 0x78uy; 0x20uy; 0x6duy; 0x6fuy; 0x6euy; 0x74uy; 0x68uy; 0x73uy; 0x20uy; 0x61uy; 0x6euy; 0x64uy; 0x20uy; 0x6duy; 0x61uy; 0x79uy; 0x20uy; 0x62uy; 0x65uy; 0x20uy; 0x75uy; 0x70uy; 0x64uy; 0x61uy; 0x74uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x72uy; 0x65uy; 0x70uy; 0x6cuy; 0x61uy; 0x63uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x6fuy; 0x62uy; 0x73uy; 0x6fuy; 0x6cuy; 0x65uy; 0x74uy; 0x65uy; 0x64uy; 0x20uy; 0x62uy; 0x79uy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x74uy; 0x20uy; 0x61uy; 0x6euy; 0x79uy; 0x20uy; 0x74uy; 0x69uy; 0x6duy; 0x65uy; 0x2euy; 0x20uy; 0x49uy; 0x74uy; 0x20uy; 0x69uy; 0x73uy; 0x20uy; 0x69uy; 0x6euy; 0x61uy; 0x70uy; 0x70uy; 0x72uy; 0x6fuy; 0x70uy; 0x72uy; 0x69uy; 0x61uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x75uy; 0x73uy; 0x65uy; 0x20uy; 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x72uy; 0x65uy; 0x66uy; 0x65uy; 0x72uy; 0x65uy; 0x6euy; 0x63uy; 0x65uy; 0x20uy; 0x6duy; 0x61uy; 0x74uy; 0x65uy; 0x72uy; 0x69uy; 0x61uy; 0x6cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x63uy; 0x69uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x68uy; 0x65uy; 0x6duy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x74uy; 0x68uy; 0x61uy; 0x6euy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x2fuy; 0xe2uy; 0x80uy; 0x9cuy; 0x77uy; 0x6fuy; 0x72uy; 0x6buy; 0x20uy; 0x69uy; 0x6euy; 0x20uy; 0x70uy; 0x72uy; 0x6fuy; 0x67uy; 0x72uy; 0x65uy; 0x73uy; 0x73uy; 0x2euy; 0x2fuy; 0xe2uy; 0x80uy; 0x9duy; ] in assert_norm (List.Tot.length l = 265); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let input0_len: (x:UInt32.t { UInt32.v x = B.length input0 }) = 265ul let output0: (b: B.buffer UInt8.t { B.length b = 281 /\ B.recallable b }) = [@inline_let] let l = [ 0x64uy; 0xa0uy; 0x86uy; 0x15uy; 0x75uy; 0x86uy; 0x1auy; 0xf4uy; 0x60uy; 0xf0uy; 0x62uy; 0xc7uy; 0x9buy; 0xe6uy; 0x43uy; 0xbduy; 0x5euy; 0x80uy; 0x5cuy; 0xfduy; 0x34uy; 0x5cuy; 0xf3uy; 0x89uy; 0xf1uy; 0x08uy; 0x67uy; 0x0auy; 0xc7uy; 0x6cuy; 0x8cuy; 0xb2uy; 0x4cuy; 0x6cuy; 0xfcuy; 0x18uy; 0x75uy; 0x5duy; 0x43uy; 0xeeuy; 0xa0uy; 0x9euy; 0xe9uy; 0x4euy; 0x38uy; 0x2duy; 0x26uy; 0xb0uy; 0xbduy; 0xb7uy; 0xb7uy; 0x3cuy; 0x32uy; 0x1buy; 0x01uy; 0x00uy; 0xd4uy; 0xf0uy; 0x3buy; 0x7fuy; 0x35uy; 0x58uy; 0x94uy; 0xcfuy; 0x33uy; 0x2fuy; 0x83uy; 0x0euy; 0x71uy; 0x0buy; 0x97uy; 0xceuy; 0x98uy; 0xc8uy; 0xa8uy; 0x4auy; 0xbduy; 0x0buy; 0x94uy; 0x81uy; 0x14uy; 0xaduy; 0x17uy; 0x6euy; 0x00uy; 0x8duy; 0x33uy; 0xbduy; 0x60uy; 0xf9uy; 0x82uy; 0xb1uy; 0xffuy; 0x37uy; 0xc8uy; 0x55uy; 0x97uy; 0x97uy; 0xa0uy; 0x6euy; 0xf4uy; 0xf0uy; 0xefuy; 0x61uy; 0xc1uy; 0x86uy; 0x32uy; 0x4euy; 0x2buy; 0x35uy; 0x06uy; 0x38uy; 0x36uy; 0x06uy; 0x90uy; 0x7buy; 0x6auy; 0x7cuy; 0x02uy; 0xb0uy; 0xf9uy; 0xf6uy; 0x15uy; 0x7buy; 0x53uy; 0xc8uy; 0x67uy; 0xe4uy; 0xb9uy; 0x16uy; 0x6cuy; 0x76uy; 0x7buy; 0x80uy; 0x4duy; 0x46uy; 0xa5uy; 0x9buy; 0x52uy; 0x16uy; 0xcduy; 0xe7uy; 0xa4uy; 0xe9uy; 0x90uy; 0x40uy; 0xc5uy; 0xa4uy; 0x04uy; 0x33uy; 0x22uy; 0x5euy; 0xe2uy; 0x82uy; 0xa1uy; 0xb0uy; 0xa0uy; 0x6cuy; 0x52uy; 0x3euy; 0xafuy; 0x45uy; 0x34uy; 0xd7uy; 0xf8uy; 0x3fuy; 0xa1uy; 0x15uy; 0x5buy; 0x00uy; 0x47uy; 0x71uy; 0x8cuy; 0xbcuy; 0x54uy; 0x6auy; 0x0duy; 0x07uy; 0x2buy; 0x04uy; 0xb3uy; 0x56uy; 0x4euy; 0xeauy; 0x1buy; 0x42uy; 0x22uy; 0x73uy; 0xf5uy; 0x48uy; 0x27uy; 0x1auy; 0x0buy; 0xb2uy; 0x31uy; 0x60uy; 0x53uy; 0xfauy; 0x76uy; 0x99uy; 0x19uy; 0x55uy; 0xebuy; 0xd6uy; 0x31uy; 0x59uy; 0x43uy; 0x4euy; 0xceuy; 0xbbuy; 0x4euy; 0x46uy; 0x6duy; 0xaeuy; 0x5auy; 0x10uy; 0x73uy; 0xa6uy; 0x72uy; 0x76uy; 0x27uy; 0x09uy; 0x7auy; 0x10uy; 0x49uy; 0xe6uy; 0x17uy; 0xd9uy; 0x1duy; 0x36uy; 0x10uy; 0x94uy; 0xfauy; 0x68uy; 0xf0uy; 0xffuy; 0x77uy; 0x98uy; 0x71uy; 0x30uy; 0x30uy; 0x5buy; 0xeauy; 0xbauy; 0x2euy; 0xdauy; 0x04uy; 0xdfuy; 0x99uy; 0x7buy; 0x71uy; 0x4duy; 0x6cuy; 0x6fuy; 0x2cuy; 0x29uy; 0xa6uy; 0xaduy; 0x5cuy; 0xb4uy; 0x02uy; 0x2buy; 0x02uy; 0x70uy; 0x9buy; 0xeeuy; 0xaduy; 0x9duy; 0x67uy; 0x89uy; 0x0cuy; 0xbbuy; 0x22uy; 0x39uy; 0x23uy; 0x36uy; 0xfeuy; 0xa1uy; 0x85uy; 0x1fuy; 0x38uy; ] in assert_norm (List.Tot.length l = 281); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let output0_len: (x:UInt32.t { UInt32.v x = B.length output0 }) = 281ul let key1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x4cuy; 0xf5uy; 0x96uy; 0x83uy; 0x38uy; 0xe6uy; 0xaeuy; 0x7fuy; 0x2duy; 0x29uy; 0x25uy; 0x76uy; 0xd5uy; 0x75uy; 0x27uy; 0x86uy; 0x91uy; 0x9auy; 0x27uy; 0x7auy; 0xfbuy; 0x46uy; 0xc5uy; 0xefuy; 0x94uy; 0x81uy; 0x79uy; 0x57uy; 0x14uy; 0x59uy; 0x40uy; 0x68uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let key1_len: (x:UInt32.t { UInt32.v x = B.length key1 }) = 32ul let nonce1: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) = [@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0xcauy; 0xbfuy; 0x33uy; 0x71uy; 0x32uy; 0x45uy; 0x77uy; 0x8euy; ] in assert_norm (List.Tot.length l = 12); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let nonce1_len: (x:UInt32.t { UInt32.v x = B.length nonce1 }) = 12ul let aad1: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b }) = [@inline_let] let l = [ ] in assert_norm (List.Tot.length l = 0); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let aad1_len: (x:UInt32.t { UInt32.v x = B.length aad1 }) = 0ul let input1: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b /\ B.disjoint b aad1 }) = B.recall aad1;[@inline_let] let l = [ ] in assert_norm (List.Tot.length l = 0); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let input1_len: (x:UInt32.t { UInt32.v x = B.length input1 }) = 0ul let output1: (b: B.buffer UInt8.t { B.length b = 16 /\ B.recallable b }) = [@inline_let] let l = [ 0xeauy; 0xe0uy; 0x1euy; 0x9euy; 0x2cuy; 0x91uy; 0xaauy; 0xe1uy; 0xdbuy; 0x5duy; 0x99uy; 0x3fuy; 0x8auy; 0xf7uy; 0x69uy; 0x92uy; ] in assert_norm (List.Tot.length l = 16); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let output1_len: (x:UInt32.t { UInt32.v x = B.length output1 }) = 16ul let key2: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x2duy; 0xb0uy; 0x5duy; 0x40uy; 0xc8uy; 0xeduy; 0x44uy; 0x88uy; 0x34uy; 0xd1uy; 0x13uy; 0xafuy; 0x57uy; 0xa1uy; 0xebuy; 0x3auy; 0x2auy; 0x80uy; 0x51uy; 0x36uy; 0xecuy; 0x5buy; 0xbcuy; 0x08uy; 0x93uy; 0x84uy; 0x21uy; 0xb5uy; 0x13uy; 0x88uy; 0x3cuy; 0x0duy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l
false
false
Test.Vectors.Chacha20Poly1305.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val key2_len:(x: UInt32.t{UInt32.v x = B.length key2})
[]
Test.Vectors.Chacha20Poly1305.key2_len
{ "file_name": "providers/test/vectors/Test.Vectors.Chacha20Poly1305.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: FStar.UInt32.t {FStar.UInt32.v x = LowStar.Monotonic.Buffer.length Test.Vectors.Chacha20Poly1305.key2}
{ "end_col": 6, "end_line": 93, "start_col": 2, "start_line": 93 }
Prims.Tot
val aad3:(b: B.buffer UInt8.t {B.length b = 8 /\ B.recallable b})
[ { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Test.Vectors", "short_module": null }, { "abbrev": false, "full_module": "Test.Vectors", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aad3: (b: B.buffer UInt8.t { B.length b = 8 /\ B.recallable b }) = [@inline_let] let l = [ 0x6auy; 0xe2uy; 0xaduy; 0x3fuy; 0x88uy; 0x39uy; 0x5auy; 0x40uy; ] in assert_norm (List.Tot.length l = 8); B.gcmalloc_of_list HyperStack.root l
val aad3:(b: B.buffer UInt8.t {B.length b = 8 /\ B.recallable b}) let aad3:(b: B.buffer UInt8.t {B.length b = 8 /\ B.recallable b}) =
false
null
false
[@@ inline_let ]let l = [0x6auy; 0xe2uy; 0xaduy; 0x3fuy; 0x88uy; 0x39uy; 0x5auy; 0x40uy] in assert_norm (List.Tot.length l = 8); B.gcmalloc_of_list HyperStack.root l
{ "checked_file": "Test.Vectors.Chacha20Poly1305.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Test.Vectors.Chacha20Poly1305.fst" }
[ "total" ]
[ "LowStar.Buffer.gcmalloc_of_list", "FStar.UInt8.t", "FStar.Monotonic.HyperHeap.root", "LowStar.Monotonic.Buffer.mbuffer", "LowStar.Buffer.trivial_preorder", "Prims.l_and", "Prims.eq2", "Prims.nat", "LowStar.Monotonic.Buffer.length", "FStar.Pervasives.normalize_term", "FStar.List.Tot.Base.length", "Prims.b2t", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "FStar.Monotonic.HyperHeap.rid", "LowStar.Monotonic.Buffer.frameOf", "LowStar.Monotonic.Buffer.recallable", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.op_Equality", "Prims.int", "LowStar.Buffer.buffer", "Prims.list", "Prims.Cons", "FStar.UInt8.__uint_to_t", "Prims.Nil" ]
[]
module Test.Vectors.Chacha20Poly1305 module B = LowStar.Buffer #set-options "--max_fuel 0 --max_ifuel 0" let key0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy; 0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let key0_len: (x:UInt32.t { UInt32.v x = B.length key0 }) = 32ul let nonce0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) = [@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; ] in assert_norm (List.Tot.length l = 12); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let nonce0_len: (x:UInt32.t { UInt32.v x = B.length nonce0 }) = 12ul let aad0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) = [@inline_let] let l = [ 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x4euy; 0x91uy; ] in assert_norm (List.Tot.length l = 12); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let aad0_len: (x:UInt32.t { UInt32.v x = B.length aad0 }) = 12ul let input0: (b: B.buffer UInt8.t { B.length b = 265 /\ B.recallable b /\ B.disjoint b aad0 }) = B.recall aad0;[@inline_let] let l = [ 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x72uy; 0x65uy; 0x20uy; 0x64uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x76uy; 0x61uy; 0x6cuy; 0x69uy; 0x64uy; 0x20uy; 0x66uy; 0x6fuy; 0x72uy; 0x20uy; 0x61uy; 0x20uy; 0x6duy; 0x61uy; 0x78uy; 0x69uy; 0x6duy; 0x75uy; 0x6duy; 0x20uy; 0x6fuy; 0x66uy; 0x20uy; 0x73uy; 0x69uy; 0x78uy; 0x20uy; 0x6duy; 0x6fuy; 0x6euy; 0x74uy; 0x68uy; 0x73uy; 0x20uy; 0x61uy; 0x6euy; 0x64uy; 0x20uy; 0x6duy; 0x61uy; 0x79uy; 0x20uy; 0x62uy; 0x65uy; 0x20uy; 0x75uy; 0x70uy; 0x64uy; 0x61uy; 0x74uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x72uy; 0x65uy; 0x70uy; 0x6cuy; 0x61uy; 0x63uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x6fuy; 0x62uy; 0x73uy; 0x6fuy; 0x6cuy; 0x65uy; 0x74uy; 0x65uy; 0x64uy; 0x20uy; 0x62uy; 0x79uy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x74uy; 0x20uy; 0x61uy; 0x6euy; 0x79uy; 0x20uy; 0x74uy; 0x69uy; 0x6duy; 0x65uy; 0x2euy; 0x20uy; 0x49uy; 0x74uy; 0x20uy; 0x69uy; 0x73uy; 0x20uy; 0x69uy; 0x6euy; 0x61uy; 0x70uy; 0x70uy; 0x72uy; 0x6fuy; 0x70uy; 0x72uy; 0x69uy; 0x61uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x75uy; 0x73uy; 0x65uy; 0x20uy; 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x72uy; 0x65uy; 0x66uy; 0x65uy; 0x72uy; 0x65uy; 0x6euy; 0x63uy; 0x65uy; 0x20uy; 0x6duy; 0x61uy; 0x74uy; 0x65uy; 0x72uy; 0x69uy; 0x61uy; 0x6cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x63uy; 0x69uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x68uy; 0x65uy; 0x6duy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x74uy; 0x68uy; 0x61uy; 0x6euy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x2fuy; 0xe2uy; 0x80uy; 0x9cuy; 0x77uy; 0x6fuy; 0x72uy; 0x6buy; 0x20uy; 0x69uy; 0x6euy; 0x20uy; 0x70uy; 0x72uy; 0x6fuy; 0x67uy; 0x72uy; 0x65uy; 0x73uy; 0x73uy; 0x2euy; 0x2fuy; 0xe2uy; 0x80uy; 0x9duy; ] in assert_norm (List.Tot.length l = 265); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let input0_len: (x:UInt32.t { UInt32.v x = B.length input0 }) = 265ul let output0: (b: B.buffer UInt8.t { B.length b = 281 /\ B.recallable b }) = [@inline_let] let l = [ 0x64uy; 0xa0uy; 0x86uy; 0x15uy; 0x75uy; 0x86uy; 0x1auy; 0xf4uy; 0x60uy; 0xf0uy; 0x62uy; 0xc7uy; 0x9buy; 0xe6uy; 0x43uy; 0xbduy; 0x5euy; 0x80uy; 0x5cuy; 0xfduy; 0x34uy; 0x5cuy; 0xf3uy; 0x89uy; 0xf1uy; 0x08uy; 0x67uy; 0x0auy; 0xc7uy; 0x6cuy; 0x8cuy; 0xb2uy; 0x4cuy; 0x6cuy; 0xfcuy; 0x18uy; 0x75uy; 0x5duy; 0x43uy; 0xeeuy; 0xa0uy; 0x9euy; 0xe9uy; 0x4euy; 0x38uy; 0x2duy; 0x26uy; 0xb0uy; 0xbduy; 0xb7uy; 0xb7uy; 0x3cuy; 0x32uy; 0x1buy; 0x01uy; 0x00uy; 0xd4uy; 0xf0uy; 0x3buy; 0x7fuy; 0x35uy; 0x58uy; 0x94uy; 0xcfuy; 0x33uy; 0x2fuy; 0x83uy; 0x0euy; 0x71uy; 0x0buy; 0x97uy; 0xceuy; 0x98uy; 0xc8uy; 0xa8uy; 0x4auy; 0xbduy; 0x0buy; 0x94uy; 0x81uy; 0x14uy; 0xaduy; 0x17uy; 0x6euy; 0x00uy; 0x8duy; 0x33uy; 0xbduy; 0x60uy; 0xf9uy; 0x82uy; 0xb1uy; 0xffuy; 0x37uy; 0xc8uy; 0x55uy; 0x97uy; 0x97uy; 0xa0uy; 0x6euy; 0xf4uy; 0xf0uy; 0xefuy; 0x61uy; 0xc1uy; 0x86uy; 0x32uy; 0x4euy; 0x2buy; 0x35uy; 0x06uy; 0x38uy; 0x36uy; 0x06uy; 0x90uy; 0x7buy; 0x6auy; 0x7cuy; 0x02uy; 0xb0uy; 0xf9uy; 0xf6uy; 0x15uy; 0x7buy; 0x53uy; 0xc8uy; 0x67uy; 0xe4uy; 0xb9uy; 0x16uy; 0x6cuy; 0x76uy; 0x7buy; 0x80uy; 0x4duy; 0x46uy; 0xa5uy; 0x9buy; 0x52uy; 0x16uy; 0xcduy; 0xe7uy; 0xa4uy; 0xe9uy; 0x90uy; 0x40uy; 0xc5uy; 0xa4uy; 0x04uy; 0x33uy; 0x22uy; 0x5euy; 0xe2uy; 0x82uy; 0xa1uy; 0xb0uy; 0xa0uy; 0x6cuy; 0x52uy; 0x3euy; 0xafuy; 0x45uy; 0x34uy; 0xd7uy; 0xf8uy; 0x3fuy; 0xa1uy; 0x15uy; 0x5buy; 0x00uy; 0x47uy; 0x71uy; 0x8cuy; 0xbcuy; 0x54uy; 0x6auy; 0x0duy; 0x07uy; 0x2buy; 0x04uy; 0xb3uy; 0x56uy; 0x4euy; 0xeauy; 0x1buy; 0x42uy; 0x22uy; 0x73uy; 0xf5uy; 0x48uy; 0x27uy; 0x1auy; 0x0buy; 0xb2uy; 0x31uy; 0x60uy; 0x53uy; 0xfauy; 0x76uy; 0x99uy; 0x19uy; 0x55uy; 0xebuy; 0xd6uy; 0x31uy; 0x59uy; 0x43uy; 0x4euy; 0xceuy; 0xbbuy; 0x4euy; 0x46uy; 0x6duy; 0xaeuy; 0x5auy; 0x10uy; 0x73uy; 0xa6uy; 0x72uy; 0x76uy; 0x27uy; 0x09uy; 0x7auy; 0x10uy; 0x49uy; 0xe6uy; 0x17uy; 0xd9uy; 0x1duy; 0x36uy; 0x10uy; 0x94uy; 0xfauy; 0x68uy; 0xf0uy; 0xffuy; 0x77uy; 0x98uy; 0x71uy; 0x30uy; 0x30uy; 0x5buy; 0xeauy; 0xbauy; 0x2euy; 0xdauy; 0x04uy; 0xdfuy; 0x99uy; 0x7buy; 0x71uy; 0x4duy; 0x6cuy; 0x6fuy; 0x2cuy; 0x29uy; 0xa6uy; 0xaduy; 0x5cuy; 0xb4uy; 0x02uy; 0x2buy; 0x02uy; 0x70uy; 0x9buy; 0xeeuy; 0xaduy; 0x9duy; 0x67uy; 0x89uy; 0x0cuy; 0xbbuy; 0x22uy; 0x39uy; 0x23uy; 0x36uy; 0xfeuy; 0xa1uy; 0x85uy; 0x1fuy; 0x38uy; ] in assert_norm (List.Tot.length l = 281); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let output0_len: (x:UInt32.t { UInt32.v x = B.length output0 }) = 281ul let key1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x4cuy; 0xf5uy; 0x96uy; 0x83uy; 0x38uy; 0xe6uy; 0xaeuy; 0x7fuy; 0x2duy; 0x29uy; 0x25uy; 0x76uy; 0xd5uy; 0x75uy; 0x27uy; 0x86uy; 0x91uy; 0x9auy; 0x27uy; 0x7auy; 0xfbuy; 0x46uy; 0xc5uy; 0xefuy; 0x94uy; 0x81uy; 0x79uy; 0x57uy; 0x14uy; 0x59uy; 0x40uy; 0x68uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let key1_len: (x:UInt32.t { UInt32.v x = B.length key1 }) = 32ul let nonce1: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) = [@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0xcauy; 0xbfuy; 0x33uy; 0x71uy; 0x32uy; 0x45uy; 0x77uy; 0x8euy; ] in assert_norm (List.Tot.length l = 12); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let nonce1_len: (x:UInt32.t { UInt32.v x = B.length nonce1 }) = 12ul let aad1: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b }) = [@inline_let] let l = [ ] in assert_norm (List.Tot.length l = 0); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let aad1_len: (x:UInt32.t { UInt32.v x = B.length aad1 }) = 0ul let input1: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b /\ B.disjoint b aad1 }) = B.recall aad1;[@inline_let] let l = [ ] in assert_norm (List.Tot.length l = 0); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let input1_len: (x:UInt32.t { UInt32.v x = B.length input1 }) = 0ul let output1: (b: B.buffer UInt8.t { B.length b = 16 /\ B.recallable b }) = [@inline_let] let l = [ 0xeauy; 0xe0uy; 0x1euy; 0x9euy; 0x2cuy; 0x91uy; 0xaauy; 0xe1uy; 0xdbuy; 0x5duy; 0x99uy; 0x3fuy; 0x8auy; 0xf7uy; 0x69uy; 0x92uy; ] in assert_norm (List.Tot.length l = 16); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let output1_len: (x:UInt32.t { UInt32.v x = B.length output1 }) = 16ul let key2: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x2duy; 0xb0uy; 0x5duy; 0x40uy; 0xc8uy; 0xeduy; 0x44uy; 0x88uy; 0x34uy; 0xd1uy; 0x13uy; 0xafuy; 0x57uy; 0xa1uy; 0xebuy; 0x3auy; 0x2auy; 0x80uy; 0x51uy; 0x36uy; 0xecuy; 0x5buy; 0xbcuy; 0x08uy; 0x93uy; 0x84uy; 0x21uy; 0xb5uy; 0x13uy; 0x88uy; 0x3cuy; 0x0duy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let key2_len: (x:UInt32.t { UInt32.v x = B.length key2 }) = 32ul let nonce2: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) = [@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x3duy; 0x86uy; 0xb5uy; 0x6buy; 0xc8uy; 0xa3uy; 0x1fuy; 0x1duy; ] in assert_norm (List.Tot.length l = 12); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let nonce2_len: (x:UInt32.t { UInt32.v x = B.length nonce2 }) = 12ul let aad2: (b: B.buffer UInt8.t { B.length b = 8 /\ B.recallable b }) = [@inline_let] let l = [ 0x33uy; 0x10uy; 0x41uy; 0x12uy; 0x1fuy; 0xf3uy; 0xd2uy; 0x6buy; ] in assert_norm (List.Tot.length l = 8); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let aad2_len: (x:UInt32.t { UInt32.v x = B.length aad2 }) = 8ul let input2: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b /\ B.disjoint b aad2 }) = B.recall aad2;[@inline_let] let l = [ ] in assert_norm (List.Tot.length l = 0); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let input2_len: (x:UInt32.t { UInt32.v x = B.length input2 }) = 0ul let output2: (b: B.buffer UInt8.t { B.length b = 16 /\ B.recallable b }) = [@inline_let] let l = [ 0xdduy; 0x6buy; 0x3buy; 0x82uy; 0xceuy; 0x5auy; 0xbduy; 0xd6uy; 0xa9uy; 0x35uy; 0x83uy; 0xd8uy; 0x8cuy; 0x3duy; 0x85uy; 0x77uy; ] in assert_norm (List.Tot.length l = 16); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let output2_len: (x:UInt32.t { UInt32.v x = B.length output2 }) = 16ul let key3: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x4buy; 0x28uy; 0x4buy; 0xa3uy; 0x7buy; 0xbeuy; 0xe9uy; 0xf8uy; 0x31uy; 0x80uy; 0x82uy; 0xd7uy; 0xd8uy; 0xe8uy; 0xb5uy; 0xa1uy; 0xe2uy; 0x18uy; 0x18uy; 0x8auy; 0x9cuy; 0xfauy; 0xa3uy; 0x3duy; 0x25uy; 0x71uy; 0x3euy; 0x40uy; 0xbcuy; 0x54uy; 0x7auy; 0x3euy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let key3_len: (x:UInt32.t { UInt32.v x = B.length key3 }) = 32ul let nonce3: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) = [@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0xd2uy; 0x32uy; 0x1fuy; 0x29uy; 0x28uy; 0xc6uy; 0xc4uy; 0xc4uy; ] in assert_norm (List.Tot.length l = 12); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let nonce3_len: (x:UInt32.t { UInt32.v x = B.length nonce3 }) = 12ul
false
false
Test.Vectors.Chacha20Poly1305.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aad3:(b: B.buffer UInt8.t {B.length b = 8 /\ B.recallable b})
[]
Test.Vectors.Chacha20Poly1305.aad3
{ "file_name": "providers/test/vectors/Test.Vectors.Chacha20Poly1305.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: LowStar.Buffer.buffer FStar.UInt8.t {LowStar.Monotonic.Buffer.length b = 8 /\ LowStar.Monotonic.Buffer.recallable b}
{ "end_col": 38, "end_line": 146, "start_col": 2, "start_line": 144 }
Prims.Tot
val nonce3_len:(x: UInt32.t{UInt32.v x = B.length nonce3})
[ { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Test.Vectors", "short_module": null }, { "abbrev": false, "full_module": "Test.Vectors", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let nonce3_len: (x:UInt32.t { UInt32.v x = B.length nonce3 }) = 12ul
val nonce3_len:(x: UInt32.t{UInt32.v x = B.length nonce3}) let nonce3_len:(x: UInt32.t{UInt32.v x = B.length nonce3}) =
false
null
false
12ul
{ "checked_file": "Test.Vectors.Chacha20Poly1305.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Test.Vectors.Chacha20Poly1305.fst" }
[ "total" ]
[ "FStar.UInt32.__uint_to_t" ]
[]
module Test.Vectors.Chacha20Poly1305 module B = LowStar.Buffer #set-options "--max_fuel 0 --max_ifuel 0" let key0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy; 0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let key0_len: (x:UInt32.t { UInt32.v x = B.length key0 }) = 32ul let nonce0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) = [@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; ] in assert_norm (List.Tot.length l = 12); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let nonce0_len: (x:UInt32.t { UInt32.v x = B.length nonce0 }) = 12ul let aad0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) = [@inline_let] let l = [ 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x4euy; 0x91uy; ] in assert_norm (List.Tot.length l = 12); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let aad0_len: (x:UInt32.t { UInt32.v x = B.length aad0 }) = 12ul let input0: (b: B.buffer UInt8.t { B.length b = 265 /\ B.recallable b /\ B.disjoint b aad0 }) = B.recall aad0;[@inline_let] let l = [ 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x72uy; 0x65uy; 0x20uy; 0x64uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x76uy; 0x61uy; 0x6cuy; 0x69uy; 0x64uy; 0x20uy; 0x66uy; 0x6fuy; 0x72uy; 0x20uy; 0x61uy; 0x20uy; 0x6duy; 0x61uy; 0x78uy; 0x69uy; 0x6duy; 0x75uy; 0x6duy; 0x20uy; 0x6fuy; 0x66uy; 0x20uy; 0x73uy; 0x69uy; 0x78uy; 0x20uy; 0x6duy; 0x6fuy; 0x6euy; 0x74uy; 0x68uy; 0x73uy; 0x20uy; 0x61uy; 0x6euy; 0x64uy; 0x20uy; 0x6duy; 0x61uy; 0x79uy; 0x20uy; 0x62uy; 0x65uy; 0x20uy; 0x75uy; 0x70uy; 0x64uy; 0x61uy; 0x74uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x72uy; 0x65uy; 0x70uy; 0x6cuy; 0x61uy; 0x63uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x6fuy; 0x62uy; 0x73uy; 0x6fuy; 0x6cuy; 0x65uy; 0x74uy; 0x65uy; 0x64uy; 0x20uy; 0x62uy; 0x79uy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x74uy; 0x20uy; 0x61uy; 0x6euy; 0x79uy; 0x20uy; 0x74uy; 0x69uy; 0x6duy; 0x65uy; 0x2euy; 0x20uy; 0x49uy; 0x74uy; 0x20uy; 0x69uy; 0x73uy; 0x20uy; 0x69uy; 0x6euy; 0x61uy; 0x70uy; 0x70uy; 0x72uy; 0x6fuy; 0x70uy; 0x72uy; 0x69uy; 0x61uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x75uy; 0x73uy; 0x65uy; 0x20uy; 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x72uy; 0x65uy; 0x66uy; 0x65uy; 0x72uy; 0x65uy; 0x6euy; 0x63uy; 0x65uy; 0x20uy; 0x6duy; 0x61uy; 0x74uy; 0x65uy; 0x72uy; 0x69uy; 0x61uy; 0x6cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x63uy; 0x69uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x68uy; 0x65uy; 0x6duy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x74uy; 0x68uy; 0x61uy; 0x6euy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x2fuy; 0xe2uy; 0x80uy; 0x9cuy; 0x77uy; 0x6fuy; 0x72uy; 0x6buy; 0x20uy; 0x69uy; 0x6euy; 0x20uy; 0x70uy; 0x72uy; 0x6fuy; 0x67uy; 0x72uy; 0x65uy; 0x73uy; 0x73uy; 0x2euy; 0x2fuy; 0xe2uy; 0x80uy; 0x9duy; ] in assert_norm (List.Tot.length l = 265); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let input0_len: (x:UInt32.t { UInt32.v x = B.length input0 }) = 265ul let output0: (b: B.buffer UInt8.t { B.length b = 281 /\ B.recallable b }) = [@inline_let] let l = [ 0x64uy; 0xa0uy; 0x86uy; 0x15uy; 0x75uy; 0x86uy; 0x1auy; 0xf4uy; 0x60uy; 0xf0uy; 0x62uy; 0xc7uy; 0x9buy; 0xe6uy; 0x43uy; 0xbduy; 0x5euy; 0x80uy; 0x5cuy; 0xfduy; 0x34uy; 0x5cuy; 0xf3uy; 0x89uy; 0xf1uy; 0x08uy; 0x67uy; 0x0auy; 0xc7uy; 0x6cuy; 0x8cuy; 0xb2uy; 0x4cuy; 0x6cuy; 0xfcuy; 0x18uy; 0x75uy; 0x5duy; 0x43uy; 0xeeuy; 0xa0uy; 0x9euy; 0xe9uy; 0x4euy; 0x38uy; 0x2duy; 0x26uy; 0xb0uy; 0xbduy; 0xb7uy; 0xb7uy; 0x3cuy; 0x32uy; 0x1buy; 0x01uy; 0x00uy; 0xd4uy; 0xf0uy; 0x3buy; 0x7fuy; 0x35uy; 0x58uy; 0x94uy; 0xcfuy; 0x33uy; 0x2fuy; 0x83uy; 0x0euy; 0x71uy; 0x0buy; 0x97uy; 0xceuy; 0x98uy; 0xc8uy; 0xa8uy; 0x4auy; 0xbduy; 0x0buy; 0x94uy; 0x81uy; 0x14uy; 0xaduy; 0x17uy; 0x6euy; 0x00uy; 0x8duy; 0x33uy; 0xbduy; 0x60uy; 0xf9uy; 0x82uy; 0xb1uy; 0xffuy; 0x37uy; 0xc8uy; 0x55uy; 0x97uy; 0x97uy; 0xa0uy; 0x6euy; 0xf4uy; 0xf0uy; 0xefuy; 0x61uy; 0xc1uy; 0x86uy; 0x32uy; 0x4euy; 0x2buy; 0x35uy; 0x06uy; 0x38uy; 0x36uy; 0x06uy; 0x90uy; 0x7buy; 0x6auy; 0x7cuy; 0x02uy; 0xb0uy; 0xf9uy; 0xf6uy; 0x15uy; 0x7buy; 0x53uy; 0xc8uy; 0x67uy; 0xe4uy; 0xb9uy; 0x16uy; 0x6cuy; 0x76uy; 0x7buy; 0x80uy; 0x4duy; 0x46uy; 0xa5uy; 0x9buy; 0x52uy; 0x16uy; 0xcduy; 0xe7uy; 0xa4uy; 0xe9uy; 0x90uy; 0x40uy; 0xc5uy; 0xa4uy; 0x04uy; 0x33uy; 0x22uy; 0x5euy; 0xe2uy; 0x82uy; 0xa1uy; 0xb0uy; 0xa0uy; 0x6cuy; 0x52uy; 0x3euy; 0xafuy; 0x45uy; 0x34uy; 0xd7uy; 0xf8uy; 0x3fuy; 0xa1uy; 0x15uy; 0x5buy; 0x00uy; 0x47uy; 0x71uy; 0x8cuy; 0xbcuy; 0x54uy; 0x6auy; 0x0duy; 0x07uy; 0x2buy; 0x04uy; 0xb3uy; 0x56uy; 0x4euy; 0xeauy; 0x1buy; 0x42uy; 0x22uy; 0x73uy; 0xf5uy; 0x48uy; 0x27uy; 0x1auy; 0x0buy; 0xb2uy; 0x31uy; 0x60uy; 0x53uy; 0xfauy; 0x76uy; 0x99uy; 0x19uy; 0x55uy; 0xebuy; 0xd6uy; 0x31uy; 0x59uy; 0x43uy; 0x4euy; 0xceuy; 0xbbuy; 0x4euy; 0x46uy; 0x6duy; 0xaeuy; 0x5auy; 0x10uy; 0x73uy; 0xa6uy; 0x72uy; 0x76uy; 0x27uy; 0x09uy; 0x7auy; 0x10uy; 0x49uy; 0xe6uy; 0x17uy; 0xd9uy; 0x1duy; 0x36uy; 0x10uy; 0x94uy; 0xfauy; 0x68uy; 0xf0uy; 0xffuy; 0x77uy; 0x98uy; 0x71uy; 0x30uy; 0x30uy; 0x5buy; 0xeauy; 0xbauy; 0x2euy; 0xdauy; 0x04uy; 0xdfuy; 0x99uy; 0x7buy; 0x71uy; 0x4duy; 0x6cuy; 0x6fuy; 0x2cuy; 0x29uy; 0xa6uy; 0xaduy; 0x5cuy; 0xb4uy; 0x02uy; 0x2buy; 0x02uy; 0x70uy; 0x9buy; 0xeeuy; 0xaduy; 0x9duy; 0x67uy; 0x89uy; 0x0cuy; 0xbbuy; 0x22uy; 0x39uy; 0x23uy; 0x36uy; 0xfeuy; 0xa1uy; 0x85uy; 0x1fuy; 0x38uy; ] in assert_norm (List.Tot.length l = 281); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let output0_len: (x:UInt32.t { UInt32.v x = B.length output0 }) = 281ul let key1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x4cuy; 0xf5uy; 0x96uy; 0x83uy; 0x38uy; 0xe6uy; 0xaeuy; 0x7fuy; 0x2duy; 0x29uy; 0x25uy; 0x76uy; 0xd5uy; 0x75uy; 0x27uy; 0x86uy; 0x91uy; 0x9auy; 0x27uy; 0x7auy; 0xfbuy; 0x46uy; 0xc5uy; 0xefuy; 0x94uy; 0x81uy; 0x79uy; 0x57uy; 0x14uy; 0x59uy; 0x40uy; 0x68uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let key1_len: (x:UInt32.t { UInt32.v x = B.length key1 }) = 32ul let nonce1: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) = [@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0xcauy; 0xbfuy; 0x33uy; 0x71uy; 0x32uy; 0x45uy; 0x77uy; 0x8euy; ] in assert_norm (List.Tot.length l = 12); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let nonce1_len: (x:UInt32.t { UInt32.v x = B.length nonce1 }) = 12ul let aad1: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b }) = [@inline_let] let l = [ ] in assert_norm (List.Tot.length l = 0); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let aad1_len: (x:UInt32.t { UInt32.v x = B.length aad1 }) = 0ul let input1: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b /\ B.disjoint b aad1 }) = B.recall aad1;[@inline_let] let l = [ ] in assert_norm (List.Tot.length l = 0); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let input1_len: (x:UInt32.t { UInt32.v x = B.length input1 }) = 0ul let output1: (b: B.buffer UInt8.t { B.length b = 16 /\ B.recallable b }) = [@inline_let] let l = [ 0xeauy; 0xe0uy; 0x1euy; 0x9euy; 0x2cuy; 0x91uy; 0xaauy; 0xe1uy; 0xdbuy; 0x5duy; 0x99uy; 0x3fuy; 0x8auy; 0xf7uy; 0x69uy; 0x92uy; ] in assert_norm (List.Tot.length l = 16); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let output1_len: (x:UInt32.t { UInt32.v x = B.length output1 }) = 16ul let key2: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x2duy; 0xb0uy; 0x5duy; 0x40uy; 0xc8uy; 0xeduy; 0x44uy; 0x88uy; 0x34uy; 0xd1uy; 0x13uy; 0xafuy; 0x57uy; 0xa1uy; 0xebuy; 0x3auy; 0x2auy; 0x80uy; 0x51uy; 0x36uy; 0xecuy; 0x5buy; 0xbcuy; 0x08uy; 0x93uy; 0x84uy; 0x21uy; 0xb5uy; 0x13uy; 0x88uy; 0x3cuy; 0x0duy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let key2_len: (x:UInt32.t { UInt32.v x = B.length key2 }) = 32ul let nonce2: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) = [@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x3duy; 0x86uy; 0xb5uy; 0x6buy; 0xc8uy; 0xa3uy; 0x1fuy; 0x1duy; ] in assert_norm (List.Tot.length l = 12); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let nonce2_len: (x:UInt32.t { UInt32.v x = B.length nonce2 }) = 12ul let aad2: (b: B.buffer UInt8.t { B.length b = 8 /\ B.recallable b }) = [@inline_let] let l = [ 0x33uy; 0x10uy; 0x41uy; 0x12uy; 0x1fuy; 0xf3uy; 0xd2uy; 0x6buy; ] in assert_norm (List.Tot.length l = 8); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let aad2_len: (x:UInt32.t { UInt32.v x = B.length aad2 }) = 8ul let input2: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b /\ B.disjoint b aad2 }) = B.recall aad2;[@inline_let] let l = [ ] in assert_norm (List.Tot.length l = 0); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let input2_len: (x:UInt32.t { UInt32.v x = B.length input2 }) = 0ul let output2: (b: B.buffer UInt8.t { B.length b = 16 /\ B.recallable b }) = [@inline_let] let l = [ 0xdduy; 0x6buy; 0x3buy; 0x82uy; 0xceuy; 0x5auy; 0xbduy; 0xd6uy; 0xa9uy; 0x35uy; 0x83uy; 0xd8uy; 0x8cuy; 0x3duy; 0x85uy; 0x77uy; ] in assert_norm (List.Tot.length l = 16); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let output2_len: (x:UInt32.t { UInt32.v x = B.length output2 }) = 16ul let key3: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x4buy; 0x28uy; 0x4buy; 0xa3uy; 0x7buy; 0xbeuy; 0xe9uy; 0xf8uy; 0x31uy; 0x80uy; 0x82uy; 0xd7uy; 0xd8uy; 0xe8uy; 0xb5uy; 0xa1uy; 0xe2uy; 0x18uy; 0x18uy; 0x8auy; 0x9cuy; 0xfauy; 0xa3uy; 0x3duy; 0x25uy; 0x71uy; 0x3euy; 0x40uy; 0xbcuy; 0x54uy; 0x7auy; 0x3euy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let key3_len: (x:UInt32.t { UInt32.v x = B.length key3 }) = 32ul let nonce3: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) = [@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0xd2uy; 0x32uy; 0x1fuy; 0x29uy; 0x28uy; 0xc6uy; 0xc4uy; 0xc4uy; ] in assert_norm (List.Tot.length l = 12); B.gcmalloc_of_list HyperStack.root l
false
false
Test.Vectors.Chacha20Poly1305.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val nonce3_len:(x: UInt32.t{UInt32.v x = B.length nonce3})
[]
Test.Vectors.Chacha20Poly1305.nonce3_len
{ "file_name": "providers/test/vectors/Test.Vectors.Chacha20Poly1305.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: FStar.UInt32.t {FStar.UInt32.v x = LowStar.Monotonic.Buffer.length Test.Vectors.Chacha20Poly1305.nonce3}
{ "end_col": 6, "end_line": 141, "start_col": 2, "start_line": 141 }
Prims.Tot
val output5_len:(x: UInt32.t{UInt32.v x = B.length output5})
[ { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Test.Vectors", "short_module": null }, { "abbrev": false, "full_module": "Test.Vectors", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let output5_len: (x:UInt32.t { UInt32.v x = B.length output5 }) = 145ul
val output5_len:(x: UInt32.t{UInt32.v x = B.length output5}) let output5_len:(x: UInt32.t{UInt32.v x = B.length output5}) =
false
null
false
145ul
{ "checked_file": "Test.Vectors.Chacha20Poly1305.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Test.Vectors.Chacha20Poly1305.fst" }
[ "total" ]
[ "FStar.UInt32.__uint_to_t" ]
[]
module Test.Vectors.Chacha20Poly1305 module B = LowStar.Buffer #set-options "--max_fuel 0 --max_ifuel 0" let key0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy; 0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let key0_len: (x:UInt32.t { UInt32.v x = B.length key0 }) = 32ul let nonce0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) = [@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; ] in assert_norm (List.Tot.length l = 12); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let nonce0_len: (x:UInt32.t { UInt32.v x = B.length nonce0 }) = 12ul let aad0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) = [@inline_let] let l = [ 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x4euy; 0x91uy; ] in assert_norm (List.Tot.length l = 12); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let aad0_len: (x:UInt32.t { UInt32.v x = B.length aad0 }) = 12ul let input0: (b: B.buffer UInt8.t { B.length b = 265 /\ B.recallable b /\ B.disjoint b aad0 }) = B.recall aad0;[@inline_let] let l = [ 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x72uy; 0x65uy; 0x20uy; 0x64uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x76uy; 0x61uy; 0x6cuy; 0x69uy; 0x64uy; 0x20uy; 0x66uy; 0x6fuy; 0x72uy; 0x20uy; 0x61uy; 0x20uy; 0x6duy; 0x61uy; 0x78uy; 0x69uy; 0x6duy; 0x75uy; 0x6duy; 0x20uy; 0x6fuy; 0x66uy; 0x20uy; 0x73uy; 0x69uy; 0x78uy; 0x20uy; 0x6duy; 0x6fuy; 0x6euy; 0x74uy; 0x68uy; 0x73uy; 0x20uy; 0x61uy; 0x6euy; 0x64uy; 0x20uy; 0x6duy; 0x61uy; 0x79uy; 0x20uy; 0x62uy; 0x65uy; 0x20uy; 0x75uy; 0x70uy; 0x64uy; 0x61uy; 0x74uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x72uy; 0x65uy; 0x70uy; 0x6cuy; 0x61uy; 0x63uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x6fuy; 0x62uy; 0x73uy; 0x6fuy; 0x6cuy; 0x65uy; 0x74uy; 0x65uy; 0x64uy; 0x20uy; 0x62uy; 0x79uy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x74uy; 0x20uy; 0x61uy; 0x6euy; 0x79uy; 0x20uy; 0x74uy; 0x69uy; 0x6duy; 0x65uy; 0x2euy; 0x20uy; 0x49uy; 0x74uy; 0x20uy; 0x69uy; 0x73uy; 0x20uy; 0x69uy; 0x6euy; 0x61uy; 0x70uy; 0x70uy; 0x72uy; 0x6fuy; 0x70uy; 0x72uy; 0x69uy; 0x61uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x75uy; 0x73uy; 0x65uy; 0x20uy; 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x72uy; 0x65uy; 0x66uy; 0x65uy; 0x72uy; 0x65uy; 0x6euy; 0x63uy; 0x65uy; 0x20uy; 0x6duy; 0x61uy; 0x74uy; 0x65uy; 0x72uy; 0x69uy; 0x61uy; 0x6cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x63uy; 0x69uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x68uy; 0x65uy; 0x6duy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x74uy; 0x68uy; 0x61uy; 0x6euy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x2fuy; 0xe2uy; 0x80uy; 0x9cuy; 0x77uy; 0x6fuy; 0x72uy; 0x6buy; 0x20uy; 0x69uy; 0x6euy; 0x20uy; 0x70uy; 0x72uy; 0x6fuy; 0x67uy; 0x72uy; 0x65uy; 0x73uy; 0x73uy; 0x2euy; 0x2fuy; 0xe2uy; 0x80uy; 0x9duy; ] in assert_norm (List.Tot.length l = 265); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let input0_len: (x:UInt32.t { UInt32.v x = B.length input0 }) = 265ul let output0: (b: B.buffer UInt8.t { B.length b = 281 /\ B.recallable b }) = [@inline_let] let l = [ 0x64uy; 0xa0uy; 0x86uy; 0x15uy; 0x75uy; 0x86uy; 0x1auy; 0xf4uy; 0x60uy; 0xf0uy; 0x62uy; 0xc7uy; 0x9buy; 0xe6uy; 0x43uy; 0xbduy; 0x5euy; 0x80uy; 0x5cuy; 0xfduy; 0x34uy; 0x5cuy; 0xf3uy; 0x89uy; 0xf1uy; 0x08uy; 0x67uy; 0x0auy; 0xc7uy; 0x6cuy; 0x8cuy; 0xb2uy; 0x4cuy; 0x6cuy; 0xfcuy; 0x18uy; 0x75uy; 0x5duy; 0x43uy; 0xeeuy; 0xa0uy; 0x9euy; 0xe9uy; 0x4euy; 0x38uy; 0x2duy; 0x26uy; 0xb0uy; 0xbduy; 0xb7uy; 0xb7uy; 0x3cuy; 0x32uy; 0x1buy; 0x01uy; 0x00uy; 0xd4uy; 0xf0uy; 0x3buy; 0x7fuy; 0x35uy; 0x58uy; 0x94uy; 0xcfuy; 0x33uy; 0x2fuy; 0x83uy; 0x0euy; 0x71uy; 0x0buy; 0x97uy; 0xceuy; 0x98uy; 0xc8uy; 0xa8uy; 0x4auy; 0xbduy; 0x0buy; 0x94uy; 0x81uy; 0x14uy; 0xaduy; 0x17uy; 0x6euy; 0x00uy; 0x8duy; 0x33uy; 0xbduy; 0x60uy; 0xf9uy; 0x82uy; 0xb1uy; 0xffuy; 0x37uy; 0xc8uy; 0x55uy; 0x97uy; 0x97uy; 0xa0uy; 0x6euy; 0xf4uy; 0xf0uy; 0xefuy; 0x61uy; 0xc1uy; 0x86uy; 0x32uy; 0x4euy; 0x2buy; 0x35uy; 0x06uy; 0x38uy; 0x36uy; 0x06uy; 0x90uy; 0x7buy; 0x6auy; 0x7cuy; 0x02uy; 0xb0uy; 0xf9uy; 0xf6uy; 0x15uy; 0x7buy; 0x53uy; 0xc8uy; 0x67uy; 0xe4uy; 0xb9uy; 0x16uy; 0x6cuy; 0x76uy; 0x7buy; 0x80uy; 0x4duy; 0x46uy; 0xa5uy; 0x9buy; 0x52uy; 0x16uy; 0xcduy; 0xe7uy; 0xa4uy; 0xe9uy; 0x90uy; 0x40uy; 0xc5uy; 0xa4uy; 0x04uy; 0x33uy; 0x22uy; 0x5euy; 0xe2uy; 0x82uy; 0xa1uy; 0xb0uy; 0xa0uy; 0x6cuy; 0x52uy; 0x3euy; 0xafuy; 0x45uy; 0x34uy; 0xd7uy; 0xf8uy; 0x3fuy; 0xa1uy; 0x15uy; 0x5buy; 0x00uy; 0x47uy; 0x71uy; 0x8cuy; 0xbcuy; 0x54uy; 0x6auy; 0x0duy; 0x07uy; 0x2buy; 0x04uy; 0xb3uy; 0x56uy; 0x4euy; 0xeauy; 0x1buy; 0x42uy; 0x22uy; 0x73uy; 0xf5uy; 0x48uy; 0x27uy; 0x1auy; 0x0buy; 0xb2uy; 0x31uy; 0x60uy; 0x53uy; 0xfauy; 0x76uy; 0x99uy; 0x19uy; 0x55uy; 0xebuy; 0xd6uy; 0x31uy; 0x59uy; 0x43uy; 0x4euy; 0xceuy; 0xbbuy; 0x4euy; 0x46uy; 0x6duy; 0xaeuy; 0x5auy; 0x10uy; 0x73uy; 0xa6uy; 0x72uy; 0x76uy; 0x27uy; 0x09uy; 0x7auy; 0x10uy; 0x49uy; 0xe6uy; 0x17uy; 0xd9uy; 0x1duy; 0x36uy; 0x10uy; 0x94uy; 0xfauy; 0x68uy; 0xf0uy; 0xffuy; 0x77uy; 0x98uy; 0x71uy; 0x30uy; 0x30uy; 0x5buy; 0xeauy; 0xbauy; 0x2euy; 0xdauy; 0x04uy; 0xdfuy; 0x99uy; 0x7buy; 0x71uy; 0x4duy; 0x6cuy; 0x6fuy; 0x2cuy; 0x29uy; 0xa6uy; 0xaduy; 0x5cuy; 0xb4uy; 0x02uy; 0x2buy; 0x02uy; 0x70uy; 0x9buy; 0xeeuy; 0xaduy; 0x9duy; 0x67uy; 0x89uy; 0x0cuy; 0xbbuy; 0x22uy; 0x39uy; 0x23uy; 0x36uy; 0xfeuy; 0xa1uy; 0x85uy; 0x1fuy; 0x38uy; ] in assert_norm (List.Tot.length l = 281); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let output0_len: (x:UInt32.t { UInt32.v x = B.length output0 }) = 281ul let key1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x4cuy; 0xf5uy; 0x96uy; 0x83uy; 0x38uy; 0xe6uy; 0xaeuy; 0x7fuy; 0x2duy; 0x29uy; 0x25uy; 0x76uy; 0xd5uy; 0x75uy; 0x27uy; 0x86uy; 0x91uy; 0x9auy; 0x27uy; 0x7auy; 0xfbuy; 0x46uy; 0xc5uy; 0xefuy; 0x94uy; 0x81uy; 0x79uy; 0x57uy; 0x14uy; 0x59uy; 0x40uy; 0x68uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let key1_len: (x:UInt32.t { UInt32.v x = B.length key1 }) = 32ul let nonce1: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) = [@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0xcauy; 0xbfuy; 0x33uy; 0x71uy; 0x32uy; 0x45uy; 0x77uy; 0x8euy; ] in assert_norm (List.Tot.length l = 12); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let nonce1_len: (x:UInt32.t { UInt32.v x = B.length nonce1 }) = 12ul let aad1: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b }) = [@inline_let] let l = [ ] in assert_norm (List.Tot.length l = 0); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let aad1_len: (x:UInt32.t { UInt32.v x = B.length aad1 }) = 0ul let input1: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b /\ B.disjoint b aad1 }) = B.recall aad1;[@inline_let] let l = [ ] in assert_norm (List.Tot.length l = 0); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let input1_len: (x:UInt32.t { UInt32.v x = B.length input1 }) = 0ul let output1: (b: B.buffer UInt8.t { B.length b = 16 /\ B.recallable b }) = [@inline_let] let l = [ 0xeauy; 0xe0uy; 0x1euy; 0x9euy; 0x2cuy; 0x91uy; 0xaauy; 0xe1uy; 0xdbuy; 0x5duy; 0x99uy; 0x3fuy; 0x8auy; 0xf7uy; 0x69uy; 0x92uy; ] in assert_norm (List.Tot.length l = 16); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let output1_len: (x:UInt32.t { UInt32.v x = B.length output1 }) = 16ul let key2: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x2duy; 0xb0uy; 0x5duy; 0x40uy; 0xc8uy; 0xeduy; 0x44uy; 0x88uy; 0x34uy; 0xd1uy; 0x13uy; 0xafuy; 0x57uy; 0xa1uy; 0xebuy; 0x3auy; 0x2auy; 0x80uy; 0x51uy; 0x36uy; 0xecuy; 0x5buy; 0xbcuy; 0x08uy; 0x93uy; 0x84uy; 0x21uy; 0xb5uy; 0x13uy; 0x88uy; 0x3cuy; 0x0duy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let key2_len: (x:UInt32.t { UInt32.v x = B.length key2 }) = 32ul let nonce2: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) = [@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x3duy; 0x86uy; 0xb5uy; 0x6buy; 0xc8uy; 0xa3uy; 0x1fuy; 0x1duy; ] in assert_norm (List.Tot.length l = 12); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let nonce2_len: (x:UInt32.t { UInt32.v x = B.length nonce2 }) = 12ul let aad2: (b: B.buffer UInt8.t { B.length b = 8 /\ B.recallable b }) = [@inline_let] let l = [ 0x33uy; 0x10uy; 0x41uy; 0x12uy; 0x1fuy; 0xf3uy; 0xd2uy; 0x6buy; ] in assert_norm (List.Tot.length l = 8); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let aad2_len: (x:UInt32.t { UInt32.v x = B.length aad2 }) = 8ul let input2: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b /\ B.disjoint b aad2 }) = B.recall aad2;[@inline_let] let l = [ ] in assert_norm (List.Tot.length l = 0); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let input2_len: (x:UInt32.t { UInt32.v x = B.length input2 }) = 0ul let output2: (b: B.buffer UInt8.t { B.length b = 16 /\ B.recallable b }) = [@inline_let] let l = [ 0xdduy; 0x6buy; 0x3buy; 0x82uy; 0xceuy; 0x5auy; 0xbduy; 0xd6uy; 0xa9uy; 0x35uy; 0x83uy; 0xd8uy; 0x8cuy; 0x3duy; 0x85uy; 0x77uy; ] in assert_norm (List.Tot.length l = 16); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let output2_len: (x:UInt32.t { UInt32.v x = B.length output2 }) = 16ul let key3: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x4buy; 0x28uy; 0x4buy; 0xa3uy; 0x7buy; 0xbeuy; 0xe9uy; 0xf8uy; 0x31uy; 0x80uy; 0x82uy; 0xd7uy; 0xd8uy; 0xe8uy; 0xb5uy; 0xa1uy; 0xe2uy; 0x18uy; 0x18uy; 0x8auy; 0x9cuy; 0xfauy; 0xa3uy; 0x3duy; 0x25uy; 0x71uy; 0x3euy; 0x40uy; 0xbcuy; 0x54uy; 0x7auy; 0x3euy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let key3_len: (x:UInt32.t { UInt32.v x = B.length key3 }) = 32ul let nonce3: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) = [@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0xd2uy; 0x32uy; 0x1fuy; 0x29uy; 0x28uy; 0xc6uy; 0xc4uy; 0xc4uy; ] in assert_norm (List.Tot.length l = 12); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let nonce3_len: (x:UInt32.t { UInt32.v x = B.length nonce3 }) = 12ul let aad3: (b: B.buffer UInt8.t { B.length b = 8 /\ B.recallable b }) = [@inline_let] let l = [ 0x6auy; 0xe2uy; 0xaduy; 0x3fuy; 0x88uy; 0x39uy; 0x5auy; 0x40uy; ] in assert_norm (List.Tot.length l = 8); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let aad3_len: (x:UInt32.t { UInt32.v x = B.length aad3 }) = 8ul let input3: (b: B.buffer UInt8.t { B.length b = 1 /\ B.recallable b /\ B.disjoint b aad3 }) = B.recall aad3;[@inline_let] let l = [ 0xa4uy; ] in assert_norm (List.Tot.length l = 1); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let input3_len: (x:UInt32.t { UInt32.v x = B.length input3 }) = 1ul let output3: (b: B.buffer UInt8.t { B.length b = 17 /\ B.recallable b }) = [@inline_let] let l = [ 0xb7uy; 0x1buy; 0xb0uy; 0x73uy; 0x59uy; 0xb0uy; 0x84uy; 0xb2uy; 0x6duy; 0x8euy; 0xabuy; 0x94uy; 0x31uy; 0xa1uy; 0xaeuy; 0xacuy; 0x89uy; ] in assert_norm (List.Tot.length l = 17); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let output3_len: (x:UInt32.t { UInt32.v x = B.length output3 }) = 17ul let key4: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x66uy; 0xcauy; 0x9cuy; 0x23uy; 0x2auy; 0x4buy; 0x4buy; 0x31uy; 0x0euy; 0x92uy; 0x89uy; 0x8buy; 0xf4uy; 0x93uy; 0xc7uy; 0x87uy; 0x98uy; 0xa3uy; 0xd8uy; 0x39uy; 0xf8uy; 0xf4uy; 0xa7uy; 0x01uy; 0xc0uy; 0x2euy; 0x0auy; 0xa6uy; 0x7euy; 0x5auy; 0x78uy; 0x87uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let key4_len: (x:UInt32.t { UInt32.v x = B.length key4 }) = 32ul let nonce4: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) = [@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x20uy; 0x1cuy; 0xaauy; 0x5fuy; 0x9cuy; 0xbfuy; 0x92uy; 0x30uy; ] in assert_norm (List.Tot.length l = 12); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let nonce4_len: (x:UInt32.t { UInt32.v x = B.length nonce4 }) = 12ul let aad4: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b }) = [@inline_let] let l = [ ] in assert_norm (List.Tot.length l = 0); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let aad4_len: (x:UInt32.t { UInt32.v x = B.length aad4 }) = 0ul let input4: (b: B.buffer UInt8.t { B.length b = 1 /\ B.recallable b /\ B.disjoint b aad4 }) = B.recall aad4;[@inline_let] let l = [ 0x2duy; ] in assert_norm (List.Tot.length l = 1); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let input4_len: (x:UInt32.t { UInt32.v x = B.length input4 }) = 1ul let output4: (b: B.buffer UInt8.t { B.length b = 17 /\ B.recallable b }) = [@inline_let] let l = [ 0xbfuy; 0xe1uy; 0x5buy; 0x0buy; 0xdbuy; 0x6buy; 0xf5uy; 0x5euy; 0x6cuy; 0x5duy; 0x84uy; 0x44uy; 0x39uy; 0x81uy; 0xc1uy; 0x9cuy; 0xacuy; ] in assert_norm (List.Tot.length l = 17); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let output4_len: (x:UInt32.t { UInt32.v x = B.length output4 }) = 17ul let key5: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) = [@inline_let] let l = [ 0x68uy; 0x7buy; 0x8duy; 0x8euy; 0xe3uy; 0xc4uy; 0xdduy; 0xaeuy; 0xdfuy; 0x72uy; 0x7fuy; 0x53uy; 0x72uy; 0x25uy; 0x1euy; 0x78uy; 0x91uy; 0xcbuy; 0x69uy; 0x76uy; 0x1fuy; 0x49uy; 0x93uy; 0xf9uy; 0x6fuy; 0x21uy; 0xccuy; 0x39uy; 0x9cuy; 0xaduy; 0xb1uy; 0x01uy; ] in assert_norm (List.Tot.length l = 32); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let key5_len: (x:UInt32.t { UInt32.v x = B.length key5 }) = 32ul let nonce5: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) = [@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0xdfuy; 0x51uy; 0x84uy; 0x82uy; 0x42uy; 0x0cuy; 0x75uy; 0x9cuy; ] in assert_norm (List.Tot.length l = 12); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let nonce5_len: (x:UInt32.t { UInt32.v x = B.length nonce5 }) = 12ul let aad5: (b: B.buffer UInt8.t { B.length b = 7 /\ B.recallable b }) = [@inline_let] let l = [ 0x70uy; 0xd3uy; 0x33uy; 0xf3uy; 0x8buy; 0x18uy; 0x0buy; ] in assert_norm (List.Tot.length l = 7); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let aad5_len: (x:UInt32.t { UInt32.v x = B.length aad5 }) = 7ul let input5: (b: B.buffer UInt8.t { B.length b = 129 /\ B.recallable b /\ B.disjoint b aad5 }) = B.recall aad5;[@inline_let] let l = [ 0x33uy; 0x2fuy; 0x94uy; 0xc1uy; 0xa4uy; 0xefuy; 0xccuy; 0x2auy; 0x5buy; 0xa6uy; 0xe5uy; 0x8fuy; 0x1duy; 0x40uy; 0xf0uy; 0x92uy; 0x3cuy; 0xd9uy; 0x24uy; 0x11uy; 0xa9uy; 0x71uy; 0xf9uy; 0x37uy; 0x14uy; 0x99uy; 0xfauy; 0xbeuy; 0xe6uy; 0x80uy; 0xdeuy; 0x50uy; 0xc9uy; 0x96uy; 0xd4uy; 0xb0uy; 0xecuy; 0x9euy; 0x17uy; 0xecuy; 0xd2uy; 0x5euy; 0x72uy; 0x99uy; 0xfcuy; 0x0auy; 0xe1uy; 0xcbuy; 0x48uy; 0xd2uy; 0x85uy; 0xdduy; 0x2fuy; 0x90uy; 0xe0uy; 0x66uy; 0x3buy; 0xe6uy; 0x20uy; 0x74uy; 0xbeuy; 0x23uy; 0x8fuy; 0xcbuy; 0xb4uy; 0xe4uy; 0xdauy; 0x48uy; 0x40uy; 0xa6uy; 0xd1uy; 0x1buy; 0xc7uy; 0x42uy; 0xceuy; 0x2fuy; 0x0cuy; 0xa6uy; 0x85uy; 0x6euy; 0x87uy; 0x37uy; 0x03uy; 0xb1uy; 0x7cuy; 0x25uy; 0x96uy; 0xa3uy; 0x05uy; 0xd8uy; 0xb0uy; 0xf4uy; 0xeduy; 0xeauy; 0xc2uy; 0xf0uy; 0x31uy; 0x98uy; 0x6cuy; 0xd1uy; 0x14uy; 0x25uy; 0xc0uy; 0xcbuy; 0x01uy; 0x74uy; 0xd0uy; 0x82uy; 0xf4uy; 0x36uy; 0xf5uy; 0x41uy; 0xd5uy; 0xdcuy; 0xcauy; 0xc5uy; 0xbbuy; 0x98uy; 0xfeuy; 0xfcuy; 0x69uy; 0x21uy; 0x70uy; 0xd8uy; 0xa4uy; 0x4buy; 0xc8uy; 0xdeuy; 0x8fuy; ] in assert_norm (List.Tot.length l = 129); B.gcmalloc_of_list HyperStack.root l inline_for_extraction let input5_len: (x:UInt32.t { UInt32.v x = B.length input5 }) = 129ul let output5: (b: B.buffer UInt8.t { B.length b = 145 /\ B.recallable b }) = [@inline_let] let l = [ 0x8buy; 0x06uy; 0xd3uy; 0x31uy; 0xb0uy; 0x93uy; 0x45uy; 0xb1uy; 0x75uy; 0x6euy; 0x26uy; 0xf9uy; 0x67uy; 0xbcuy; 0x90uy; 0x15uy; 0x81uy; 0x2cuy; 0xb5uy; 0xf0uy; 0xc6uy; 0x2buy; 0xc7uy; 0x8cuy; 0x56uy; 0xd1uy; 0xbfuy; 0x69uy; 0x6cuy; 0x07uy; 0xa0uy; 0xdauy; 0x65uy; 0x27uy; 0xc9uy; 0x90uy; 0x3duy; 0xefuy; 0x4buy; 0x11uy; 0x0fuy; 0x19uy; 0x07uy; 0xfduy; 0x29uy; 0x92uy; 0xd9uy; 0xc8uy; 0xf7uy; 0x99uy; 0x2euy; 0x4auy; 0xd0uy; 0xb8uy; 0x2cuy; 0xdcuy; 0x93uy; 0xf5uy; 0x9euy; 0x33uy; 0x78uy; 0xd1uy; 0x37uy; 0xc3uy; 0x66uy; 0xd7uy; 0x5euy; 0xbcuy; 0x44uy; 0xbfuy; 0x53uy; 0xa5uy; 0xbcuy; 0xc4uy; 0xcbuy; 0x7buy; 0x3auy; 0x8euy; 0x7fuy; 0x02uy; 0xbduy; 0xbbuy; 0xe7uy; 0xcauy; 0xa6uy; 0x6cuy; 0x6buy; 0x93uy; 0x21uy; 0x93uy; 0x10uy; 0x61uy; 0xe7uy; 0x69uy; 0xd0uy; 0x78uy; 0xf3uy; 0x07uy; 0x5auy; 0x1auy; 0x8fuy; 0x73uy; 0xaauy; 0xb1uy; 0x4euy; 0xd3uy; 0xdauy; 0x4fuy; 0xf3uy; 0x32uy; 0xe1uy; 0x66uy; 0x3euy; 0x6cuy; 0xc6uy; 0x13uy; 0xbauy; 0x06uy; 0x5buy; 0xfcuy; 0x6auy; 0xe5uy; 0x6fuy; 0x60uy; 0xfbuy; 0x07uy; 0x40uy; 0xb0uy; 0x8cuy; 0x9duy; 0x84uy; 0x43uy; 0x6buy; 0xc1uy; 0xf7uy; 0x8duy; 0x8duy; 0x31uy; 0xf7uy; 0x7auy; 0x39uy; 0x4duy; 0x8fuy; 0x9auy; 0xebuy; ] in assert_norm (List.Tot.length l = 145); B.gcmalloc_of_list HyperStack.root l
false
false
Test.Vectors.Chacha20Poly1305.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val output5_len:(x: UInt32.t{UInt32.v x = B.length output5})
[]
Test.Vectors.Chacha20Poly1305.output5_len
{ "file_name": "providers/test/vectors/Test.Vectors.Chacha20Poly1305.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: FStar.UInt32.t {FStar.UInt32.v x = LowStar.Monotonic.Buffer.length Test.Vectors.Chacha20Poly1305.output5}
{ "end_col": 7, "end_line": 245, "start_col": 2, "start_line": 245 }