val lserialize_maybe_signatureScheme_key:LL.serializer32 serialize_maybe_signatureScheme_key
val lserialize_maybe_signatureScheme_key:LL.serializer32 serialize_maybe_signatureScheme_key
let lserialize_maybe_signatureScheme_key : LL.serializer32 serialize_maybe_signatureScheme_key =
  LL.serializer32_of_leaf_writer_strong_constant_size write_maybe_signatureScheme_key 2ul ()
module MiTLS.Parsers.SignatureScheme

(* This file has been automatically generated by EverParse. *)
open FStar.Bytes
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module LP = LowParse.Spec
module LT = LowParse.TacLib
module LS = LowParse.SLow
module LSZ = LowParse.SLow
module LPI = LowParse.Spec.AllIntegers
module LL = LowParse.Low
module L = FStar.List.Tot
module B = LowStar.Buffer
module BY = FStar.Bytes
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST

#reset-options "--using_facts_from '* -FStar.Tactics -FStar.Reflection' --z3rlimit 16 --z3cliopt smt.arith.nl=false --max_fuel 2 --max_ifuel 2"

[@LT.Norm] inline_for_extraction let signatureScheme_enum : LP.enum signatureScheme U16.t =
  [@inline_let] let e = [
    Rsa_pkcs1_md5, 257us;
    Rsa_pkcs1_sha1, 513us;
    Ecdsa_md5, 259us;
    Ecdsa_sha1, 515us;
    Rsa_pkcs1_sha256, 1025us;
    Rsa_pkcs1_sha384, 1281us;
    Rsa_pkcs1_sha512, 1537us;
    Ecdsa_secp256r1_sha256, 1027us;
    Ecdsa_secp384r1_sha384, 1283us;
    Ecdsa_secp521r1_sha512, 1539us;
    Rsa_pss_rsae_sha256, 2052us;
    Rsa_pss_rsae_sha384, 2053us;
    Rsa_pss_rsae_sha512, 2054us;
    Ed25519, 2055us;
    Ed448, 2056us;
    Rsa_pss_pss_sha256, 2057us;
    Rsa_pss_pss_sha384, 2058us;
    Rsa_pss_pss_sha512, 2059us;
  ] in
  [@inline_let] let _ =
    assert_norm (L.noRepeats (LP.list_map fst e))
  in
  [@inline_let] let _ = 
    assert_norm (L.noRepeats (LP.list_map snd e))
  in e

noextract let signatureScheme_repr_parser = LPI.parse_u16

noextract let signatureScheme_repr_serializer = LPI.serialize_u16

inline_for_extraction noextract let signatureScheme_repr_parser32 = LS.parse32_u16

inline_for_extraction noextract let signatureScheme_repr_serializer32 = LS.serialize32_u16

inline_for_extraction noextract let signatureScheme_repr_size32 = LSZ.size32_u16

inline_for_extraction noextract let signatureScheme_repr_validator = (LL.validate_u16 ())

inline_for_extraction noextract let signatureScheme_repr_jumper = LL.jump_u16

inline_for_extraction noextract let signatureScheme_repr_reader = LL.read_u16

inline_for_extraction noextract let signatureScheme_repr_writer = LL.write_u16

inline_for_extraction let synth_signatureScheme (x:LP.maybe_enum_key signatureScheme_enum) : signatureScheme = 
  match x with
  | LP.Known k -> k
  | LP.Unknown y ->
    [@inline_let] let v : U16.t = y in
    [@inline_let] let _ = assert_norm (LP.list_mem v (LP.list_map snd signatureScheme_enum) == known_signatureScheme_repr v) in
    Unknown_signatureScheme v

inline_for_extraction let synth_signatureScheme_inv (x:signatureScheme) : LP.maybe_enum_key signatureScheme_enum = 
  match x with
  | Unknown_signatureScheme y ->
    [@inline_let] let v : U16.t = y in
    [@inline_let] let _ = assert_norm (LP.list_mem v (LP.list_map snd signatureScheme_enum) == known_signatureScheme_repr v) in
    LP.Unknown v
  | x ->
    [@inline_let] let x1 : signatureScheme = x in
    [@inline_let] let _ : squash(not (Unknown_signatureScheme? x1) ==> LP.list_mem x1 (LP.list_map fst signatureScheme_enum)) =
      _ by (LP.synth_maybe_enum_key_inv_unknown_tac x1)
    in
    LP.Known (x1 <: LP.enum_key signatureScheme_enum)

let lemma_synth_signatureScheme_inv' () : Lemma
  (LP.synth_inverse synth_signatureScheme_inv synth_signatureScheme)
= LP.forall_maybe_enum_key signatureScheme_enum (fun x -> synth_signatureScheme_inv (synth_signatureScheme x) == x)
    (_ by (LP.forall_maybe_enum_key_known_tac ()))
    (_ by (LP.forall_maybe_enum_key_unknown_tac ()))

let lemma_synth_signatureScheme_inj () : Lemma
  (LP.synth_injective synth_signatureScheme) = 
  lemma_synth_signatureScheme_inv' ();
  LP.synth_inverse_synth_injective synth_signatureScheme synth_signatureScheme_inv

#push-options "--max_ifuel 0 --initial_ifuel 0 --max_fuel 0 --max_ifuel 0"
let lemma_synth_signatureScheme_inv () : Lemma
  (LP.synth_inverse synth_signatureScheme synth_signatureScheme_inv) = allow_inversion signatureScheme; ()

#pop-options
noextract let parse_maybe_signatureScheme_key : LP.parser _ (LP.maybe_enum_key signatureScheme_enum) =
  LP.parse_maybe_enum_key signatureScheme_repr_parser signatureScheme_enum

noextract let serialize_maybe_signatureScheme_key : LP.serializer parse_maybe_signatureScheme_key =
  LP.serialize_maybe_enum_key signatureScheme_repr_parser signatureScheme_repr_serializer signatureScheme_enum

noextract let signatureScheme_parser : LP.parser _ signatureScheme =
  lemma_synth_signatureScheme_inj ();
  parse_maybe_signatureScheme_key `LP.parse_synth` synth_signatureScheme

noextract let signatureScheme_serializer : LP.serializer signatureScheme_parser =
  lemma_synth_signatureScheme_inj ();
  lemma_synth_signatureScheme_inv ();
  LP.serialize_synth _ synth_signatureScheme serialize_maybe_signatureScheme_key synth_signatureScheme_inv ()

let signatureScheme_bytesize (x:signatureScheme) : GTot nat = Seq.length (signatureScheme_serializer x)

let signatureScheme_bytesize_eq x = ()

let parse32_maybe_signatureScheme_key : LS.parser32 parse_maybe_signatureScheme_key =
  FStar.Tactics.synth_by_tactic (LS.parse32_maybe_enum_key_tac signatureScheme_repr_parser32 signatureScheme_enum)

let signatureScheme_parser32 : LS.parser32 signatureScheme_parser =
  lemma_synth_signatureScheme_inj ();
  LS.parse32_synth _ synth_signatureScheme (fun x->synth_signatureScheme x) parse32_maybe_signatureScheme_key ()

let serialize32_maybe_signatureScheme_key : LS.serializer32 serialize_maybe_signatureScheme_key =
  FStar.Tactics.synth_by_tactic (LS.serialize32_maybe_enum_key_tac
    signatureScheme_repr_serializer32 signatureScheme_enum)

let signatureScheme_serializer32 : LS.serializer32 signatureScheme_serializer =
  lemma_synth_signatureScheme_inj ();
  lemma_synth_signatureScheme_inv ();
  LS.serialize32_synth _ synth_signatureScheme _ serialize32_maybe_signatureScheme_key synth_signatureScheme_inv (fun x->synth_signatureScheme_inv x) ()

let signatureScheme_size32 =
  [@inline_let] let _ = assert_norm (LSZ.size32_constant_precond signatureScheme_serializer 2ul) in
  LSZ.size32_constant signatureScheme_serializer 2ul ()

[@@ (LT.postprocess_with LT.pp_norm_tac) ]
inline_for_extraction let read_maybe_signatureScheme_key : LL.leaf_reader parse_maybe_signatureScheme_key =
    LL.mk_read_maybe_enum_key signatureScheme_repr_reader signatureScheme_enum

let signatureScheme_reader =
 [@inline_let] let _ = lemma_synth_signatureScheme_inj () in
 LL.read_synth' parse_maybe_signatureScheme_key synth_signatureScheme read_maybe_signatureScheme_key ()

inline_for_extraction let write_maybe_signatureScheme_key : LL.leaf_writer_strong serialize_maybe_signatureScheme_key =
  LL.write_maybe_enum_key signatureScheme_repr_writer signatureScheme_enum (_ by (LP.enum_repr_of_key_tac signatureScheme_enum))
/
prims.fst.checked LowStar.Buffer.fst.checked LowParse.TacLib.fst.checked LowParse.Spec.AllIntegers.fst.checked LowParse.Spec.fst.checked LowParse.SLow.fst.checked LowParse.Low.fst.checked FStar.UInt8.fsti.checked FStar.UInt64.fsti.checked FStar.UInt32.fsti.checked FStar.UInt16.fsti.checked FStar.Tactics.Effect.fsti.checked FStar.Tactics.fst.checked FStar.Seq.fst.checked FStar.Pervasives.Native.fst.checked FStar.Pervasives.fsti.checked FStar.List.Tot.fst.checked FStar.HyperStack.ST.fsti.checked FStar.HyperStack.fst.checked FStar.Bytes.fsti.checked
MiTLS.Parsers.SignatureScheme.fst
LowParse.Low.Base.serializer32 MiTLS.Parsers.SignatureScheme.serialize_maybe_signatureScheme_key
LowParse.Low.Base.serializer32_of_leaf_writer_strong_constant_size LowParse.Spec.Int.parse_u16_kind LowParse.Spec.Enum.maybe_enum_key MiTLS.Parsers.SignatureScheme.signatureScheme FStar.UInt16.t MiTLS.Parsers.SignatureScheme.signatureScheme_enum MiTLS.Parsers.SignatureScheme.parse_maybe_signatureScheme_key MiTLS.Parsers.SignatureScheme.serialize_maybe_signatureScheme_key MiTLS.Parsers.SignatureScheme.write_maybe_signatureScheme_key FStar.UInt32.__uint_to_t
let lserialize_maybe_signatureScheme_key:LL.serializer32 serialize_maybe_signatureScheme_key =
  
LL.serializer32_of_leaf_writer_strong_constant_size write_maybe_signatureScheme_key 2ul ()