val serialize32_asn1_boolean_backwards (_:unit)
: (serializer32_backwards serialize_asn1_boolean)
val serialize32_asn1_boolean_backwards (_:unit)
: (serializer32_backwards serialize_asn1_boolean)
let serialize32_asn1_boolean_backwards ()
= fun (x: bool)
    (#rrel #rel: _)
    (b: B.mbuffer byte rrel rel)
    (pos: size_t)
->  let offset = len_of_asn1_boolean x in
    let content: byte = encode_asn1_boolean x in
    (* Prf *) lemma_serialize_asn1_boolean_unfold x;
    (* Prf *) serialize_u8_spec content;
    mbuffer_upd (* <-- NOTE: serialize the encoding of a BOOLEAN value *)
      (* buf *) b
      (*range*) (v (pos - offset)) (v pos)
      (* pos *) (pos - offset)
      (* val *)content;
(*return*) offset
module ASN1.Low.Value.BOOLEAN
///
/// ASN.1 Low
///
open LowParse.Low.Base
open LowParse.Low.Combinators
open LowParse.Low.Int

open ASN1.Base
open ASN1.Spec.Value.BOOLEAN
open ASN1.Low.Base

module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module B = LowStar.Buffer
open FStar.Integers

(* NOTE: Read after `ASN1.Spec.Tag`, `ASN1.Spec.Length` *)

friend ASN1.Spec.Value.BOOLEAN

///
/// Encoding a tag into bytes at low-level, implementation of `synth_..._inverse`

///
inline_for_extraction
let encode_asn1_boolean
  (x: bool)
: Tot (b: byte{b == synth_asn1_boolean_inverse x})
= match x with
  | true  -> 0xFFuy
  | false -> 0x00uy

///
/// Low-level function to be used to compute the length of a value's serialization
///
inline_for_extraction
let len_of_asn1_boolean
  (b: bool)
: Tot (l: size_t{
  v l == Seq.length (serialize serialize_asn1_boolean b) /\
  v l == 1})
= lemma_serialize_asn1_boolean_unfold b;
  lemma_serialize_asn1_boolean_size b;
  1ul

///
/// Backwards low-level serializer for ASN1 BOOLEAN values
/
prims.fst.checked LowStar.Buffer.fst.checked LowParse.Low.Int.fsti.checked LowParse.Low.Combinators.fsti.checked LowParse.Low.Base.fst.checked FStar.UInt8.fsti.checked FStar.UInt32.fsti.checked FStar.Seq.fst.checked FStar.Pervasives.Native.fst.checked FStar.Pervasives.fsti.checked FStar.Integers.fst.checked FStar.HyperStack.ST.fsti.checked FStar.HyperStack.fst.checked ASN1.Spec.Value.BOOLEAN.fst.checked ASN1.Spec.Value.BOOLEAN.fst.checked ASN1.Spec.Tag.fsti.checked ASN1.Spec.Length.fsti.checked ASN1.Low.Tag.fsti.checked ASN1.Low.Length.fsti.checked ASN1.Low.Base.fst.checked ASN1.Base.fst.checked
ASN1.Low.Value.BOOLEAN.fst
_: Prims.unit -> ASN1.Low.Base.serializer32_backwards ASN1.Spec.Value.BOOLEAN.serialize_asn1_boolean
Prims.unit Prims.bool LowStar.Monotonic.Buffer.srel ASN1.Low.Base.byte LowStar.Monotonic.Buffer.mbuffer ASN1.Low.Base.size_t FStar.UInt32.t LowParse.Low.Base.mbuffer_upd FStar.Ghost.hide Prims.nat FStar.Integers.v FStar.Integers.Unsigned FStar.Integers.W32 FStar.Integers.op_Subtraction LowParse.Spec.Int.serialize_u8_spec ASN1.Spec.Value.BOOLEAN.lemma_serialize_asn1_boolean_unfold ASN1.Low.Value.BOOLEAN.encode_asn1_boolean Prims.l_and Prims.eq2 Prims.int Prims.l_or Prims.b2t Prims.op_GreaterThanOrEqual FStar.Pervasives.norm Prims.Cons FStar.Pervasives.norm_step FStar.Pervasives.iota FStar.Pervasives.delta_attr Prims.string Prims.Nil FStar.Pervasives.Native.Mktuple2 FStar.Integers.signed_width FStar.Pervasives.Native.option FStar.Integers.nat_of_width FStar.Integers.width_of_sw FStar.Integers.width Prims.l_True FStar.Int.size FStar.Integers.fixed_width FStar.UInt.size FStar.UInt32.v FStar.Seq.Base.length LowParse.Bytes.byte LowParse.Spec.Base.serialize ASN1.Spec.Value.BOOLEAN.parse_asn1_boolean_kind ASN1.Base.datatype_of_asn1_type ASN1.Base.BOOLEAN ASN1.Spec.Value.BOOLEAN.parse_asn1_boolean ASN1.Spec.Value.BOOLEAN.serialize_asn1_boolean ASN1.Low.Value.BOOLEAN.len_of_asn1_boolean
let serialize32_asn1_boolean_backwards () =
  
fun (x: bool) (#rrel: _) (#rel: _) (b: B.mbuffer byte rrel rel) (pos: size_t) ->
  let offset = len_of_asn1_boolean x in
  let content:byte = encode_asn1_boolean x in
  lemma_serialize_asn1_boolean_unfold x;
  serialize_u8_spec content;
  mbuffer_upd b (v (pos - offset)) (v pos) (pos - offset) content;
  offset